| fit_var_each | R Documentation |
Applies fit_var() to each subject separately, returning one transparent
person-specific OLS VAR result per individual. This is the unregularized
companion to fit_graphical_var_each() and is useful as an equivalence baseline
for checking lag construction, scaling, and temporal coefficient direction.
fit_var_each(data, vars, id, day = NULL, beep = NULL, min_obs = NULL, ...)
data |
A |
vars |
Character vector of variable names. |
id |
Character. Name of the person-ID column; required. |
day |
Character. Name of the day/session column, or |
beep |
Character. Name of the measurement-occasion column, or |
min_obs |
Integer or |
... |
Further arguments passed to |
A named list of var_result objects (class var_list), one element
per subject, named by subject id. Subjects that cannot be fit are dropped
with a warning.
set.seed(1)
d <- data.frame(
id = rep(1:3, each = 40),
day = rep(1, 120),
beep = rep(seq_len(40), 3),
A = rnorm(120), B = rnorm(120), C = rnorm(120)
)
fits <- fit_var_each(d, vars = c("A", "B", "C"), id = "id",
day = "day", beep = "beep")
fits[["1"]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.