
Plot an Empirical or Model-Implied Correlation Variogram
Source:R/viz-correlation.R
plot_variogram.Rdplot_variogram() summarizes the same time-by-time correlation matrix used
by plot_correlation() as correlations against absolute time differences.
Its minimum input requirements are the same as plot_correlation().
Usage
plot_variogram(
x,
newdata = NULL,
times = NULL,
y_levels = NULL,
absorb = NULL,
id_var = "id",
time_var = "time",
y_var = "y",
p_var = "yprev",
p2_var = NULL,
facet_var = NULL,
gap_var = NULL,
time_covariates = NULL,
seed = NULL,
n_draws = 100L,
smooth = TRUE,
method = c("spearman", "pearson")
)Arguments
- x
A trajectory data frame or a fitted Markov model.
- newdata
Optional data frame of prediction profiles for model-based plots. If
NULL, wrapper-fitted models use their stored data and extract one prediction row per ID.- times
Optional time values to include. Required for model-based plots.
- y_levels
Optional state levels. If supplied for raw trajectory data, state scores follow this order.
- absorb
Optional absorbing-state label for model-based recursions.
- id_var
Character ID column for raw data and stored model-data extraction.
- time_var
Character name of the time column.
- y_var
Character name of the state column in raw trajectory data.
- p_var
Character name of the previous-state column for model recursions.
- p2_var
Optional second previous-state column for second-order model recursions.
- facet_var
Optional grouping variable. Correlations are computed separately within each observed stratum.
- 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.
- seed
Optional random seed for
blrmposterior draw selection.- n_draws
Integer number of posterior draws to sample for
blrm, orNULLto use all stored draws. Defaults to 100.- smooth
Logical. If
TRUE, add a loess smooth.- method
Correlation method:
"spearman"(default) or"pearson".