[R] How does survreg ordered factors vs not ordered factors?

Marc Schwartz marc_schwartz at me.com
Mon Apr 23 16:32:27 CEST 2012


On Apr 23, 2012, at 8:29 AM, wwreith wrote:

> Consider the following generic code for a survival model
> 
> survobj<-Surv(data$Time,data$Satisfactory)
> survmodel<-survreg(survobj~x1+x2+x3+x4+x5+x6, data=data, dist="weibull")
> survsum<-summary(survmodel)
> survsum
> 
> My question: Does anyone know what exactly survreg() does differently if
> 
> x1<-factor(data$x1, ordered=TRUE)
> x2<-factor(data$x2, ordered=TRUE)
> 
> vs. 
> 
> x1<-factor(data$x1)
> x2<-factor(data$x2)
> 
> Thanks,
> 
> William


You might want to Google search for "Orthogonal Polynomial Contrasts", which is what you get by default in R for ordered factors and that will apply not just for survreg, but for all typical modeling functions in R (lm, glm, etc.). There is a page here that might be helpful:

  http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm

and it is also covered, albeit briefly, in An Introduction to R:

  http://cran.r-project.org/doc/manuals/R-intro.html#Contrasts

as well as ?contr.poly. Briefly, it allows for an analysis/exploration of linear and higher order polynomial trends in the factor in relation to the response variable, which would be more typical for an ordinal, as compared to a nominal, independent variable.

For unordered factors, the default in R is to use what are called treatment contrasts, which compares each level of the factor with the base or reference level. Depending upon the nature of the analysis you are conducting and your underlying hypotheses, treatment contrasts are very commonly used for ordinal variables as well.

Regards,

Marc Schwartz



More information about the R-help mailing list