if (FALSE) {
require(rms)
require(ggplot2)
require(survival)
dist <- datadist(data=2) # can omit if not using summary, (gg)plot, survplot,
# or if specify all variable values to them. Can
# also defer. data=2: get distribution summaries
# for all variables in search position 2
# run datadist once, for all candidate variables
dist <- datadist(age,race,bp,sex,height) # alternative
options(datadist="dist")
f <- cph(Surv(d.time, death) ~ rcs(age,4)*strat(race) +
bp*strat(sex)+lsp(height,60),x=TRUE,y=TRUE)
anova(f)
anova(f,age,height) # Joint test of 2 vars
fastbw(f)
summary(f, sex="female") # Adjust sex to "female" when testing
# interacting factor bp
bplot(Predict(f, age, height)) # 3-D plot
ggplot(Predict(f, age=10:70, height=60))
latex(f) # LaTeX representation of fit
f <- lm(y ~ x) # Can use with any fitting function that
# calls model.frame.default, e.g. lm, glm
specs.rms(f) # Use .rms since class(f)="lm"
anova(f) # Works since Varcov(f) (=Varcov.lm(f)) works
fastbw(f)
options(datadist=NULL)
f <- ols(y ~ x1*x2) # Saves enough information to do fastbw, anova
anova(f) # Will not do Predict since distributions
fastbw(f) # of predictors not saved
plot(f, x1=seq(100,300,by=.5), x2=.5)
# all values defined - don't need datadist
dist <- datadist(x1,x2) # Equivalent to datadist(f)
options(datadist="dist")
plot(f, x1, x2=.5) # Now you can do plot, summary
plot(nomogram(f, interact=list(x2=c(.2,.7))))
}
Run the code above in your browser using DataLab