||
library(lavaan)
popModel <- "
A=~0.641*x1+0.653*x2+0.760*x3+0.760*x4
B=~0.727*x5+0.756*x6+0.899*x7
C=~0.574*x8+0.689*x9+0.697*x10
D=~0.685*x11+0.575*x12+0.549*x13
E=~0.750*x14+0.743*x15+0.648*x16+0.634*x17
F=~0.796*x18+0.741*x19+0.691*x20
G=~0.769*x21+0.739*x22+0.747*x23
H=~0.803*x24+0.636*x25+0.779*x26
A~~ 1*A
B~~ 1*B
C~~ 1*C
D~~ 1*D
E~~ 1*E
F~~ 1*F
G~~ 1*G
H~~ 1*H
A~~ 0.459*B
A~~ 0.282*C
A~~ 0.256*D
A~~ 0.260*E
A~~ 0.288*F
A~~ 0.336*G
A~~ 0.526*H
B~~ 0.204*C
B~~ 0.238*D
B~~ 0.254*E
B~~ 0.243*F
B~~ 0.280*G
B~~ 0.434*H
C~~ 0.293*D
C~~ 0.279*E
C~~ 0.293*F
C~~ 0.326*G
C~~ 0.265*H
D~~ 0.255*E
D~~ 0.370*F
D~~ 0.269*G
D~~ 0.254*H
E~~ 0.299*F
E~~ 0.320*G
E~~ 0.302*H
F~~ 0.364*G
F~~ 0.224*H
G~~ 0.553*H
x1 ~~ 0.589*x1
x2 ~~ 0.574*x2
x3 ~~ 0.422*x3
x4 ~~ 0.422*x4
x5 ~~ 0.471*x5
x6 ~~ 0.428*x6
x7 ~~ 0.192*x7
x8 ~~ 0.671*x8
x9 ~~ 0.525*x9
x10 ~~ 0.514*x10
x11 ~~ 0.531*x11
x12 ~~ 0.699*x12
x13 ~~ 0.699*x13
x14 ~~ 0.438*x14
x15 ~~ 0.448*x15
x16 ~~ 0.580*x16
x17 ~~ 0.598*x17
x18 ~~ 0.366*x18
x19 ~~ 0.451*x19
x20 ~~ 0.523*x20
x21 ~~ 0.409*x21
x22 ~~ 0.454*x22
x23 ~~ 0.442*x23
x24 ~~ 0.355*x24
x25 ~~ 0.596*x25
x26 ~~ 0.393*x26
"
data <- simulateData(popModel, sample.nobs = 200)
analyzeModel <- "
A=~x1+x2+x3+x4
B=~x5+x6+x7
C=~x8+x9+x10
D=~x11+x12+x13
E=~x14+x15+x16+x17
F=~x18+x19+x20
G=~x21+x22+x23
H=~x24+x25+x26
"
data <- cfa(analyzeModel, data = data, std.lv = TRUE)
# Use simsem to simulate and analyze multiple data sets
library(simsem)
Output1 <- sim(1000, analyzeModel, n=376, generate=popModel,
lavaanfun = "cfa", std.lv=TRUE)
summary(Output1)
Output2 <- sim(NULL, analyzeModel, n=100:1000, generate=popModel,
lavaanfun = "cfa", std.lv=TRUE)
summary(Output2)
powTable2 <- getPower(Output2)
findPower(powTable2, "N", 0.89)
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-7-27 22:41
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社