library(lavaan)
library(semTools)
library(simsem)
library(pwr)
To estimate sample size, we conducted a rudimentary power analysis. That is, we planned for a two-sided correlation of r = .1. We adopted a balanced alpha and beta error approach. Because we were in “exploration mode”, we aimed for a high statistical power and hence relaxed alpha. Ideally, we would have wanted to set an error rate of 5%; however, this was outside of our budget. Instead, we opted for an error rate of 10%.
sesoi <- 0.1
# a priori power analyses
pwr.r.test(r = sesoi, sig.level = 0.05, power = 0.95)
##
## approximate correlation power calculation (arctangh transformation)
##
## n = 1293
## r = 0.1
## sig.level = 0.05
## power = 0.95
## alternative = two.sided
power_n_95 <- pwr.r.test(r = sesoi, sig.level = 0.05, power = 0.95)$n
A 5% error rate would imply collecting 1292.88 participants.
population <-
"
# Fix means to 0
HEX_HOH_SIN_01 ~ 0*1
HEX_HOH_SIN_02 ~ 0*1
HEX_HOH_SIN_03 ~ 0*1
HEX_HOH_SIN_04 ~ 0*1
NFP_PHY_01 ~ 0*1
NFP_PHY_02 ~ 0*1
NFP_PHY_03 ~ 0*1
NFP_PHY_04 ~ 0*1
# Fix variances
HEX_HOH_SIN_01 ~~ 1 * HEX_HOH_SIN_01
HEX_HOH_SIN_02 ~~ 1 * HEX_HOH_SIN_02
HEX_HOH_SIN_03 ~~ 1 * HEX_HOH_SIN_03
HEX_HOH_SIN_04 ~~ 1 * HEX_HOH_SIN_04
NFP_PHY_01 ~~ 1 * NFP_PHY_01
NFP_PHY_02 ~~ 1 * NFP_PHY_02
NFP_PHY_03 ~~ 1 * NFP_PHY_03
NFP_PHY_04 ~~ 1 * NFP_PHY_04
# Define latent vars
HEX_HOH_SIN =~ .9*HEX_HOH_SIN_01 + .9*HEX_HOH_SIN_02 + .9*HEX_HOH_SIN_03 + .9*HEX_HOH_SIN_04
NFP_PHY =~ .9*NFP_PHY_01 + .9*NFP_PHY_02 + .9*NFP_PHY_03 + .9*NFP_PHY_04
# Covariances
HEX_HOH_SIN ~~ .1*NFP_PHY
"
sample <- "
HEX_HOH_SIN =~ HEX_HOH_SIN_01 + HEX_HOH_SIN_02 + HEX_HOH_SIN_03 + HEX_HOH_SIN_04
NFP_PHY =~ NFP_PHY_01 + NFP_PHY_02 + NFP_PHY_03 + NFP_PHY_04
"
reliability <- simsem::sim(
# nRep = NULL,
model = sample,
# n = 500,
n = seq(500, 5000, 50),
generate = population,
# std.lv = TRUE,
lavaanfun = "sem"
)
## Progress: 1 / 91
## Progress: 2 / 91
## Progress: 3 / 91
## Progress: 4 / 91
## Progress: 5 / 91
## Progress: 6 / 91
## Progress: 7 / 91
## Progress: 8 / 91
## Progress: 9 / 91
## Progress: 10 / 91
## Progress: 11 / 91
## Progress: 12 / 91
## Progress: 13 / 91
## Progress: 14 / 91
## Progress: 15 / 91
## Progress: 16 / 91
## Progress: 17 / 91
## Progress: 18 / 91
## Progress: 19 / 91
## Progress: 20 / 91
## Progress: 21 / 91
## Progress: 22 / 91
## Progress: 23 / 91
## Progress: 24 / 91
## Progress: 25 / 91
## Progress: 26 / 91
## Progress: 27 / 91
## Progress: 28 / 91
## Progress: 29 / 91
## Progress: 30 / 91
## Progress: 31 / 91
## Progress: 32 / 91
## Progress: 33 / 91
## Progress: 34 / 91
## Progress: 35 / 91
## Progress: 36 / 91
## Progress: 37 / 91
## Progress: 38 / 91
## Progress: 39 / 91
## Progress: 40 / 91
## Progress: 41 / 91
## Progress: 42 / 91
## Progress: 43 / 91
## Progress: 44 / 91
## Progress: 45 / 91
## Progress: 46 / 91
## Progress: 47 / 91
## Progress: 48 / 91
## Progress: 49 / 91
## Progress: 50 / 91
## Progress: 51 / 91
## Progress: 52 / 91
## Progress: 53 / 91
## Progress: 54 / 91
## Progress: 55 / 91
## Progress: 56 / 91
## Progress: 57 / 91
## Progress: 58 / 91
## Progress: 59 / 91
## Progress: 60 / 91
## Progress: 61 / 91
## Progress: 62 / 91
## Progress: 63 / 91
## Progress: 64 / 91
## Progress: 65 / 91
## Progress: 66 / 91
## Progress: 67 / 91
## Progress: 68 / 91
## Progress: 69 / 91
## Progress: 70 / 91
## Progress: 71 / 91
## Progress: 72 / 91
## Progress: 73 / 91
## Progress: 74 / 91
## Progress: 75 / 91
## Progress: 76 / 91
## Progress: 77 / 91
## Progress: 78 / 91
## Progress: 79 / 91
## Progress: 80 / 91
## Progress: 81 / 91
## Progress: 82 / 91
## Progress: 83 / 91
## Progress: 84 / 91
## Progress: 85 / 91
## Progress: 86 / 91
## Progress: 87 / 91
## Progress: 88 / 91
## Progress: 89 / 91
## Progress: 90 / 91
## Progress: 91 / 91
summary(reliability)
## RESULT OBJECT
## Model Type
## [1] "lavaan"
## ========= Fit Indices Cutoffs ============
## N chisq aic bic rmsea cfi tli srmr
## 1 500 27.4 12873 12955 0.023 0.995 0.992 0.026
## 2 1625 27.3 41804 41895 0.019 0.996 0.994 0.022
## 3 2750 27.3 70736 70836 0.015 0.997 0.996 0.018
## 4 3875 27.3 99667 99776 0.012 0.998 0.998 0.014
## 5 5000 27.2 128599 128716 0.008 1.000 0.999 0.010
## ========= Parameter Estimates and Standard Errors ============
## Estimate Average Estimate SD Average SE Power (Not equal 0) Std Est Std Est SD Std Ave SE Average Param Average Bias
## HEX_HOH_SIN=~HEX_HOH_SIN_02 1.004 0.044 0.044 1.000 0.669 0.019 0.017 0.9 0.104
## HEX_HOH_SIN=~HEX_HOH_SIN_03 0.998 0.050 0.043 1.000 0.667 0.017 0.017 0.9 0.098
## HEX_HOH_SIN=~HEX_HOH_SIN_04 1.005 0.049 0.044 1.000 0.671 0.017 0.017 0.9 0.105
## NFP_PHY=~NFP_PHY_02 0.998 0.044 0.043 1.000 0.669 0.016 0.017 0.9 0.098
## NFP_PHY=~NFP_PHY_03 0.996 0.047 0.043 1.000 0.668 0.016 0.017 0.9 0.096
## NFP_PHY=~NFP_PHY_04 0.999 0.048 0.043 1.000 0.669 0.020 0.017 0.9 0.099
## HEX_HOH_SIN_01~~HEX_HOH_SIN_01 1.005 0.045 0.041 1.000 0.555 0.024 0.022 1.0 0.005
## HEX_HOH_SIN_02~~HEX_HOH_SIN_02 1.001 0.043 0.041 1.000 0.552 0.025 0.022 1.0 0.001
## HEX_HOH_SIN_03~~HEX_HOH_SIN_03 0.998 0.040 0.041 1.000 0.555 0.023 0.022 1.0 -0.002
## HEX_HOH_SIN_04~~HEX_HOH_SIN_04 0.993 0.035 0.041 1.000 0.550 0.023 0.022 1.0 -0.007
## NFP_PHY_01~~NFP_PHY_01 1.002 0.046 0.041 1.000 0.552 0.022 0.022 1.0 0.002
## NFP_PHY_02~~NFP_PHY_02 0.996 0.046 0.041 1.000 0.552 0.021 0.022 1.0 -0.004
## NFP_PHY_03~~NFP_PHY_03 0.998 0.037 0.041 1.000 0.554 0.021 0.022 1.0 -0.002
## NFP_PHY_04~~NFP_PHY_04 0.999 0.043 0.041 1.000 0.552 0.026 0.022 1.0 -0.001
## HEX_HOH_SIN~~HEX_HOH_SIN 0.807 0.057 0.054 1.000 1.000 0.000 0.000 1.0 -0.193
## NFP_PHY~~NFP_PHY 0.814 0.051 0.054 1.000 1.000 0.000 0.000 1.0 -0.186
## HEX_HOH_SIN~~NFP_PHY 0.083 0.025 0.023 0.934 0.102 0.031 0.028 0.1 -0.017
## Coverage r_coef.n r_se.n
## HEX_HOH_SIN=~HEX_HOH_SIN_02 0.242 -0.150 -0.888
## HEX_HOH_SIN=~HEX_HOH_SIN_03 0.396 -0.007 -0.874
## HEX_HOH_SIN=~HEX_HOH_SIN_04 0.231 -0.141 -0.874
## NFP_PHY=~NFP_PHY_02 0.385 0.104 -0.877
## NFP_PHY=~NFP_PHY_03 0.352 0.041 -0.862
## NFP_PHY=~NFP_PHY_04 0.275 0.074 -0.879
## HEX_HOH_SIN_01~~HEX_HOH_SIN_01 0.912 -0.064 -0.915
## HEX_HOH_SIN_02~~HEX_HOH_SIN_02 0.956 -0.011 -0.912
## HEX_HOH_SIN_03~~HEX_HOH_SIN_03 0.978 0.186 -0.912
## HEX_HOH_SIN_04~~HEX_HOH_SIN_04 0.967 -0.101 -0.908
## NFP_PHY_01~~NFP_PHY_01 0.923 0.141 -0.902
## NFP_PHY_02~~NFP_PHY_02 0.956 -0.005 -0.901
## NFP_PHY_03~~NFP_PHY_03 0.978 0.148 -0.895
## NFP_PHY_04~~NFP_PHY_04 0.967 0.084 -0.905
## HEX_HOH_SIN~~HEX_HOH_SIN 0.088 0.079 -0.906
## NFP_PHY~~NFP_PHY 0.132 0.003 -0.913
## HEX_HOH_SIN~~NFP_PHY 0.769 -0.266 -0.912
## ========= Correlation between Fit Indices ============
## chisq aic bic rmsea cfi tli srmr n
## chisq 1.000 -0.100 -0.100 0.819 -0.666 -0.810 0.468 -0.100
## aic -0.100 1.000 1.000 -0.328 0.371 0.054 -0.763 1.000
## bic -0.100 1.000 1.000 -0.328 0.371 0.054 -0.763 1.000
## rmsea 0.819 -0.328 -0.328 1.000 -0.934 -0.849 0.671 -0.328
## cfi -0.666 0.371 0.371 -0.934 1.000 0.819 -0.685 0.371
## tli -0.810 0.054 0.054 -0.849 0.819 1.000 -0.476 0.054
## srmr 0.468 -0.763 -0.763 0.671 -0.685 -0.476 1.000 -0.763
## n -0.100 1.000 1.000 -0.328 0.371 0.054 -0.763 1.000
## ================== Replications =====================
## Number of replications = 91
## Number of converged replications = 91
## 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. Nonpositive-definite latent or observed (residual) covariance matrix
## (e.g., Heywood case or linear dependency) = 0
## NOTE: The sample size is varying.
power_tab <- getPower(reliability)
power_80 <- findPower(power_tab, "N", 0.90)
A power of 80% would imply collecting 1501 participants.
save.image("data/workspace_1.RData")