plot_lp_difference() evaluates a fitted ordinal Markov model at one patient
profile and plots differences in the model linear predictor between
counterfactual levels of one variable over time. The plot is conditional on
the supplied profile and faceted by previous state.
Usage
plot_lp_difference(
x,
profile,
variables,
times,
previous_states = NULL,
y_levels = NULL,
absorb = NULL,
time_var = "time",
p_var = "yprev",
gap_var = NULL,
time_covariates = NULL,
line_width = 0.7
)Arguments
- x
A fitted
orm,blrm,vglm, orrobcov_vglmMarkov model.- profile
One-row data frame containing the covariate profile.
- variables
Named list with one variable and at least two values. The first value is the reference.
- times
Time values at which to evaluate the linear predictor.
- previous_states
Optional previous-state values to facet by. Defaults to all non-absorbing states in
y_levels.- y_levels
Optional state levels. If omitted, levels are inferred from the model when possible.
- absorb
Optional absorbing-state label excluded from the default previous-state grid.
- time_var
Character name of the time column.
- p_var
Character name of the previous-state column.
- gap_var
Optional time-gap_var variable used by the fitted model.
- time_covariates
Optional time-varying covariate lookup table used by the fitted model.
- line_width
Line width for the plotted contrasts.
Details
plot_lp_difference() is model-based only. At minimum, supply model, a
one-row profile, variables, and times. The profile should contain the
model covariates for the patient or scenario being plotted; times and
previous_states define the plotting grid.
Examples
if (FALSE) { # \dontrun{
plot_lp_difference(
fit,
profile = data.frame(tx = 0, age = 59, sex = "Male", yprev = 3),
variables = list(tx = c(0, 1)),
times = 1:28,
y_levels = 1:8,
absorb = 8
)
} # }
