PDF version (NAG web site
, 64bit version, 64bit version)
NAG Toolbox: nag_contab_condl_logistic (g11ca)
Purpose
nag_contab_condl_logistic (g11ca) returns parameter estimates for the conditional logistic analysis of stratified data, for example, data from casecontrol studies and survival analyses.
Syntax
[
dev,
b,
se,
sc,
covar,
nca,
nct,
ifail] = g11ca(
ns,
z,
isz,
ic,
isi,
b,
tol,
maxit, 'n',
n, 'm',
m, 'ip',
ip, 'iprint',
iprint)
[
dev,
b,
se,
sc,
covar,
nca,
nct,
ifail] = nag_contab_condl_logistic(
ns,
z,
isz,
ic,
isi,
b,
tol,
maxit, 'n',
n, 'm',
m, 'ip',
ip, 'iprint',
iprint)
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
where
$\beta $ is a vector of unknown coefficients for the covariates
$z$ and
$\alpha $ is a constant term. If the observations come from different strata or groups,
$\alpha $ would vary from strata to strata. If the observed outcomes are independent then the
$y$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
$y=1$ may not be independent. For example, in epidemiological research, casecontrol 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 casecontrol 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
${n}_{\mathrm{s}}$ strata can be written as
where
${S}_{i}$ is the set of observations in the
$i$th stratum, with associated vectors of covariates
${z}_{l}$,
$l\in {S}_{i}$, and
${z}_{i}$ is the vector of covariates of the case in the
$i$th stratum. In the general case of
${c}_{i}$ cases per strata then the full conditional likelihood is
where
${s}_{i}$ is the sum of the vectors of covariates for the cases in the
$i$th stratum and
${s}_{l}$,
$l\in {C}_{i}$ refer to the sum of vectors of covariates for all distinct sets of
${c}_{i}$ observations drawn from the
$i$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,
${U}_{\mathit{j}}\left(\beta \right)$, for
$\mathit{j}=1,2,\dots ,p$, which can be used for testing the significance of arguments.
If the strata are not small,
${C}_{i}$ 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_coxmodel (g12ba)) 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_coxmodel (g12ba) uses an approximation. For an exact estimate, the data can be expanded using
nag_surviv_coxmodel_risksets (g12za) to create the risk sets/strata and
nag_contab_condl_logistic (g11ca) 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 casecontrol 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 stratummatched casecontrol studies Appl. Statist. 30 190–197
Parameters
Compulsory Input Parameters
 1:
$\mathrm{ns}$ – int64int32nag_int scalar

The number of strata, ${n}_{s}$.
Constraint:
${\mathbf{ns}}\ge 1$.
 2:
$\mathrm{z}\left(\mathit{ldz},{\mathbf{m}}\right)$ – double array

ldz, the first dimension of the array, must satisfy the constraint
$\mathit{ldz}\ge {\mathbf{n}}$.
The $i$th row must contain the covariates which are associated with the $i$th observation.
 3:
$\mathrm{isz}\left({\mathbf{m}}\right)$ – int64int32nag_int array

Indicates which subset of covariates are to be included in the model.
If ${\mathbf{isz}}\left(j\right)\ge 1$, the $j$th covariate is included in the model.
If ${\mathbf{isz}}\left(j\right)=0$, the $j$th covariate is excluded from the model and not referenced.
Constraint:
${\mathbf{isz}}\left(j\right)\ge 0$ and at least one value must be nonzero.
 4:
$\mathrm{ic}\left({\mathbf{n}}\right)$ – int64int32nag_int array

Indicates whether the
$i$th observation is a case or a control.
If ${\mathbf{ic}}\left(i\right)=0$, indicates that the $i$th observation is a case.
If ${\mathbf{ic}}\left(i\right)=1$, indicates that the $i$th observation is a control.
Constraint:
${\mathbf{ic}}\left(\mathit{i}\right)=0$ or $1$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
 5:
$\mathrm{isi}\left({\mathbf{n}}\right)$ – int64int32nag_int array

Stratum indicators which also allow data points to be excluded from the analysis.
If ${\mathbf{isi}}\left(i\right)=k$, indicates that the $i$th observation is from the $k$th stratum, where $k=1,2,\dots ,{\mathbf{ns}}$.
If ${\mathbf{isi}}\left(i\right)=0$, indicates that the $i$th observation is to be omitted from the analysis.
Constraint:
$0\le {\mathbf{isi}}\left(\mathit{i}\right)\le {\mathbf{ns}}$ and more than
ip values of
${\mathbf{isi}}\left(\mathit{i}\right)>0$, for
$\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
 6:
