dlvm1 | R Documentation |
This is the family of models that models a dynamic factor model on panel data. There are four covariance structures that can be modeled in different ways: within_latent
, between_latent
for the within-person and between-person latent (contemporaneous) models respectively, and within_residual
, between_residual
for the within-person and between-person residual models respectively. The panelgvar
wrapper function sets the lambda
to an identity matrix, all residual variances to zero, and models within-person and between-person latent (contemporaneous) models as GGMs. The panelvar
wrapper does the same but models contemporaneous relations as a variance-covariance matrix. Finally, the panel_lvgvar
wrapper automatically models all latent networks as GGMs.
dlvm1(data, vars, lambda, within_latent = c("cov", "chol",
"prec", "ggm"), within_residual = c("cov", "chol",
"prec", "ggm"), between_latent = c("cov", "chol",
"prec", "ggm"), between_residual = c("cov", "chol",
"prec", "ggm"), beta = "full", omega_zeta_within =
"full", delta_zeta_within = "diag", kappa_zeta_within
= "full", sigma_zeta_within = "full",
lowertri_zeta_within = "full", omega_epsilon_within =
"zero", delta_epsilon_within = "diag",
kappa_epsilon_within = "diag", sigma_epsilon_within =
"diag", lowertri_epsilon_within = "diag",
omega_zeta_between = "full", delta_zeta_between =
"diag", kappa_zeta_between = "full",
sigma_zeta_between = "full", lowertri_zeta_between =
"full", omega_epsilon_between = "zero",
delta_epsilon_between = "diag", kappa_epsilon_between
= "diag", sigma_epsilon_between = "diag",
lowertri_epsilon_between = "diag", nu, mu_eta,
identify = TRUE, identification = c("loadings",
"variance"), latents, groups, covs, means, nobs, start
= "version2", covtype = c("choose", "ML", "UB"),
missing = "listwise", equal = "none",
baseline_saturated = TRUE, estimator = "ML",
optimizer, storedata = FALSE, verbose = FALSE,
sampleStats, baseline =
c("stationary_random_intercept", "stationary",
"independence", "none"), bootstrap = FALSE, boot_sub,
boot_resample)
panelgvar(data, vars, within_latent = c("ggm","chol","cov","prec"),
between_latent = c("ggm","chol","cov","prec"), ...)
panelvar(data, vars, within_latent = c("cov","chol","prec","ggm"),
between_latent = c("cov","chol","prec","ggm"), ...)
panel_lvgvar(...)
data |
A data frame encoding the data used in the analysis. Can be missing if |
vars |
Required argument. Different from in other psychonetrics models, this must be a *matrix* with each row indicating a variable and each column indicating a measurement. The matrix must be filled with names of the variables in the dataset corresponding to variable i at wave j. NAs can be used to indicate missing waves. The rownames of this matrix will be used as variable names. |
lambda |
Required argument. A model matrix encoding the factor loading structure. Each row indicates an indicator and each column a latent. A 0 encodes a fixed to zero element, a 1 encoding a free to estimate element, and higher integers encoding equality constrains. For multiple groups, this argument can be a list or array with each element/slice encoding such a matrix. |
within_latent |
The type of within-person latent contemporaneous model to be used. |
within_residual |
The type of within-person residual model to be used. |
between_latent |
The type of between-person latent model to be used. |
between_residual |
The type of between-person residual model to be used. |
beta |
A model matrix encoding the temporal relationships (transpose of temporal network). A 0 encodes a fixed to zero element, a 1 encoding a free to estimate element, and higher integers encoding equality constrains. For multiple groups, this argument can be a list or array with each element/slice encoding such a matrix. Can also be |
omega_zeta_within |
Only used when |
delta_zeta_within |
Only used when |
kappa_zeta_within |
Only used when |
sigma_zeta_within |
Only used when |
lowertri_zeta_within |
Only used when |
omega_epsilon_within |
Only used when |
delta_epsilon_within |
Only used when |
kappa_epsilon_within |
Only used when |
sigma_epsilon_within |
Only used when |
lowertri_epsilon_within |
Only used when |
omega_zeta_between |
Only used when |
delta_zeta_between |
Only used when |
kappa_zeta_between |
Only used when |
sigma_zeta_between |
Only used when |
lowertri_zeta_between |
Only used when |
omega_epsilon_between |
Only used when |
delta_epsilon_between |
Only used when |
kappa_epsilon_between |
Only used when |
sigma_epsilon_between |
Only used when |
lowertri_epsilon_between |
Only used when |
nu |
Optional vector encoding the intercepts of the observed variables. Set elements to 0 to indicate fixed to zero constrains, 1 to indicate free intercepts, and higher integers to indicate equality constrains. For multiple groups, this argument can be a list or array with each element/column encoding such a vector. |
mu_eta |
Optional vector encoding the means of the latent variables. Set elements to 0 to indicate fixed to zero constrains, 1 to indicate free intercepts, and higher integers to indicate equality constrains. For multiple groups, this argument can be a list or array with each element/column encoding such a vector. |
identify |
Logical, should the model be automatically identified? |
identification |
Type of identification used. |
latents |
An optional character vector with names of the latent variables. |
groups |
An optional string indicating the name of the group variable in |
covs |
A sample variance–covariance matrix, or a list/array of such matrices for multiple groups. IMPORTANT NOTE: psychonetrics expects the maximum likelihood (ML) covariance matrix, which is NOT obtained from |
means |
A vector of sample means, or a list/matrix containing such vectors for multiple groups. |
nobs |
The number of observations used in |
start |
Start value specification. Can be either a string or a psychonetrics model. If it is a string, |
missing |
How should missingness be handled in computing the sample covariances and number of observations when |
equal |
A character vector indicating which matrices should be constrained equal across groups. |
baseline_saturated |
A logical indicating if the baseline and saturated model should be included. Mostly used internally and NOT Recommended to be used manually. |
estimator |
The estimator to be used. Currently implemented are |
optimizer |
The optimizer to be used. Can be one of |
storedata |
Logical, should the raw data be stored? Needed for bootstrapping (see |
verbose |
Logical, should progress be printed to the console? |
sampleStats |
An optional sample statistics object. Mostly used internally. |
covtype |
If 'covs' is used, this is the type of covariance (maximum likelihood or unbiased) the input covariance matrix represents. Set to |
baseline |
What baseline model should be used? |
bootstrap |
Should the data be bootstrapped? If |
boot_sub |
Proportion of cases to be subsampled ( |
boot_resample |
Logical, should the bootstrap be with replacement ( |
... |
Arguments sent to |
An object of the class psychonetrics (psychonetrics-class)
Sacha Epskamp
library("dplyr")
# Smoke data cov matrix, based on LISS data panel https://www.dataarchive.lissdata.nl
smoke <- structure(c(47.2361758611759, 43.5366809116809, 41.0057465682466,
43.5366809116809, 57.9789886039886, 47.6992521367521,
41.0057465682466,
47.6992521367521, 53.0669434731935), .Dim = c(3L, 3L),
.Dimnames = list(
c("smoke2008", "smoke2009", "smoke2010"), c("smoke2008",
"smoke2009", "smoke2010")))
# Design matrix:
design <- matrix(rownames(smoke),1,3)
# Form model:
mod <- panelvar(vars = design,
covs = smoke, nobs = 352
)
# Run model:
mod <- mod %>% runmodel
# Evaluate fit:
mod %>% fit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.