matrixpls.sim: Monte Carlo simulations with matrixpls

Description Usage Arguments Details Value See Also Examples

View source: R/matrixpls.sim.R

Description

Performs Monte Carlo simulations of matrixpls with the sim function of the simsem package. The standard errors and confidence intervals are estimated with the boot and boot.ci functions of the boot package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
matrixpls.sim(
  nRep = NULL,
  model = NULL,
  n = NULL,
  ...,
  cilevel = 0.95,
  citype = c("norm", "basic", "stud", "perc", "bca"),
  boot.R = 500,
  fitIndices = fitSummary,
  outfundata = NULL,
  outfun = NULL,
  prefun = NULL
)

Arguments

nRep

Number of replications. If any of the n, pmMCAR, or pmMAR arguments are specified as lists, the number of replications will default to the length of the list(s), and nRep need not be specified.

model

There are two options for this argument: 1. lavaan script or lavaan parameter table, or 2. a list containing three matrices inner, reflective, and formative defining the free regression paths in the model.

n

Sample size(s). In single-group models, either a single integer, or a vector of integers to vary sample size across replications. In multigroup models, either a list of single integers (for constant group sizes across replications) or a list of vectors (to vary group sizes across replications). Any non-integers will be rounded.

...

All other arguments are passed through to sim, matrixpls.boot, or matrixpls.

cilevel

Confidence level. This argument will be forwarded to the boot.ci when calculating the confidence intervals.

citype

Type of confidence interval. This argument will be forwarded to the boot.ci when calculating the confidence intervals.

boot.R

Number of bootstrap replications to use to estimate standard errors or FALSE to disable bootstrapping.

fitIndices

A function that returns a list of fit indices for the model. Setting this argument to NULL disables fit indices.

outfundata

A function to be applied to the matrixpls output and the generated data after each replication. Users can get the characteristics of the generated data and also compare the characteristics with the generated output. The output from this function in each replication will be saved in the simulation output (SimResult), and can be obtained using the getExtraOutput function.

outfun

A function to be applied to the matrixpls output at each replication. Output from this function in each replication will be saved in the simulation output (SimResult), and can be obtained using the getExtraOutput function.

prefun

A function to be applied to the dataset before each replication. The output of this function is passed as arguments to matrixpls

Details

This function calls the sim function from the simsem package to perform Monte Carlo simulations with matrixpls. The function parses the model parameters and replaces it with a function call that estimates the model and bootstrapped standard errors and confidence intervals with matrixpls.boot.

If the generate or rawdata arguments are not specified in the sim arguments then the model argument will be used for data generation and must be specified in lavaan format.

Value

An object of class SimResult-class.

See Also

matrixpls, matrixpls.boot, sim, SimResult-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
if(!require(simsem)){
    print("This example requires the simsem package")
} else{

#
# Runs the second model from
#
# Aguirre-Urreta, M., & Marakas, G. (2013). Partial Least Squares and Models with Formatively 
# Specified Endogenous Constructs: A Cautionary Note. Information Systems Research. 
# doi:10.1287/isre.2013.0493

library(MASS)

X <- diag(15) 
X[upper.tri(X, diag=TRUE)] <- c(
  1.000,
  0.640, 1.000,
  0.640, 0.640, 1.000,
  0.640, 0.640, 0.640, 1.000,
  0.096, 0.096, 0.096, 0.096, 1.000,
  0.096, 0.096, 0.096, 0.096, 0.640, 1.000,
  0.096, 0.096, 0.096, 0.096, 0.640, 0.640, 1.000,
  0.096, 0.096, 0.096, 0.096, 0.640, 0.640, 0.640, 1.000,
  0.115, 0.115, 0.115, 0.115, 0.192, 0.192, 0.192, 0.192, 1.000,
  0.115, 0.115, 0.115, 0.115, 0.192, 0.192, 0.192, 0.192, 0.640, 1.000,
  0.115, 0.115, 0.115, 0.115, 0.192, 0.192, 0.192, 0.192, 0.640, 0.640,
  1.000,
  0.115, 0.115, 0.115, 0.115, 0.192, 0.192, 0.192, 0.192, 0.640, 0.640,
  0.640, 1.000,
  0.000, 0.000, 0.000, 0.000, 0.271, 0.271, 0.271, 0.271, 0.325, 0.325,
  0.325, 0.325, 1.000,
  0.000, 0.000, 0.000, 0.000, 0.271, 0.271, 0.271, 0.271, 0.325, 0.325,
  0.325, 0.325, 0.300, 1.000,
  0.000, 0.000, 0.000, 0.000, 0.271, 0.271, 0.271, 0.271, 0.325, 0.325,
  0.325, 0.325, 0.300, 0.300, 1.000
)
X <- X + t(X) - diag(diag(X)) 

colnames(X) <- rownames(X) <- c(paste("Y",1:12,sep=""),paste("X",1:3,sep=""))

# Print the population covariance matrix X to see that it is correct

X

# The estimated model in Lavaan syntax

analyzeModel <- "
ksi =~ Y1 + Y2 + Y3 + Y4
eta1 <~ X1 + X2 + X3
eta2 =~ Y5 + Y6 + Y7 + Y8
eta3 =~ Y9 + Y10 + Y11 + Y12

eta1 ~ ksi
eta2 ~ eta1
eta3 ~ eta1
"

# Only run 100 replications without bootstrap replications each so that the 
# example runs faster. Generate the data outside simsem because simsem
# does not support drawing samples from population matrix

dataSets <- lapply(1:100, function(x){
  mvrnorm(300,                 # Sample size
          rep(0,15),           # Means
          X)                   # Population covarancematrix
})

Output <- matrixpls.sim(model = analyzeModel, rawData = dataSets, boot.R=FALSE,
                        multicore = FALSE, stopOnError = TRUE)

summary(Output)


}

