Check linearity of continuous covariate
lincheck full GLM command
The continuous covariate to be checked for linearity must be first in the list of independent variables.
Description
lincheck provides a quick-and-dirty check of whether a continuous covariate in a general linearized model (GLM) is linear in the link function. lincheck makes a new categorical variable that breaks the continuous covariate into quartiles, then re-estimates the GLM using dummy variables for the quartiles, and finally provides a graph of estimated coefficients plotted against the midpoints (actually: medians) of the quartiles. A linear graph supports the assumption of linearity of the continuous covariate. lincheck works with most GLM commands such as regress, logit/logistic, probit, poisson, stcox etc. and their svy-versions.
Remarks
lincheck implements a method suggested by Hosmer & Lemeshow (Applied Logistic Regression, 2nd ed., 2000, Wiley, p.99f). Its reason of existence is the fact that linearity of a continuous covariate can be checked in the presence of other covariates in the model. If the graph is not linear, the continuous covariate might have to enter the model linearized. fracpoly can be used to suggest appropriate transformations. Indeed, Hosmer & Lemeshow recommend to use fracpoly in any case, since its results might not always agree with those of lincheck, and the question of linearity should be assessed in the light of the results of both methods.
Examples
. lincheck logit smoker age sex weight if syst_bp>120, nolog or . lincheck xi:logit smoker age sex i.race, nolog . lincheck stcox weight sex . lincheck svyprobit smoker weight age sex
The first two examples test linearity for 'age', the others test linearity for 'weight'.
Author
Alex Gamma, University Hospital of Psychiatry, Research Department, Zurich, Switzerland. Email: gamma@bli.unizh.ch
Also see
Online: help for lintrend, fracpoly, lowess