Cary Dehing-Oberije wrote: > Hi everybody, > > I am a new user of R, design package. > I am trying to plot the estimated hazard ratio's of my cox regression > model with the confidence intervals. But I keep getting the > message:Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : > contrasts can be applied only to factors with 2 or more levels > > I have dichotomous, categorical as well as continuous variables in the > model, but I can only plot the dichotomous variable. > > I started with the following syntax: > > dd <- datadist(x1, x2, x3)
Please follow the posting guide. Please provide R commands that generate values of x1, x2, x3 that cause the problem you reported below. > options(datadist='dd') > > fit<-cph(S~ x1 +x2 +x3, x=T,y=T) > > plothr<- summary(fit) > plot(plothr, log=T) or just plot(summary(fit), log=TRUE) > > Because the levels defined by datadist didn't seem to work I tried to > adjust the levels after fitting the model: > > dd$limits["Adjust to","x1"] <- 1 > dd$limits["Adjust to","x2"] <- 30 Don't do that. Frank > fit <- update(fit) > plothr<- summary(fit) > plot(plothr, log=T) > > Finally I have tried: summary(fit, x1=1, x2=30, x3=3) > > But this option didn't work either. Can anybody tell me what goes wrong > and why? > Thanks for your help, > > Cary > > Cary Dehing-Oberije > Researcher CAT project > p/a MAASTRO clinic > Dr. Tanslaan 12 > 6229 ET Maastricht > The Netherlands > phone: 088 - 4455666 / 088 - 4455767 > email: [EMAIL PROTECTED] > > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.