Example output

Attaching package: 'matrixpls'

The following objects are masked from 'package:stats':

    ave, loadings

Loading required package: simsem
Loading required package: lavaan
This is lavaan 0.5-23.1097
lavaan is BETA software! Please report any bugs.
 
###############################################################################################
This is simsem 0.5-13
simsem is BETA software! Please report any bugs.
simsem was developed at the University of Kansas Center for Research Methods and Data Analysis.
###############################################################################################
Progress: 1 / 100 
Progress: 2 / 100 
Progress: 3 / 100 
Progress: 4 / 100 
Progress: 5 / 100 
Progress: 6 / 100 
Progress: 7 / 100 
Progress: 8 / 100 
Progress: 9 / 100 
Progress: 10 / 100 
Progress: 11 / 100 
Progress: 12 / 100 
Progress: 13 / 100 
Progress: 14 / 100 
Progress: 15 / 100 
Progress: 16 / 100 
Progress: 17 / 100 
Progress: 18 / 100 
Progress: 19 / 100 
Progress: 20 / 100 
Progress: 21 / 100 
Progress: 22 / 100 
Progress: 23 / 100 
Progress: 24 / 100 
Progress: 25 / 100 
Progress: 26 / 100 
Progress: 27 / 100 
Progress: 28 / 100 
Progress: 29 / 100 
Progress: 30 / 100 
Progress: 31 / 100 
Progress: 32 / 100 
Progress: 33 / 100 
Progress: 34 / 100 
Progress: 35 / 100 
Progress: 36 / 100 
Progress: 37 / 100 
Progress: 38 / 100 
Progress: 39 / 100 
Progress: 40 / 100 
Progress: 41 / 100 
Progress: 42 / 100 
Progress: 43 / 100 
Progress: 44 / 100 
Progress: 45 / 100 
Progress: 46 / 100 
Progress: 47 / 100 
Progress: 48 / 100 
Progress: 49 / 100 
Progress: 50 / 100 
Progress: 51 / 100 
Progress: 52 / 100 
Progress: 53 / 100 
Progress: 54 / 100 
Progress: 55 / 100 
Progress: 56 / 100 
Progress: 57 / 100 
Progress: 58 / 100 
Progress: 59 / 100 
Progress: 60 / 100 
Progress: 61 / 100 
Progress: 62 / 100 
Progress: 63 / 100 
Progress: 64 / 100 
Progress: 65 / 100 
Progress: 66 / 100 
Progress: 67 / 100 
Progress: 68 / 100 
Progress: 69 / 100 
Progress: 70 / 100 
Progress: 71 / 100 
Progress: 72 / 100 
Progress: 73 / 100 
Progress: 74 / 100 
Progress: 75 / 100 
Progress: 76 / 100 
Progress: 77 / 100 
Progress: 78 / 100 
Progress: 79 / 100 
Progress: 80 / 100 
Progress: 81 / 100 
Progress: 82 / 100 
Progress: 83 / 100 
Progress: 84 / 100 
Progress: 85 / 100 
Progress: 86 / 100 
Progress: 87 / 100 
Progress: 88 / 100 
Progress: 89 / 100 
Progress: 90 / 100 
Progress: 91 / 100 
Progress: 92 / 100 
Progress: 93 / 100 
Progress: 94 / 100 
Progress: 95 / 100 
Progress: 96 / 100 
Progress: 97 / 100 
Progress: 98 / 100 
Progress: 99 / 100 
Progress: 100 / 100 
RESULT OBJECT
Model Type
[1] "function"
========= Fit Indices Cutoffs ============
           Alpha
Fit Indices   0.1  0.05  0.01 0.001  Mean    SD
       srmr 0.335 0.341 0.352 0.356 0.315 0.017
========= Parameter Estimates and Standard Errors ============
          Estimate Average Estimate SD
eta1~ksi            -0.004       0.088
eta2~eta1            0.439       0.046
eta3~eta1            0.525       0.044
ksi=~Y1              0.705       0.274
ksi=~Y2              0.719       0.302
ksi=~Y3              0.745       0.279
ksi=~Y4              0.739       0.252
eta2=~Y5             0.853       0.018
eta2=~Y6             0.853       0.018
eta2=~Y7             0.851       0.017
eta2=~Y8             0.851       0.018
eta3=~Y9             0.852       0.017
eta3=~Y10            0.851       0.018
eta3=~Y11            0.854       0.016
eta3=~Y12            0.854       0.017
eta1<~X1             0.458       0.076
eta1<~X2             0.455       0.074
eta1<~X3             0.449       0.074
================== Replications =====================
Number of replications = 100 
Number of converged replications = 100 
Number of nonconverged replications: 
   1. Nonconvergent Results = 0 
   2. Nonconvergent results from multiple imputation = 0 
   3. At least one SE were negative or NA = 0 
   4. At least one variance estimates were negative = 0 
   5. At least one correlation estimates were greater than 1 or less than -1 = 0 
   6. Model-implied covariance matrices of any groups of latent variables are not positive definite = 0 
NOTE: The data generation model is not the same as the analysis model. See the summary of the population underlying data generation by the summaryPopulation function.

matrixpls documentation built on April 28, 2021, 5:07 p.m.