[R] [UNCLASSIFIED] predict.survreg() with frailty term and newdata

From: <joe.crombie_at_affa.gov.au>
Date: Mon 22 Jan 2007 - 00:03:40 GMT

Dear All,  

I am attempting to make predictions based on a survreg() model with some censoring and a frailty term, as below: predict works fine on the original data, but not if I specify newdata.  

# a model with groups as fixed effect

model1 <- survreg(Surv(y,cens)~ x1 + x2 + groups,

                 dist = "gaussian")

# and with groups as a random effect

fr <- frailty(groups, dist = "gaussian", sparse = F) model2 <- survreg(Surv(y,cens)~ x1 + x2 + fr,

                  dist = "gaussian")

# predict() works fine for groups as fixed effect
predict(model1, newdata = list(x1 = 1, x2 = 1, groups = groups[1]))
# [,1]
# 1 10.51833 # no problem!

# but not so well with frailty(groups)

predict(model2, newdata = list(x1 = 1, x2 = 1, fr = factor(1, levels = 1:10))) #> Error in x %*% coef : non-conformable arguments  

I have found references on the R and S-Plus lists which suggest that others have had this problem (in both packages), but I can't find any solution or further explanation. Can anyone suggest a way of getting the predictions I'm after? Any help is greatly appreciated.  

Kind regards Joe  

Joe Crombie  

Information and Risk Sciences
Bureau of Rural Science
Canberra Australia  

p: +61 2 6272 5906
e: joe.crombie@brs.gov.au <blocked::mailto:joe.crombie@brs.gov.au>

IMPORTANT - This message has been issued by The Department of Agriculture, Fisheries and Forestry (DAFF). The information transmitted is for the use of the intended recipient only and may contain confidential and/or legally privileged material. It is your responsibility to check any attachments for viruses and defects before opening or sending them on. Any reproduction, publication, communication, re-transmission, disclosure, dissemination or other use of the information contained in this e-mail by persons or entities other than the intended recipient is prohibited. The taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error please notify the sender and delete all copies of this transmission together with any attachments. If you have received this e-mail as part of a valid mailing list and no longer want to receive a message such as this one advise the sender by return e-mail accordingly. Only e-mail correspondence which includes this footer, has been authorised by DAFF

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon Jan 22 11:06:34 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 22 Jan 2007 - 01:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.