I am currently working on sample size calculation via R package 'simsem' for a CFA-based questionnaire validation project. To emphasize, this is a social science research.
Hence, Total of 3 Latent and 10 Measured Variables.
All indicator / measured variables are expected to positively estimate unto their respective latent variables.
In terms of conceptual framework, you may look at the attached file below for clarification.
I will run through my attempt using an example broken down into components as a template from this link and also provide some questions for those I have no idea how to deal with :
https://rdrr.io/cran/simsem/man/continuousPower.html
Full Example
# Specify Sample Size by n
loading <- matrix(0, 6, 1)
loading[1:6, 1] <- NA
LY <- bind(loading, 0.7)
RPS <- binds(diag(1))
RTE <- binds(diag(6))
CFA.Model <- model(LY = LY, RPS = RPS, RTE = RTE, modelType="CFA")
dat <- generate(CFA.Model, 50)
out <- analyze(CFA.Model, dat)
# Specify both continuous sample size and percent missing completely at random.
# Note that more fine-grained values of n and pmMCAR is needed, e.g., n=seq(50, 500, 1)
# and pmMCAR=seq(0, 0.2, 0.01)
Output <- sim(NULL, CFA.Model, n=seq(100, 200, 20), pmMCAR=c(0, 0.1, 0.2))
summary(Output)
# Find the power of all combinations of different sample size and percent MCAR missing
Cpow <- continuousPower(Output, contN = TRUE, contMCAR = TRUE)
Cpow
# Find the power of parameter estimates when sample size is 200 and percent MCAR missing is 0.3
Cpow2 <- continuousPower(Output, contN = TRUE, contMCAR = TRUE, pred=list(N = 200, pmMCAR = 0.3))
Cpow2
Example 1#
# Specify Sample Size by n
loading <- matrix(0, 6, 1)
loading[1:6, 1] <- NA
My Coding 1#
loading <- matrix(0, 10, 3)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:10, 3] <- NA
Question (1)
What does NA indicates?
Question (2)
What about covariance?
I found one simulation that specify it around:
#Specify latent variances and covariances
latent.cor <- matrix(NA, 2, 2)
diag(latent.cor) <- 1
RPH <- symMatrix(latent.cor, 0.1)
#Specify measurement errors
error.cor <- matrix(0, 6, 6)
diag(error.cor) <- 1
RTD <- symMatrix(error.cor)
Question (3)
How do I identify and apply relevant matrix and diag settings?
Example 2#
LY <- bind(loading, 0.7)
RPS <- binds(diag(1))
RTE <- binds(diag(6))
My Coding 2#
I have no idea how to deal with this.
Example 3#
CFA.Model <- model(LY = LY, RPS = RPS, RTE = RTE, modelType="CFA")
dat <- generate(CFA.Model, 50)
out <- analyze(CFA.Model, dat)
My Coding 3#
CFA.Model <- model(LY=LY, RPS=RPS, RTE=RTE, modelType="CFA")
dat <- generate(CFA.Model, 50)
out <- analyze(CFA.Model, dat)
Question (4)
For
"dat <- generate(CFA.Model, 50)"
The 50 above is the sample size that I want to simulate for power analysis.
Is this interpretation correct?
If I am correct, should 50 be the default number? or should there be some condition or assumptions to look for?
Example 4#
# Specify both continuous sample size and percent missing completely at random.
# Note that more fine-grained values of n and pmMCAR is needed, e.g., n=seq(50, 500, 1)
# and pmMCAR=seq(0, 0.2, 0.01)
Output <- sim(NULL, CFA.Model, n=seq(100, 200, 20), pmMCAR=c(0, 0.1, 0.2))
summary(Output)
My Coding 4#
Output <- sim(NULL, CFA.Model, n=seq(50, 500, 1), pmMCAR=c(0, 0.1, 0.2))
summary(Output)
Example 5#
# Find the power of all combinations of different sample size and percent MCAR missing
Cpow <- continuousPower(Output, contN = TRUE, contMCAR = TRUE)
Cpow
My Coding 5#
Cpow <- continuousPower(Output, contN = TRUE, contMCAR = TRUE)
Cpow
Example 6# # Find the power of parameter estimates when sample size is 200 and percent MCAR missing is 0.3Cpow2 <- continuousPower(Output, contN = TRUE, contMCAR = TRUE, pred=list(N = 200, pmMCAR = 0.3))Cpow2