[R] use "factor" for categorical covariate in Cox PH model

Dieter Menne dieter.menne at menne-biomed.de
Tue Jul 18 09:09:36 CEST 2006

Linda Lei <llei <at> bccrc.ca> writes:

> When dealing with the categorical covariates (for example 3 groups), it
> will come out different results if we add the command "factor" in front
> of the categorical covariate or not 

The catch is here: the covariate is not a "categorial", but a number. In that
case a regression is computed, and the ONE ration printed out has the meaning of
a slope.

> if we don't add "factor", there is
> only one hazard ratio; if we add "factor", there are two hazard ratios.
> So does the "factor" actually create some dummy variables for the
> calculation?

Factor make the covariate a categorial one, and two contrasts are printed out,
relative to the first level of the covariate.


More information about the R-help mailing list