wwreith
2012-Apr-23 13:29 UTC
[R] How does survreg ordered factors vs not ordered factors?
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 -- View this message in context: http://r.789695.n4.nabble.com/How-does-survreg-ordered-factors-vs-not-ordered-factors-tp4580395p4580395.html Sent from the R help mailing list archive at Nabble.com.
Marc Schwartz
2012-Apr-23 14:32 UTC
[R] How does survreg ordered factors vs not ordered factors?
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, > > WilliamYou 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