View source: R/rolling_graphical_var.R
| fit_rolling_graphical_var | R Documentation |
Fits fit_graphical_var() over ordered, overlapping windows within each subject.
This is the time-varying graphical VAR companion to fit_rolling_var(): every
window uses graphical VAR's lag construction, EBIC/penalty settings, and
tidy coefficient access, then returns one coefficient table per window.
fit_rolling_graphical_var(
data,
vars,
id = NULL,
day = NULL,
beep = NULL,
window_size,
step = 1L,
scale = TRUE,
center_within = TRUE,
delete_missings = TRUE,
min_obs = NULL,
subject = NULL,
keep_fits = FALSE,
...
)
data |
A |
vars |
Character vector of variable names. |
id |
Character. Name of the person-ID column, or |
day |
Character. Name of the day/session column, or |
beep |
Character. Name of the measurement-occasion column, or |
window_size |
Integer number of ordered rows per rolling window. |
step |
Integer number of rows to advance between windows. Default |
scale |
Logical. Whether to standardize variables inside each window.
Default |
center_within |
Logical. Whether to centre within person inside each
window when more than one id is present. Default |
delete_missings |
Logical. Drop incomplete current/lagged rows. Default
|
min_obs |
Integer or |
subject |
Optional vector naming the subject(s) to analyse. |
keep_fits |
Logical. Store successful |
... |
Further arguments passed to |
A rolling_gvar_result with $estimates, $windows, $failures,
and optionally $fits. $estimates is a tidy coefficient table with
subject/window metadata plus network, from, to, and weight.
set.seed(1)
d <- data.frame(id = 1, day = rep(1:5, each = 20),
beep = rep(1:20, 5),
A = rnorm(100), B = rnorm(100), C = rnorm(100))
tv <- fit_rolling_graphical_var(d, vars = c("A", "B", "C"), id = "id",
day = "day", beep = "beep",
window_size = 50, step = 25,
scale = FALSE, n_lambda = 5)
head(tv$estimates)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.