| |
- calcprob(beta, x)
- calculate probabilities (in percent) given beta and x
- logistic_regression(x, y, beta_start=None, verbose=False, CONV_THRESH=0.001, MAXIT=500)
- Uses the Newton-Raphson algorithm to calculate maximum
likliehood estimates of a logistic regression.
Can handle multivariate case (more than one predictor).
x - rank-2 array of predictors. Number of predictors = x.shape[0]=N
y - binary outcomes (len(y) = x.shape[1])
beta_start - initial beta vector (default zeros(N+1,x.dtype)
if verbose=True, diagnostics printed for each iteration.
MAXIT - max number of iterations (default 500)
CONV_THRESH - convergence threshold (sum of absolute differences
of beta-beta_old)
returns beta (the logistic regression coefficients, a N+1 element vector),
J_bar (the (N+1)x(N=1) information matrix), and l (the log-likeliehood).
J_bar can be used to estimate the covariance matrix and the standard
error beta.
l can be used for a chi-squared significance test.
covmat = inverse(J_bar) --> covariance matrix
stderr = sqrt(diag(covmat)) --> standard errors for beta
deviance = -2l --> scaled deviance statistic
chi-squared value for -2l is the model chi-squared test.
- simple_logistic_regression(x, y, beta_start=None, verbose=False, CONV_THRESH=0.001, MAXIT=500)
- Uses the Newton-Raphson algorithm to calculate maximum
likliehood estimates of a simple logistic regression.
Faster than logistic_regression when there is only one predictor.
x - predictor
y - binary outcomes (len(y) = len(x))
beta_start - initial beta (default zero)
if verbose=True, diagnostics printed for each iteration.
MAXIT - max number of iterations (default 500)
CONV_THRESH - convergence threshold (sum of absolute differences
of beta-beta_old)
returns beta (the logistic regression coefficients, a 2-element vector),
J_bar (the 2x2 information matrix), and l (the log-likeliehood).
J_bar can be used to estimate the covariance matrix and the standard
error beta.
l can be used for a chi-squared significance test.
covmat = inverse(J_bar) --> covariance matrix
stderr = sqrt(diag(covmat)) --> standard errors for beta
deviance = -2l --> scaled deviance statistic
chi-squared value for -2l is the model chi-squared test.
|