nag_condl_logistic (g11cac) (PDF version)
g11 Chapter Contents
g11 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_condl_logistic (g11cac)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_condl_logistic (g11cac) returns parameter estimates for the conditional logistic analysis of stratified data, for example, data from case-control studies and survival analyses.

2  Specification

#include <nag.h>
#include <nagg11.h>
void  nag_condl_logistic (Nag_OrderType order, Integer n, Integer m, Integer ns, const double z[], Integer pdz, const Integer isz[], Integer p, const Integer ic[], const Integer isi[], double *dev, double b[], double se[], double sc[], double cov[], Integer nca[], Integer nct[], double tol, Integer maxit, Integer iprint, const char *outfile, NagError *fail)

3  Description

In the analysis of binary data, the logistic model is commonly used. This relates the probability of one of the outcomes, say y=1, to p explanatory variates or covariates by
Proby=1=expα+zTβ 1+expα+zTβ ,
where β is a vector of unknown coefficients for the covariates z 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 ys 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 y=1 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 ns strata can be written as
L=i=1nsexpziTβ lSiexpzlTβ , (1)
where Si is the set of observations in the ith stratum, with associated vectors of covariates zl, lSi, and zi is the vector of covariates of the case in the ith stratum. In the general case of ci cases per strata then the full conditional likelihood is
L=i=1nsexpsiTβ lCiexpslTβ , (2)
where si is the sum of the vectors of covariates for the cases in the ith stratum and sl, lCi refer to the sum of vectors of covariates for all distinct sets of ci observations drawn from the ith 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, Ujβ, for j=1,2,,p, which can be used for testing the significance of arguments.
If the strata are not small, Ci 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 nag_surviv_cox_model (g12bac)) 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 data nag_surviv_cox_model (g12bac) uses an approximation. For an exact estimate, the data can be expanded using nag_surviv_risk_sets (g12zac) to create the risk sets/strata and nag_condl_logistic (g11cac) used.

4  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

5  Arguments

1:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by order=Nag_RowMajor. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     nIntegerInput
On entry: n, the number of observations.
Constraint: n2.
3:     mIntegerInput
On entry: the number of covariates in array z.
Constraint: m1.
4:     nsIntegerInput
On entry: the number of strata, ns.
Constraint: ns1.
5:     z[dim]const doubleInput
Note: the dimension, dim, of the array z must be at least
  • max1,pdz×m when order=Nag_ColMajor;
  • max1,n×pdz when order=Nag_RowMajor.
The i,jth element of the matrix Z is stored in
  • z[j-1×pdz+i-1] when order=Nag_ColMajor;
  • z[i-1×pdz+j-1] when order=Nag_RowMajor.
On entry: the ith row must contain the covariates which are associated with the ith observation.
6:     pdzIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array z.
Constraints:
  • if order=Nag_ColMajor, pdzn;
  • if order=Nag_RowMajor, pdzm.
