survival
survival copied to clipboard
predict.coxph.penal ignores newdata when the model has only a sparse term
This is closely related to #70 and also probably has minimal impact.
In predict.coxph.penal, when there is only a sparse ~/penalty~ term in the model, the newdata argument (if supplied) gets ignored in calculating the predictions (except for the assignment line 45, which gets overwritten).
https://github.com/therneau/survival/blob/a676f5ec6959bc54e32c2dac94c9c336e1f08370/R/predict.coxph.penal.S#L41-L54
Currently, if newdata has been supplied, an error stops execution at line 47 unless "indx" has been defined outside the function (issue #70), but when that is fixed, the resulting predictions ignore newdata.
What do you want the prediction to be from a frailty model with new data? I'm not trying to be difficult -- I have struggled with this question myself. Say the model has frailty(inst) to have a random effect per institution. If the new data contains a new institution -- give NA or the mean of the random effects distribution? Can I count on random effects having a consistent label?
I was thinking that the behavior would be the same as when there are fixed covariates in addition to the frailty term — that the predictions would be for a random effect of zero. In the case of a model with only a frailty term, the only part of newdata that would matter for predictions (and only if type="expected") would be the follow-up time. Rows of newdata that differed only in the value of the frailty term would get the same prediction.