Jon Kroll Bjerregaard
2011-Feb-25 16:54 UTC
[R] Forced inclusion of varaibles in validate command as well as step
Hello all
I am a very new R user
I am used to using STATA
My problem:
I want to build a Cox model and validate this.
I have a large number of clinical relevant factors and feel the need to
reduce these. Meanwhile I have some clinical variables I deem sufficiently
important to force into the model regardless of AIC or p value.
This is my present log over commands
************
library(rms)
library(survival)
library(Hmisc)
data1 <- read.table("optimism.csv", header=T, sep=",")
attach(data1)
coxmodel4 <- coxph(formula=Surv(OS,mors) ~
iAJCC2+iAJCC3+iPS2+iPS3++alder_diag+gender+vol_GTV+iforb2+iforb3+hem_LNL+ser
o_thromb+LDH_UNL+ALAT_UNL+BASP_UNL+sero_bili+resection_perf+sero_WBC,
data=data1, x=TRUE, y=TRUE,method=c("efron"))
coxmodel.streg<-step(coxmodel4)
I would like to "lock" iAJCC2 iAJCC3 and iPS2 + iPS3 regardless, but I
cannot seem to get the step function to accept this.
Further
Once I have the model I would like to validate it with the validate command
I am presently using this****************
fit <- cph(formula=Surv(OS,mors) ~
iAJCC2+iAJCC3+iPS2+iPS3+alder_diag+gender+vol_GTV+iforb2+iforb3+hem_LNL+sero
_thromb+LDH_UNL+ALAT_UNL+BASP_UNL+sero_bili+resection_perf+sero_WBC,
data=data1, x=TRUE, y=TRUE)
fit
validate(fit, method="boot", B=40,bw=TRUE, rule="p",
type="residual",
sls=0.15, aics=0, pr=TRUE)
Due to my small data set 153 patients with 130 events I have chosen to lift
the p limit from 5% to 15% as suggested by Steyerberg.
************************************************************************
I would appreciate any help with the lock term (also if it cannot be done)
As I mentioned I am a bit of a rookie, and not too experienced as a
programmer (I am a MD after all)
However I am quite impressed with R so far since I have been trying to get
this far in STATA for a few weeks.
Sincerely
Jon Kroll Bjerregaard, MD. Dep of Oncology Odense University Hospital
[[alternative HTML version deleted]]
Frank Harrell
2011-Feb-26 14:53 UTC
[R] Forced inclusion of varaibles in validate command as well as step
Jon, Version 3.3-0 of rms will be released within 2-3 days. It has a new option "force" for fastbw, validate, calibrate. force is an integer vector of the parameter numbers to force into every model. It is meant to work with type='individual' and its performance with type='residual' needs to be studied (I doubt if it works as you want). Suppose you have a Cox model (which does not have an intercept to include in the sequential numbering for force) like this: f <- cph(S ~ sex + pol(age,2) + rcs(height,4)) and you want to force age into every model. You would specify force=2:3. Typing coef(f) will show you the sequential parameters in the model. Someday I'll extend this to force='age' but that's not in the current version. Note that fastbw always pools age and age^2 effects when judging significance. As always use stepwise methods at your own risk. They are dangerous to your health. If you are using Linux I can send the new version by e-mail. Frank ----- Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Forced-inclusion-of-varaibles-in-validate-command-as-well-as-step-tp3324901p3325922.html Sent from the R help mailing list archive at Nabble.com.