7:     isz[m]const IntegerInput
On entry: indicates which subset of covariates are to be included in the model.
If isz[j-1]1, the jth covariate is included in the model.
If isz[j-1]=0, the jth covariate is excluded from the model and not referenced.
Constraint: isz[j-1]0 and at least one value must be nonzero.
8:     pIntegerInput
On entry: p, the number of covariates included in the model as indicated by isz.
Constraint: p1 and p= number of nonzero values of isz .
9:     ic[n]const IntegerInput
On entry: indicates whether the ith observation is a case or a control.
If ic[i-1]=0, indicates that the ith observation is a case.
If ic[i-1]=1, indicates that the ith observation is a control.
Constraint: ic[i-1]=0 or 1, for i=1,2,,n.
10:   isi[n]const IntegerInput
On entry: stratum indicators which also allow data points to be excluded from the analysis.
If isi[i-1]=k, indicates that the ith observation is from the kth stratum, where k=1,2,,ns.
If isi[i-1]=0, indicates that the ith observation is to be omitted from the analysis.
Constraint: 0isi[i-1]ns and more than p values of isi[i-1]>0, for i=1,2,,n.
11:   devdouble *Output
On exit: the deviance, that is, -2×, (maximized log marginal likelihood).
12:   b[p]doubleInput/Output
On entry: initial estimates of the covariate coefficient arguments β. b[j-1] must contain the initial estimate of the coefficent of the covariate in z corresponding to the jth nonzero value of isz.
Suggested value: in many cases an initial value of zero for b[j-1] may be used. For another suggestion see Section 9.
On exit: b[j-1] contains the estimate β^i of the coefficient of the covariate stored in the ith column of z where i is the jth nonzero value in the array isz.
13:   se[p]doubleOutput
On exit: se[j-1] is the asymptotic standard error of the estimate contained in b[j-1] and score function in sc[j-1], for j=1,2,,p.
14:   sc[p]doubleOutput
On exit: sc[j] is the value of the score function Ujβ for the estimate contained in b[j-1].
15:   cov[p×p+1/2]doubleOutput
On exit: the variance-covariance matrix of the parameter estimates in b stored in packed form by column, i.e., the covariance between the parameter estimates given in b[i-1] and b[j-1], ji, is given in cov[jj-1/2+i].
16:   nca[ns]IntegerOutput
On exit: nca[i-1] contains the number of cases in the ith stratum, for i=1,2,,ns.
17:   nct[ns]IntegerOutput
On exit: nct[i-1] contains the number of controls in the ith stratum, for i=1,2,,ns.
18:   toldoubleInput
On entry: indicates the accuracy required for the estimation. Convergence is assumed when the decrease in deviance is less than tol×1.0+CurrentDeviance. This corresponds approximately to an absolute accuracy if the deviance is small and a relative accuracy if the deviance is large.
Constraint: tol10×machine precision.
19:   maxitIntegerInput
On entry: the maximum number of iterations required for computing the estimates. If maxit is set to 0 then the standard errors, the score functions and the variance-covariance matrix are computed for the input value of β in b but β is not updated.
Constraint: maxit0.
20:   iprintIntegerInput
On entry: indicates if the printing of information on the iterations is required.
iprint0
No printing.
iprint1
The deviance and the current estimates are printed every iprint iterations.
Suggested value: iprint=0.
21:   outfileconst char *Input
On entry: the name of a file to which diagnostic output will be directed. If outfile is NULL the diagnostic output will be directed to standard output.
22:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_CONVERGENCE
Convergence not achieved in value iterations.
NE_INT
On entry, element value of isz<0.
On entry, ic[value]=value.
Constraint: ic[i]=0 or 1, for all i.
On entry, m=value.
Constraint: m1.
On entry, maxit=value.
Constraint: maxit0.
On entry, n=value.
Constraint: n2.
On entry, ns=value.
Constraint: ns1.
On entry, p=value.
Constraint: p1.
On entry, pdz<n: pdz=value.
On entry, pdz=value.
Constraint: pdz>0.
NE_INT_2
On entry, isi[value]=value and ns=value.
Constraint: 0isi[i-1]ns.
On entry, pdz=value and m=value.
Constraint: pdzm.
NE_INT_ARRAY_ELEM_CONS
On entry, there are not p values of isz>0.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_NOT_CLOSE_FILE
Cannot close file value.
NE_NOT_WRITE_FILE
Cannot open file value for writing.
NE_OBSERVATIONS
On entry, too few observations included in model.
NE_OVERFLOW
Overflow in calculations.
NE_REAL
On entry, tol=value.
Constraint: tol10×machine precision.
NE_SINGULAR
The matrix of second partial derivatives is singular; computation abandoned.

7  Accuracy

The accuracy is specified by tol.

8  Parallelism and Performance

nag_condl_logistic (g11cac) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_condl_logistic (g11cac) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

The other models described in Section 3 can be fitted using the generalized linear modelling functions nag_glm_binomial (g02gbc) and nag_glm_poisson (g02gcc).
The case with one case per stratum can be analysed by having a dummy response variable y such that y=1 for a case and y=0 for a control, and fitting a Poisson generalized linear model with a log link and including a factor with a level for each strata. These models can be fitted by using nag_glm_poisson (g02gcc).
nag_condl_logistic (g11cac) uses mean centering, which involves subtracting the means from the covariables prior to computation of any statistics. This helps to minimize the effect of outlying observations and accelerates convergence. In order to reduce the risk of the sums computed by Howard's algorithm becoming too large, the scaling factor described in Krailo and Pike (1984) is used.
If the initial estimates are poor then there may be a problem with overflow in calculating expβTzi or there may be non-convergence. Reasonable estimates can often be obtained by fitting an unconditional model.

10  Example

The data was used for illustrative purposes by Smith et al. (1981) and consists of two strata and two covariates. The data is input, the model is fitted and the results are printed.

10.1  Program Text

Program Text (g11cace.c)

10.2  Program Data

Program Data (g11cace.d)

10.3  Program Results

Program Results (g11cace.r)


nag_condl_logistic (g11cac) (PDF version)
g11 Chapter Contents
g11 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2014