[R] predicting expected number of events using a coxph model

agittens swiftset at gmail.com
Fri Jun 29 23:56:45 CEST 2012


I fit a coxph model:

coxphfit <- coxph(Surv(sampledLifetime, !sampledCensoredQ) ~  curpbc6  +
prevpbc6,  sampledTimeSeries)

Now I'm trying to predict the expected number of events using a new dataset.
The documentation suggests that

coxPred <- predict(coxphfit, newdata = testTimeSeries, type="expected")

will do what I want, but I get the error

Error in model.frame.default(data = testTimeSeries, formula =
Surv(sampledLifetime,  : 
  variable lengths differ (found for 'curpbc6')

when I do this. The dataframes sampledTimeSeries and testTimeSeries were
constructed by taking rows from a larger dataframe, so they have the same
data.

What am I doing incorrectly?

--
View this message in context: http://r.789695.n4.nabble.com/predicting-expected-number-of-events-using-a-coxph-model-tp4634935.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list