$\mathrm{b}\left({\mathbf{ip}}\right)$ – double array
Suggested value:
in many cases an initial value of zero for
${\mathbf{b}}\left(j\right)$ may be used. For another suggestion see
Further Comments.
Initial estimates of the covariate coefficient arguments
$\beta $.
${\mathbf{b}}\left(j\right)$ must contain the initial estimate of the coefficent of the covariate in
z corresponding to the
$j$th nonzero value of
isz.
 7:
$\mathrm{tol}$ – double scalar

Indicates the accuracy required for the estimation. Convergence is assumed when the decrease in deviance is less than ${\mathbf{tol}}\times \left(1.0+\mathrm{CurrentDeviance}\right)$. This corresponds approximately to an absolute accuracy if the deviance is small and a relative accuracy if the deviance is large.
Constraint:
${\mathbf{tol}}\ge 10\times \mathit{machineprecision}$.
 8:
$\mathrm{maxit}$ – int64int32nag_int scalar

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 variancecovariance matrix are computed for the input value of
$\beta $ in
b but
$\beta $ is not updated.
Constraint:
${\mathbf{maxit}}\ge 0$.
Optional Input Parameters
 1:
$\mathrm{n}$ – int64int32nag_int scalar

Default:
the dimension of the arrays
ic,
isi and the first dimension of the array
z. (An error is raised if these dimensions are not equal.)
$n$, the number of observations.
Constraint:
${\mathbf{n}}\ge 2$.
 2:
$\mathrm{m}$ – int64int32nag_int scalar

Default:
the dimension of the array
isz and the second dimension of the array
z. (An error is raised if these dimensions are not equal.)
The number of covariates in array
z.
Constraint:
${\mathbf{m}}\ge 1$.
 3:
$\mathrm{ip}$ – int64int32nag_int scalar

Default:
the dimension of the array
b.
$p$, the number of covariates included in the model as indicated by
isz.
Constraint:
${\mathbf{ip}}\ge 1$ and
${\mathbf{ip}}=\text{}$ number of nonzero values of
isz .
 4:
$\mathrm{iprint}$ – int64int32nag_int scalar
Default:
$0$
Indicates if the printing of information on the iterations is required.
 ${\mathbf{iprint}}\le 0$
 No printing.
 ${\mathbf{iprint}}\ge 1$
 The deviance and the current estimates are printed every iprint iterations. When printing occurs the output is directed to the current advisory message unit (see nag_file_set_unit_advisory (x04ab)).
Output Parameters
 1:
$\mathrm{dev}$ – double scalar

The deviance, that is, minus twice the maximized loglikelihood.
 2:
$\mathrm{b}\left({\mathbf{ip}}\right)$ – double array
Suggested value:
in many cases an initial value of zero for
${\mathbf{b}}\left(j\right)$ may be used. For another suggestion see
Further Comments.
${\mathbf{b}}\left(j\right)$ contains the estimate
${\hat{\beta}}_{i}$ of the coefficient of the covariate stored in the
$i$th column of
z where
$i$ is the
$j$th nonzero value in the array
isz.
 3:
$\mathrm{se}\left({\mathbf{ip}}\right)$ – double array

${\mathbf{se}}\left(\mathit{j}\right)$ is the asymptotic standard error of the estimate contained in ${\mathbf{b}}\left(\mathit{j}\right)$ and score function in ${\mathbf{sc}}\left(\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{ip}}$.
 4:
$\mathrm{sc}\left({\mathbf{ip}}\right)$ – double array

${\mathbf{sc}}\left(j\right)$ is the value of the score function ${U}_{j}\left(\beta \right)$ for the estimate contained in ${\mathbf{b}}\left(j\right)$.
 5:
$\mathrm{covar}\left({\mathbf{ip}}\times \left({\mathbf{ip}}+1\right)/2\right)$ – double array

The variancecovariance matrix of the parameter estimates in
b stored in packed form by column, i.e., the covariance between the parameter estimates given in
${\mathbf{b}}\left(i\right)$ and
${\mathbf{b}}\left(j\right)$,
$j\ge i$, is given in
${\mathbf{covar}}\left(j\left(j1\right)/2+i\right)$.
 6:
