Dear all,

I am using R 4.4.0 via RStudio (2024.04.0) on a Windows PC.  The code below 
worked on the previous version of the flexsurv but is not working since my 
recent update (version 2.3).

The code that was working is:

library(survival)

rfs  <- pmax(rotterdam$recur, rotterdam$death)
rfstime <- with(rotterdam, ifelse(recur==1, rtime, dtime))
fit1 <- flexsurvspline(Surv(rfstime, rfs) ~ age + meno + size + er,  k=2, data 
= rotterdam)

# obtain the linear predictor for each patient
predf <- model.matrix(fit1) %*% fit1$res[-(1:4),"est"]

# Predict baseline survival at 5 years
y5_Flex_1 <- summary(fit1,type="survival",t=5)
y5_Flex <- y5_Flex_1[[1]]$est
y5_Flex

# Shrinkage factor
vanH <- 0.9589255
heuristic_lp_flex = vanH*predf      

# Now calculate the shrunken model baseline survival prob at 5 years by fixing 
the shrunken lp as an offset and predicting the baseline survival
fit1_shrunk <- 
flexsurvspline(Surv(rfstime,rfs)~offset(heuristic_lp_flex),k=2,data=rotterdam)

The error message is
Error in model.matrix.default(forms[[i]], m) :
  model frame and formula mismatch in model.matrix()

Any suggestions gratefully received!!!

Kind regards,
Laura

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to