Skip to contents

blrm_markov() fits a model using rmsb::blrm() and stores the data needed by subsequent SOP and inference functions. It uses x = TRUE and y = TRUE by default, rejects offsets, and stores separate likelihood, refit, and designated-start profile data plus the optional patient ID on the returned model. Bayesian fits do not receive cluster-robust covariance; posterior uncertainty comes from the fitted blrm draws.

Usage

blrm_markov(
  formula,
  ppo = NULL,
  cppo = NULL,
  data,
  ...,
  id_var = NULL,
  time_var = "time",
  first_followup_time = NULL,
  x = TRUE,
  y = TRUE
)

Arguments

formula

a R formula object that can use rms package enhancements such as the restricted interaction operator

ppo

formula specifying the model predictors for which proportional odds is not assumed

cppo

a function that if present causes a constrained partial PO model to be fit. The function specifies the values in the Gamma vector in Peterson and Harrell (1990) equation (6). Sometimes to make posterior sampling better behaved, the function should be scaled and centered. This is done by wrapping cppo in a function that scales the cppo result before returning the vector value, when normcppo is TRUE. The default normalization is based on the mean and standard deviation of the function values over the distribution of observed Y. For getting predicted values and estimates post-blrm(), cppo must not reference any functions that are not available at such later times.

data

a data frame; defaults to using objects from the calling environment

...

passed to rstan::optimizing() or the rcmdstan optimizing function. sampling.args is usually used instead.

id_var

Optional character scalar naming the patient or cluster ID column in data. When supplied, SOP calls can reuse the stored full data and infer the ID column for baseline extraction and random-effect prediction.

time_var

Character scalar naming the modeled time column used to identify the designated starting-profile row.

first_followup_time

First scheduled post-baseline outcome time used to select the starting-profile row. See orm_markov() for the numeric and categorical time contracts.

x

set to FALSE to not store the design matrix in the fit. x=TRUE is needed if running blrmStats for example.

y

set to FALSE to not store the response variable in the fit

Value

A fitted blrm object retaining the data needed by subsequent SOP and inference functions.

Details

The designated-start profile and fitted-patient eligibility contract is the same as for orm_markov(). In particular, the transition response at the starting row may be missing when that patient contributes another usable likelihood transition.

A subset supplied through ... is evaluated once when the model is fitted, looking first in data and then where blrm_markov() was called.

Examples

if (FALSE) { # \dontrun{
dd <- rms::datadist(data)
options(datadist = "dd")

fit <- blrm_markov(
  y ~ yprev + rms::rcs(time, 4) * tx,
  ppo = ~ time,
  cppo = function(y) y,
  data = data,
  id_var = "id"
)

avg_sops(fit, variables = list(tx = c(0, 1)), times = 1:60)
} # }