Skip to content

Forcing a variableinto a model using stepAIC

2 messages · Laura Bonnett, Chuck Cleland

#
Dear All,

I am attempting to use forward and/or backward selection to determine
the best model for the variables I have.  Unfortunately, because I am
dealing with patients and every patient is receiving treatment I need
to force the variable for treatment into the model.  Is there a way to
do this using R?  (Additionally, the model is stratified by
randomisation period).  I know that SAS can be used to do this but my
SAS coding is poor and consequently it would be easier for me to use
R, especially given the fractional polynomial transformations!

Currently the model is as follows (without treatment).

coxfita=coxph(Surv(rem.Remtime,rem.Rcens)~sind(nearma)+fsh(nearma)+fdr(nearma)+th1(nearma)+th2(nearma)+fp(cage)+fp(fint)+fp(tsb)+strata(rpa),data=nearma)


Thank you for your help,

Laura
#
On 5/22/2009 9:58 AM, Laura Bonnett wrote:
See the scope argument to stepAIC in the MASS package.  You can
specify a formula in the 'lower' component of scope which includes the
treatment variable.  That will force the treatment variable to remain in
every model examined in the stepwise search.