mlVARsample: Simulator function given an mlVAR object

View source: R/mlVARsamplesize.R

mlVARsampleR Documentation

Simulator function given an mlVAR object


Simulates data based on an mlVAR object, estimates the mlVAR network model based on the simulated data and compares the estimated network to the mlVAR object network.


mlVARsample(object, nTime = c(25,50,100,200), nSample = 100, pMissing = 0, 
  nReps = 100, nCores = 1, ...)

## S3 method for class 'mlVARsample'
summary(object, ...)



mlVAR object, or mlVARsample object in the summary method


Vector with number of time points to test.


Number of individuals in the dataset. It is possible to decrease the number of individuals compared to the individuals in the mlVAR object. However, it is not possible to have more individuals than there are in the mlVAR object.


Percentage of missing data to be simulated.


Number of repetitions for each condition.


Number of cores to use.


Arguments sent to mlVAR.


This function simulates data based on the mlVAR object. The individual networks (random effects) are used to simulate data using the graphicalVARsim function from the graphicalVAR package (Epskamp, 2020). The individual data is combined into one dataset. This dataset is used to estimate the mlVAR network.

For every condition, the function returns four values per network comparison measure (correlation, sensitivity, specificity, bias, and precision): one for the fixed temporal effects, one for the fixed contemporaneous effects, the mean comparison value of the random temporal effects, and the mean comparison value of the random contemporaneous effects.


Sacha Epskamp <>


Sacha Epskamp (2020). graphicalVAR: Graphical VAR for Experience Sampling Data. R package version 0.2.3.

See Also

mlVARsim, mlVAR


## Not run: 
### Small example ###
# Simulate data:
Model <- mlVARsim(nPerson = 100, nNode = 3, nTime = 50, lag=1)

# Estimate using correlated random effects:
fit <- mlVAR(Model$Data, vars = Model$vars, 
             idvar = Model$idvar, lags = 1, 
             temporal = "correlated")

# Sample from fitted model: 
samples <- mlVARsample(fit, nTime = 50, nSample = 50, pMissing = 0.1,
                       nReps = 5, nCores = 1)

# Summarize results:

## End(Not run) 

mlVAR documentation built on May 31, 2023, 6:51 p.m.

Related to mlVARsample in mlVAR...