|
|
@@ -360,8 +360,8 @@ class LogisticPolyRegression:
|
|
|
x: array of n floats
|
|
|
y: array of n int in {0, 1}
|
|
|
|
|
|
- Return:
|
|
|
- pars
|
|
|
+ Return:
|
|
|
+ dict {"pars", "cost", "success"}
|
|
|
"""
|
|
|
def fit(self, x, y, pars0 = None, method = "local"):
|
|
|
|
|
|
@@ -391,7 +391,7 @@ class LogisticPolyRegression:
|
|
|
|
|
|
else:
|
|
|
assert False, "This method is not supported."
|
|
|
-
|
|
|
+
|
|
|
return {"pars": res.x, "cost": res.fun, "success": res.success}
|
|
|
|
|
|
"""
|
|
|
@@ -414,7 +414,8 @@ class LogisticPolyRegression:
|
|
|
"LLF": log_likelihood,
|
|
|
"AIC": AIC,
|
|
|
"BIC": BIC,
|
|
|
- "A": classification accuracy (threshold values = 0.5 prob)}
|
|
|
+ "A": classification accuracy (threshold values = 0.5 prob),
|
|
|
+ "chi2": chi2 statistic,}
|
|
|
|
|
|
Ref:
|
|
|
https://en.wikipedia.org/wiki/Logistic_regression
|
|
|
@@ -514,6 +515,23 @@ class LogisticPolyRegression:
|
|
|
return np.linalg.inv(H)
|
|
|
|
|
|
"""
|
|
|
+ Calculating standard errors fo model parameters for normal distribution of parameters:
|
|
|
+
|
|
|
+ pars ~ N(mean_pars, cov_pars)
|
|
|
+
|
|
|
+ Input:
|
|
|
+
|
|
|
+ cov_pars: array of rxr floats, variance-covariance matrix of parameters
|
|
|
+
|
|
|
+ Return:
|
|
|
+ array of r floats, standard errors of parameters
|
|
|
+ """
|
|
|
+ def get_SE_pars_normal(self, cov_pars):
|
|
|
+
|
|
|
+ # computing standard errors of parameters
|
|
|
+ return np.sqrt(np.diag(cov_pars))
|
|
|
+
|
|
|
+ """
|
|
|
Calculating quantiles of the model parameters at given probabilities p
|
|
|
for normal distribution of parameters:
|
|
|
|