naginterfaces.library.contab.condl_logistic¶
- naginterfaces.library.contab.condl_logistic(ns, z, isz, ic, isi, b, tol, maxit, iprint=0, io_manager=None)[source]¶
condl_logistic
returns parameter estimates for the conditional logistic analysis of stratified data, for example, data from case-control studies and survival analyses.For full information please refer to the NAG Library document for g11ca
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g11/g11caf.html
- Parameters
- nsint
The number of strata, .
- zfloat, array-like, shape
The th row must contain the covariates which are associated with the th observation.
- iszint, array-like, shape
Indicates which subset of covariates are to be included in the model.
If , the th covariate is included in the model.
If , the th covariate is excluded from the model and not referenced.
- icint, array-like, shape
Indicates whether the th observation is a case or a control.
If , indicates that the th observation is a case.
If , indicates that the th observation is a control.
- isiint, array-like, shape
Stratum indicators which also allow data points to be excluded from the analysis.
If , indicates that the th observation is from the th stratum, where .
If , indicates that the th observation is to be omitted from the analysis.
- bfloat, array-like, shape
Initial estimates of the covariate coefficient parameters . must contain the initial estimate of the coefficent of the covariate in corresponding to the th nonzero value of .
Suggested value: in many cases an initial value of zero for may be used. For another suggestion see Further Comments.
- tolfloat
Indicates the accuracy required for the estimation. Convergence is assumed when the decrease in deviance is less than . This corresponds approximately to an absolute accuracy if the deviance is small and a relative accuracy if the deviance is large.
- maxitint
The maximum number of iterations required for computing the estimates. If is set to then the standard errors, the score functions and the variance-covariance matrix are computed for the input value of in but is not updated.
- iprintint, optional
Indicates if the printing of information on the iterations is required.
No printing.
The deviance and the current estimates are printed every iterations. When printing occurs the output is directed to the file object associated with the advisory I/O unit (see
FileObjManager
).- io_managerFileObjManager, optional
Manager for I/O in this routine.
- Returns
- devfloat
The deviance, that is, minus twice the maximized log-likelihood.
- bfloat, ndarray, shape
contains the estimate of the coefficient of the covariate stored in the th column of where is the th nonzero value in the array .
- sefloat, ndarray, shape
is the asymptotic standard error of the estimate contained in and score function in , for .
- scfloat, ndarray, shape
is the value of the score function for the estimate contained in .
- covfloat, ndarray, shape
The variance-covariance matrix of the parameter estimates in stored in packed form by column, i.e., the covariance between the parameter estimates given in and , , is given in .
- ncaint, ndarray, shape
contains the number of cases in the th stratum, for .
- nctint, ndarray, shape
contains the number of controls in the th stratum, for .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, there are not values of .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, too few observations included in model.
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, and .
Constraint: or .
- (errno )
Overflow in calculations.
- (errno )
The matrix of second partial derivatives is singular.
- Warns
- NagAlgorithmicWarning
- (errno )
Convergence not achieved in iterations.
- Notes
In the analysis of binary data, the logistic model is commonly used. This relates the probability of one of the outcomes, say , to explanatory variates or covariates by
where is a vector of unknown coefficients for the covariates and is a constant term. If the observations come from different strata or groups, would vary from strata to strata. If the observed outcomes are independent then the s follow a Bernoulli distribution, i.e., a binomial distribution with sample size one and the model can be fitted as a generalized linear model with binomial errors.
In some situations the number of observations for which may not be independent. For example, in epidemiological research, case-control studies are widely used in which one or more observed cases are matched with one or more controls. The matching is based on fixed characteristics such as age and sex, and is designed to eliminate the effect of such characteristics in order to more accurately determine the effect of other variables. Each case-control group can be considered as a stratum. In this type of study the binomial model is not appropriate, except if the strata are large, and a conditional logistic model is used. This considers the probability of the cases having the observed vectors of covariates given the set of vectors of covariates in the strata. In the situation of one case per stratum, the conditional likelihood for strata can be written as
where is the set of observations in the th stratum, with associated vectors of covariates , , and is the vector of covariates of the case in the th stratum. In the general case of cases per strata then the full conditional likelihood is
where is the sum of the vectors of covariates for the cases in the th stratum and , refer to the sum of vectors of covariates for all distinct sets of observations drawn from the th stratum. The conditional likelihood can be maximized by a Newton–Raphson procedure. The covariances of the parameter estimates can be estimated from the inverse of the matrix of second derivatives of the logarithm of the conditional likelihood, while the first derivatives provide the score function, , for , which can be used for testing the significance of parameters.
If the strata are not small, can be large so to improve the speed of computation, the algorithm in Howard (1972) and described by Krailo and Pike (1984) is used.
A second situation in which the above conditional likelihood arises is in fitting Cox’s proportional hazard model (see
surviv.coxmodel
) in which the strata refer to the risk sets for each failure time and where the failures are cases. When ties are present in the datasurviv.coxmodel
uses an approximation. For an exact estimate, the data can be expanded usingsurviv.coxmodel_risksets
to create the risk sets/strata andcondl_logistic
used.
- References
Cox, D R, 1972, Regression models in life tables (with discussion), J. Roy. Statist. Soc. Ser. B (34), 187–220
Cox, D R and Hinkley, D V, 1974, Theoretical Statistics, Chapman and Hall
Howard, S, 1972, Remark on the paper by Cox, D R (1972): Regression methods, J. R. Statist. Soc. (B 34), and life tables, 187–220
Krailo, M D and Pike, M C, 1984, Algorithm AS 196. Conditional multivariate logistic analysis of stratified case-control studies, Appl. Statist. (33), 95–103
Smith, P G, Pike, M C, Hill, P, Breslow, N E and Day, N E, 1981, Algorithm AS 162. Multivariate conditional logistic analysis of stratum-matched case-control studies, Appl. Statist. (30), 190–197