Constructor for a prior distribution in msmbayes
Arguments
- par
Character string indicating the model parameter to place the prior on
This should start with one of the following:
"logq"
. Log transition intensity."q"
, Transition intensity"time"
. Defined as1/q
. This can be interpreted as the mean time to the next transition to state $s$ for people in state $r$ (from the point of view of someone observing one person at a time, and switching to observing a different person if a competing transition happens)."loghr"
. Log hazard ratio"hr"
. Hazard ratioThen for transition intensities, it should two include indices indicating the transition, e.g.
"logq(2,3)"
for the log transition intensity from state 2 to state 3.For covariate effects, the covariate name is supplied alongside the transition indices, e.g.
"loghr(age,2,3)"
for the effect ofage
on the log hazard ratio of transitioning from state 2 to state 3.For factor covariates, this should include the level, e.g.
"loghr(sexMALE,2,3)"
for level"MALE"
of factor"sex"
.The indices or the covariate name can be omitted to indicate that the same prior will used for all transitions, or/and all covariates. This can be done with or without the brackets, e.g.
"logq()"
or"logq"
are both understood.- mean
Prior mean (only used for logq or loghr)
- sd
Prior standard deviation (only used for logq or loghr)
- median
Prior median
- lower
Prior lower 95% quantile
- upper
Prior upper 95% quantile
Value
A list of class "msmprior"
, with components
par
(as supplied by the user)
par_base
(either "logq"
or "loghr"
)
covname
(name of covariate effect)
ind1
, ind2
(as supplied by the user)
mean
(of log-normal prior on par_base
)
sd
(of log-normal prior on par_base
)
Details
In msmbayes
, a normal prior is used for the log
transition intensities (logq
) and log hazard ratios (loghr
).
The goal of this function is to determine the mean and SD of this
prior. It can be used in two ways:
(a) directly specifying the prior mean and SD of logq or
loghr`
(b) specifying prior quantiles for more interpretable
transformations of these. These may include q
(the transition
intensity) or time
(the reciprocal of the intensity,
interpreted as a mean time to this transition when observing a
sequence of individuals at risk of it). Or hr
(hazard ratio2)
Two quantiles out of the median, lower or upper should be provided.
If three are provided, then the upper quantile is ignored. These
are transformed back to the scale of logq
or loghr
, and the
unique normal prior with these quantiles is deduced.
Examples
priors <- list(
msmprior("logq(1,2)", median=-2, lower=-4),
msmprior("q(2,1)", median=0.1, upper=10)
)
Q <- rbind(c(0,1),c(1,0))
mod <- msmbayes(data=infsim2, state="state", time="months", subject="subject",
Q=Q, priors=priors, fit_method="optimize")
#> Initial log joint probability = -185.951
#> Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
#> 12 -18.3986 0.00174506 0.00118475 0.9593 0.9593 13
#> Optimization terminated normally:
#> Convergence detected: relative gradient magnitude is below tolerance
#> Finished in 0.3 seconds.
summary(mod)
#> # A tibble: 4 × 6
#> name from to value prior rhat
#> <chr> <int> <int> <rvar[1d]> <chr> <dbl>
#> 1 q 1 2 0.58 ± NA "0.14 (0.018, 0.99)" NA
#> 2 q 2 1 3.41 ± NA "0.10 (0.001, 9.88)" NA
#> 3 mst 1 NA 1.73 ± NA " 7.4 (1.0, 54)" NA
#> 4 mst 2 NA 0.29 ± NA "10.0 (0.1, 988)" NA