| fit_var_bayes | R Documentation |
Native, pure-R Bayesian VAR(1) that reproduces Mplus's Bayesian
(DSEM/time-series) estimates without needing Mplus. It is the unregularized
Bayesian counterpart of fit_graphical_var(): instead of a graphical-lasso /
EBIC sparse fit, it estimates a full VAR(1) with a flat prior on the
temporal coefficients and an inverse-Wishart prior on the residual
precision, then reports the temporal network B and the contemporaneous
partial-correlation network derived from the residual covariance. With more
than one subject the data are within-person centred and pooled (as in
fit_graphical_var()).
fit_var_bayes(
data,
vars,
id = NULL,
day = NULL,
beep = NULL,
lags = 1L,
scale = TRUE,
center_within = TRUE,
n_iter = 4000L,
n_burnin = NULL,
n_chains = 2L,
thin = 1L,
seed = NULL,
min_obs = NULL,
subject = NULL,
verbose = FALSE
)
data |
A |
vars |
Character vector of variable names (length >= 2). |
id |
Character. Person-ID column, or |
day |
Character. Day/session column, or |
beep |
Character. Beep/measurement column, or |
lags |
Integer lag order; only |
scale |
Logical. Global standardization of each variable. Default |
center_within |
Logical. Within-person centre when >1 id (removes
between-person variance, as in |
n_iter, n_burnin, n_chains, thin |
MCMC controls. Defaults |
seed |
Integer or |
min_obs |
Integer or |
subject |
Optional vector naming the exact subject(s) to analyse. |
verbose |
Logical. Progress messages. Default |
A var_bayes_result object (a cograph group with temporal and
contemporaneous netobjects) carrying beta, temporal, kappa, PCC,
PDC, posterior draws, and a tidy coefs() table (posterior median, SD,
95% CI, one-tailed p, significance by CI excluding 0).
fit_graphical_var() (regularized GLASSO/EBIC), fit_var() (OLS),
fit_mlvar_bayes() (multilevel Bayesian VAR).
set.seed(1)
y <- matrix(0, 200, 2)
for (t in 2:200) y[t, ] <- c(0.4, 0.3) * y[t - 1, ] + rnorm(2)
d <- data.frame(A = y[, 1], B = y[, 2])
fit <- fit_var_bayes(d, vars = c("A", "B"), n_iter = 500, seed = 1)
print(fit)
coefs(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.