I am wondering how to reconstruct the design matrix for a coxph()
model with a pspline()
term. For example, if I fit the following model,
fit <- coxph(Surv(t,delta) ~ pspline(x,df=0))
how can I calculate the linear predictor by hand for a given value of $x$?
Formally, I am modeling $h(t|x) = h_0(t)\cdot e^{(X^\intercal\beta)}$, and I want to know how to calculate $X$ or $X^\intercal\beta$ by hand. I can't find detailed documentation of how the design matrix is constructed when the pspline()
term is used.
As for why I care, I am running a large set of new predictions from a coxph()
object with a pspline()
term. I have stored the cumulative hazard $H_0(t)$ and want to be able to calculate $H_0(t)\cdot e^{(X^\intercal\beta)}$ efficiently. I'm finding that using
predict(fit, newdata=data.frame(x=x.new), type='lp')
is very inefficient! Any tips would be greatly appreciated.