chjackson / flexsurv

The flexsurv R package for flexible parametric survival and multi-state modelling
http://chjackson.github.io/flexsurv/
54 stars 28 forks source link

X and beta arguments don't work properly in rsurvspline, qsurvspline #63

Closed chjackson closed 9 months ago

chjackson commented 5 years ago

X and beta arguments are not supported properly in rsurvspline and qsurvspline. They fail silently by returning a vector of the wrong dimension.

rsurvspline(n = 10, gamma = c(-2,1,0),
            beta = c(0,1), 
            X = matrix(rep(c(0,0), 10), ncol=2, byrow=TRUE),
            knots = c(-1,0,1))

I intend to fix by withdrawing support for these arguments. They are currently deprecated, as dpqr functions in R don't typically have arguments like this.

chjackson commented 5 years ago

The recommended alternative to using X and beta is to adjust the intercept gamma0 to include the effects of the covariates before calling the dpqr function:

gamma <- matrix(rep(c(-2,1,0), 10), nrow=10, byrow=TRUE)
beta <- c(0,1)
X  <- matrix(rep(c(0,0), 10), ncol=2, byrow=TRUE)
gamma[,1] <- gamma[,1]  +  X %*% beta
rsurvspline(n = 10, gamma = gamma, knots = c(-1,0,1))
chjackson commented 9 months ago

Resolved in https://github.com/chjackson/flexsurv/commit/9291e60884808a7389bf4bff139fb9d73971a1c5