Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

r - Multi state models in R2BayesX

I am trying to fit a multi-state model using R package R2BayesX. How can I do so correctly? There is no example in the manual. Here is my attempt.

  • activity is 1/0 ie the states
  • time is time
  • patient id is the random effect I want
f <- activity ~ sx(time,bs="baseline")+sx(PatientId, bs="re")
b <- bayesx(f, family = "multistate", method = "MCMC", data=df)

Note: created new output directory

Warning message:

In run.bayesx(file.path(res$bayesx.prg$file.dir, prg.name = res$bayesx.prg$prg.name), :
an error occurred during runtime of BayesX, please check the BayesX logfile!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm not sure what kind of model exactly you want to specify but I tried to provide an artificial non-sensical data set to make the error above reproducible:

set.seed(1)
df <- data.frame(
  activity = rbinom(1000, prob = 0.5, size = 1),
  time = rep(1:50, 20),
  id = rep(1:20, each = 50)
)

Possibly, you could provide an improved example. And then I can run your code:

library("R2BayesX")
f <- activity ~ sx(time, bs = "baseline") + sx(id, bs = "re")
b <- bayesx(f, family = "multistate", method = "MCMC", data = df)

This leads to the warning above and you can inspect BayesX's logfile via:

bayesx_logfile(b)

which tells you (among other information):

ERROR: family multistate is not allowed for method regress

So here only REML estimation appears to be supported, but:

b <- bayesx(f, family = "multistate", method = "REML", data = df)

also results in an error, the logfile says:

ERROR: Variable state has to be specified as a global option!

So the state has to be provided in a different way. I guess that you tried to do so by the binary response but it seems that the response should be the time variable (as in survival models) and then an additional state indicator needs to be provided somehow. I couldn't find an example for this in the BayesX manuals, though. I recommend that you contact the BayesX mailing list and/or the R2BayesX package maintainer with a more specific question and a reproducible example.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...