[R] predict with eha package

Mike Harwood harwood262 at gmail.com
Thu Jun 2 15:53:11 CEST 2011


Hello list, and thank you in advance.

I'm unable to generate predicted values when specifying newdata using
phreg and aftreg models
in the eha package, but I do not have the same problem with a
proportional hazards model from coxph.  Without the newdata argument
the predicted values are returned, but with
"newdata=<model.dataframe>" coxph is fine but both aftreg and phreg
models return an  "Error in predict.coxph(f.ph.eha,
newdata = mort, type = "lp") :  Data is not the same size as it was in
the original fit" message.  Since I ultimately want a parametric model
and the "real"
data is left truncated and right censored, I think the aftreg function
in the eha package is what I must use.  Following is my sample code,
without the output.

#~ All models generated successfully ---------------------------------
f.ph <- coxph(Surv(enter, exit, event) ~ ses, data = mort)
f.ph.eha <- phreg(Surv(enter, exit, event) ~ ses, data = mort)
f.aft <- aftreg(Surv(enter, exit, event) ~ ses, data = mort)

#~ All fits generated successfully -----------------------------------
f.ph.fit <- predict(f.ph, type='lp')
f.ph.eha.fit <- predict(f.ph.eha, type='lp')
f.aft.fit <- predict(f.aft, type='lp')

#~ First fit generated successfully, others output
error--------------------
f.ph.fit <- predict(f.ph, newdata=mort, type='lp')
f.ph.eha.fit <- predict(f.ph.eha, newdata=mort, type='lp')
f.aft.fit <- predict(f.aft, newdata=mort, type='lp')


Mike



More information about the R-help mailing list