mlVAR_GC {mnet}R Documentation

Testing Group Differences in mlVAR

Description

Does inference on group differences in mlVAR models using a permutation test. The function is a wrapper around the function mlVAR() from the mlVAR package.

Usage

mlVAR_GC(data, vars, idvar, dayvar = NULL,
         beepvar = NULL, groups, test = "permutation",
         paired = FALSE, estimator, contemporaneous,
         temporal, nCores = 1, nP = 500, saveModels = FALSE,
         verbose = FALSE, pbar = TRUE)

Arguments

data

The data.frame containing the data (rows=cases, columns=variables) including the variables to be modeled, a unique id per subject, and potentially additional variables about the measurement procedure (see dayvar and dayvar below).

vars

A character vector with the column names of the variables that should be included in the mlVAR models.

idvar

The name of the column containing the unique subject id.

dayvar

Optional: The name of the column indicating assessment day. Adding this argument makes sure that the first measurement of a day is not regressed on the last measurement of the previous day. IMPORTANT: only add this if the data has multiple observations per day. See also mlVAR().

beepvar

Optional: The name of the column indicating measurement occasion per day. Adding this argument will cause non-consecutive beeps to be treated as missing! See also mlVAR().

groups

The name of the column indicating group membership.

test

The type of test used. Defaults to test = "permutation", which performs a permutation test. Alternatively, test = "parametric" performs a parametric test based on confidence intervals. For the latter, a (vectorcritical p-value has to be specified.

paired

Indicates whether samples are paired or not (independent). If paired = TRUE indicates dependent samples. This requires that idvar needs to be specified such that each subject is contained in both groups, which implies that both groups have the same size. Also, the function assumes that the subjects are ordered in the same way in both groups. In this case, the permutation is computed based on within-person permutationst. The parametric test is not possible in this case since we are not able to obtain the required standard error from mlVAR models. If paired = FALSE the permutations are unrestricted. Defaults to paired = FALSE.

estimator

The estimator to be used. "lmer" for sequential univariate multi-level estimation, "Mplus" for multivariate Bayesian estimation (requires Mplus), and "lm" for fixed effects estimation. See also mlVAR().

contemporaneous

How should the contemporaneous networks be estimated? These networks are always estimated post-hoc by investigating the residuals of the temporal models. "correlated" and "orthogonal" run second multi-level models in which the networks are estimated using node-wise estimation. "fixed" and "unique" simply correlate the residuals, either by computing one network for all subjects (fixed) or a single network per per subject. See also mlVAR().

temporal

How should the temporal effects be estimated? "correlated" estimates correlated random effects, "orthogonal" estimates non-correlated random effects and "fixed" estimates a model in which only the intercept is random. Defaults to "correlated" when the number of variables is less than 6 and "orthogonal" otherwise. "unique" uses lm to estimate an unique model for each subject. See also mlVAR().

nCores

Number of cores to use in computation. See also mlVAR().

nP

Number of permutations used to create the sampling distribution under the null hypothesis for the permutation test. Defaults to nP = 500.

saveModels

If true, the pair of mlVAR objects for each permutations are saved in the output. Defaults to saveModels = FALSE since the resulting output object can become very large.

verbose

If true, the the verbose option in foreach, which is used in side mlVAR_GC(), is switched on. Defaults to verbose = FALSE.

pbar

If true, a progress bar is shown. Defaults to pbar = TRUE.

Details

The output consists of a list with the following entries:

Value

Returns a list with the following entries:

EmpDiffs

A list containing five matrices with the empirically observed differences (Group 1 - Group 2) in the between-person network, the fixed and random effects variances of the temporal network, and the fixed and random effects variances of the contemporaneous network.

Pval

Same structure as TrueDiffs but provides p-values for the corresponding observed group differences. Note that for the parametric test, p-values are only available for fixed lagged effects, fixed contemporaneous (residual) effects, and the between network effects. This is because mlVAR only provides standard errors for those types of parameters.

SampDist

A list of arrays, containing the sampling distributions for between-person network, the fixed and random effects variances of the temporal network, and the fixed and random effects variances of the contemporaneous network.

Models

If saveModels = TRUE, this contains a list with all pairs of mlVAR models for each permutation.

Runtime

The runtime of the function in minutes.

Author(s)

Jonas Haslbeck <jonashaslbeck@protonmail.com>

References

Epskamp, S., Waldorp, L. J., Mõttus, R., & Borsboom, D. (2018). The Gaussian graphical model in cross-sectional and time-series data. Multivariate behavioral research, 53(4), 453-480.

Examples




# Use simulated example data loaded with package
head(ExampleData)

# Call Permutation test
out <- mlVAR_GC(data = ExampleData,
                vars = c("V1", "V2", "V3"),
                idvar = "id",
                groups = "group",
                nCores = 2, # choose max cores possible on your machine
                nP = 2) # Should be more in practice, see paper!

# P-values for the five parameter types:
out$Pval
# e.g., we see that there is a small p-value for
out$Pval$Phi_mean[1,2]
# which is a parameter with a true group difference
# (which we know since this is simulated data)

# The observed group differences (i.e., the test statistics)
# Can be found in:
out$EmpDiffs

# Specifically, the difference is: group 1 - group 2
# For example:
out$EmpDiffs$Phi_mean[1,2,]
# The true group difference was -0.4




[Package mnet version 0.1.2 Index]