Dear R-help,
I am using R-3.3.2 on Windows 10. As per my previous post today, I teach on a
course which has 4 computer practical sessions related to the development and
validation of clinical prediction models. These are currently written for Stata
and I am in the process of writing them for use in R too (as I far prefer R to
Stata!)
Part of the practical requires the student to fit a flexible parametric model
(using stmp2 in Stata). They then need to establish the AIC and BIC for models
with different numbers of knots. Finally, they need to obtain the linear
predictor for their chosen model.
The AIC can easily be established using the following code:
data(brcancer)
fit_3k <- stpm2(Surv(rectime,censrec==1)~hormon,data=brcancer,df=3)
fit_4k <- stpm2(Surv(rectime,censrec==1)~hormon,data=brcancer,df=4)
fit_5k <- stpm2(Surv(rectime,censrec==1)~hormon,data=brcancer,df=5)
AIC(fit_3k)
AIC(fit_4k)
AIC(fit_5k)
(although these equivalent values for my real dataset are different to those
obtained using equivalent code in Stata).
However, the BIC equivalent code leads to "NA" responses. I know that
BIC is extractable within the equivalent code in Stata, so is anyone aware of
how to extract the BIC in R?
Also, it is easy to obtain predictions from the model using code such as:
predict(fit_3k,type="hazard")
However, is there a way to extract the linear predictors for each individual?
Many thanks for your help.
Kind regards,
Laura
[[alternative HTML version deleted]]