giabaio / survHE

Survival analysis in health economic evaluation Contains a suite of functions to systematise the workflow involving survival analysis in health economic evaluation. survHE can fit a large range of survival models using both a frequentist approach (by calling the R package flexsurv) and a Bayesian perspective.
https://gianluca.statistica.it/software/survhe/
41 stars 19 forks source link

covariate interaction terms #20

Closed Geoff-Holmes closed 6 years ago

Geoff-Holmes commented 6 years ago

Hi Gianluca

I'm wondering if it is possible to include interaction terms as is possible in the underlying flexsurv. e.g.

library(survHE) data(bc) bc$dummy<-round(runif(nrow(bc)))

This works fine

mod1<-flexsurvspline(Surv(rectime, censrec) ~ group + dummy + group * dummy, data=bc)

This works fine

mod2<-fit.models(Surv(rectime, censrec) ~ group + dummy, data=bc, distr="rps")

This thows an error

mod2<-fit.models(Surv(rectime, censrec) ~ group + dummy + group * dummy, data=bc, distr="rps") Error in [.data.frame(data, , pmatch(covs, colnames(data))) : undefined columns selected

Geoff-Holmes commented 6 years ago

Sorry the comments turned into large text! I've realised I can (obviously!) just create a new column in the data for the interaction term.

giabaio commented 6 years ago

Hi Geoff, No problems! And yes --- that is the way to deal with interactions. I think flexsurvreg may construct the "model matrix" (ie the matrix of covariates) automatically using the syntax a:b to mean interaction between a and b. survHE needs you to specify the new column a*b at the moment. I can see how quickly I can include the a:b notation --- shouldn't be too long (but possibly not super high priority?).