$\mathrm{nca}\left({\mathbf{ns}}\right)$ – int64int32nag_int array

${\mathbf{nca}}\left(\mathit{i}\right)$ contains the number of cases in the $\mathit{i}$th stratum, for $\mathit{i}=1,2,\dots ,{\mathbf{ns}}$.
 7:
$\mathrm{nct}\left({\mathbf{ns}}\right)$ – int64int32nag_int array

${\mathbf{nct}}\left(\mathit{i}\right)$ contains the number of controls in the $\mathit{i}$th stratum, for $\mathit{i}=1,2,\dots ,{\mathbf{ns}}$.
 8:
$\mathrm{ifail}$ – int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
 ${\mathbf{ifail}}=1$

On entry,  ${\mathbf{m}}<1$, 
or  ${\mathbf{n}}<2$, 
or  ${\mathbf{ns}}<1$, 
or  ${\mathbf{ip}}<1$, 
or  $\mathit{ldz}<{\mathbf{n}}$, 
or  ${\mathbf{tol}}<10\times \mathit{machineprecision}$, 
or  ${\mathbf{maxit}}<0$. 
 ${\mathbf{ifail}}=2$

On entry,  ${\mathbf{isz}}\left(i\right)<0$, for some $i$, 
or  the value of ip is incompatible with isz, 
or  ${\mathbf{ic}}\left(i\right)\ne 1$ or $0$. 
or  ${\mathbf{isi}}\left(i\right)<0$ or ${\mathbf{isi}}\left(i\right)>{\mathbf{ns}}$, 
or  the number of values of ${\mathbf{isz}}\left(i\right)>0$ is greater than or equal to ${n}_{0}$, the number of observations excluding any with ${\mathbf{isi}}\left(i\right)=0$. 
 ${\mathbf{ifail}}=3$

The value of lwk is too small.
 ${\mathbf{ifail}}=4$

Overflow has been detected. Try using different starting values.
 ${\mathbf{ifail}}=5$

The matrix of second partial derivatives is singular. Try different starting values or include fewer covariates.
 W ${\mathbf{ifail}}=6$

Convergence has not been achieved in
maxit iterations. The progress towards convergence can be examined by using a nonzero value of
iprint. Any nonconvergence may be due to a linear combination of covariates being monotonic with time.
Full results are returned.
 ${\mathbf{ifail}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
 ${\mathbf{ifail}}=399$
Your licence key may have expired or may not have been installed correctly.
 ${\mathbf{ifail}}=999$
Dynamic memory allocation failed.
Accuracy
The accuracy is specified by
tol.
Further Comments
The other models described in
Description can be fitted using the generalized linear modelling functions
nag_correg_glm_binomial (g02gb) and
nag_correg_glm_poisson (g02gc).
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_correg_glm_poisson (g02gc).
nag_contab_condl_logistic (g11ca) 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 $\mathrm{exp}\left({\beta}^{\mathrm{T}}{z}_{i}\right)$ or there may be nonconvergence. Reasonable estimates can often be obtained by fitting an unconditional model.
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.
Open in the MATLAB editor:
g11ca_example
function g11ca_example
fprintf('g11ca example results\n\n');
data = [1 0 0 1;
1 0 1 2;
1 1 0 1;
1 1 1 3;
2 0 0 1;
2 1 1 0;
2 1 0 2];
isi = int64(data(:,1));
ic = int64(data(:,2));
z = data(:,3:end);
m = size(z,2);
ns = int64(2);
isz = ones(m,1,'int64');
tol = 1e05;
maxit = int64(10);
b = zeros(m,1);
[dev, b, se, sc, covar, nca, nct, ifail] = ...
g11ca( ...
ns, z, isz, ic, isi, b, tol, maxit);
fprintf(' Deviance = %13.3e\n\n', dev);
fprintf(' Strata No. Cases No. Controls\n\n');
ivar = double([1:ns]');
fprintf('%5d%12d%12d\n', [ivar nca nct]');
fprintf('\n Parameter Estimate Standard Error\n\n');
ivar = double([1:m]');
fprintf('%6d%18.4f%18.4f\n', [ivar b se]');
g11ca example results
Deviance = 5.475e+00
Strata No. Cases No. Controls
1 2 2
2 1 2
Parameter Estimate Standard Error
1 0.5223 1.3901
2 0.2674 0.8473
PDF version (NAG web site
, 64bit version, 64bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015