Last updated: 2020-03-31

Checks: 6 1

Knit directory: mcfa-para-est/

This reproducible R Markdown analysis was created with workflowr (version 1.5.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20190614) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/compiled_para_results.txt
    Ignored:    data/results_bias_est.csv
    Ignored:    manuscript/
    Ignored:    output/fact-cov-converge-largeN.pdf
    Ignored:    output/fact-cov-converge-medN.pdf
    Ignored:    output/fact-cov-converge-smallN.pdf
    Ignored:    output/loading-converge-largeN.pdf
    Ignored:    output/loading-converge-medN.pdf
    Ignored:    output/loading-converge-smallN.pdf
    Ignored:    sera-presentation/

Untracked files:
    Untracked:  analysis/figure/
    Untracked:  analysis/ml-cfa-parameter-bias-factor-loadings.Rmd
    Untracked:  analysis/ml-cfa-parameter-bias-level1-factor-covariances.Rmd
    Untracked:  analysis/ml-cfa-parameter-bias-level2-factor-covariances.Rmd
    Untracked:  analysis/ml-cfa-parameter-bias-level2-factor-variances.Rmd
    Untracked:  analysis/ml-cfa-parameter-bias-overview.Rmd

Unstaged changes:
    Modified:   .gitignore
    Deleted:    analysis/ml-cfa-parameter-bias-RB.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


rm(list=ls())
source(paste0(getwd(),"/code/load_packages.R"))
#source(paste0(getwd(),"/code/get_data.R"))
sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] xtable_1.8-4          kableExtra_1.1.0      MplusAutomation_0.7-3
 [4] data.table_1.12.6     patchwork_1.0.0       forcats_0.4.0        
 [7] stringr_1.4.0         dplyr_0.8.3           purrr_0.3.3          
[10] readr_1.3.1           tidyr_1.0.0           tibble_2.1.3         
[13] ggplot2_3.2.1         tidyverse_1.3.0      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3        lubridate_1.7.4   lattice_0.20-38   assertthat_0.2.1 
 [5] zeallot_0.1.0     rprojroot_1.3-2   digest_0.6.23     R6_2.4.1         
 [9] cellranger_1.1.0  plyr_1.8.4        backports_1.1.5   reprex_0.3.0     
[13] evaluate_0.14     coda_0.19-3       httr_1.4.1        pillar_1.4.2     
[17] rlang_0.4.2       lazyeval_0.2.2    readxl_1.3.1      rstudioapi_0.10  
[21] texreg_1.36.23    rmarkdown_1.18    gsubfn_0.7        proto_1.0.0      
[25] webshot_0.5.2     pander_0.6.3      munsell_0.5.0     broom_0.5.2      
[29] compiler_3.6.1    httpuv_1.5.2      modelr_0.1.5      xfun_0.11        
[33] pkgconfig_2.0.3   htmltools_0.4.0   tidyselect_0.2.5  workflowr_1.5.0  
[37] viridisLite_0.3.0 crayon_1.3.4      dbplyr_1.4.2      withr_2.1.2      
[41] later_1.0.0       grid_3.6.1        nlme_3.1-140      jsonlite_1.6     
[45] gtable_0.3.0      lifecycle_0.1.0   DBI_1.0.0         git2r_0.26.1     
[49] magrittr_1.5      scales_1.1.0      cli_1.1.0         stringi_1.4.3    
[53] fs_1.3.1          promises_1.1.0    xml2_1.2.2        generics_0.0.2   
[57] vctrs_0.2.0       boot_1.3-22       tools_3.6.1       glue_1.3.1       
[61] hms_0.5.2         parallel_3.6.1    yaml_2.2.0        colorspace_1.4-1 
[65] rvest_0.3.5       knitr_1.26        haven_2.2.0      
# general options
theme_set(theme_bw())
options(digits=3)
# set up vectors of variable names
pvec <- c(paste0('lambda1',1:6), paste0('lambda2',6:10), 'psiW12','psiB1', 'psiB2', 'psiB12', paste0('thetaB',1:10), 'icc_lv1_est', 'icc_lv2_est', paste0('icc_ov',1:10,'_est'))
# stored "true" values of parameters by each condition
ptvec <- c(rep('lambdaT',11), 'psiW12T', 'psiB1T', 'psiB2T', 'psiB12T', rep("thetaBT", 10), rep('icc_lv',2), rep('icc_ov',10))

result <- read_csv(paste0(w.d, "/data/results_bias_est.csv"))
Parsed with column specification:
cols(
  N1 = col_double(),
  N2 = col_double(),
  ICC_LV = col_double(),
  ICC_OV = col_double(),
  Variable = col_character(),
  Estimator = col_character(),
  TrueValue = col_double(),
  RB = col_double(),
  RMSE = col_double(),
  Bias = col_double(),
  SampVar = col_double(),
  muRE = col_double(),
  mwRE = col_double(),
  uwRE = col_double(),
  nRep = col_double(),
  estMean = col_double(),
  estSD = col_double()
)
# Set conditions levels as categorical values
result <- result %>%
  mutate(N1 = factor(N1, c("5", "10", "30")),
         N2 = factor(N2, c("30", "50", "100", "200")),
         ICC_OV = factor(ICC_OV, c("0.1","0.3", "0.5")),
         ICC_LV = factor(ICC_LV, c("0.1", "0.5")),
         wi = nRep/500)

Summarizing Results

First, we will plot estimates (botxplots) to show how these estimates changed across conditions. To summarize the results we will average over the parameters that only differ y indices. Meaning we will describe the “average factor loading bias” by reporting the average bias for factor loadings. Additionally, different conditions resultedin different “sample sizes.” By this we mean the number of uses replications. The different number of cases per condition was accounted for by creating a “weight” variable for each row of the result object. This meant that conditions that had more usable replications counted more towards to averages reported (or count as much as if we averaged over the individual replications).

*Click here for more details

Level-1 Factor Covariance

sdat <- filter(result, Variable %in% c("psiW12"))

TRUEVALUE <- unique(sdat$TrueValue)

p1 <- ggplot(sdat, aes(y=estMean))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance")

p2 <- ggplot(sdat, aes(y=estSD))+
  geom_boxplot()+
  labs(y="SD of Level-1 Factor Covariance")

p3 <- ggplot(sdat, aes(y=RB))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias")

p4 <- ggplot(sdat, aes(y=RMSE))+
  geom_boxplot()+
  labs(y="Root Mean Square Error")

p5 <- ggplot(sdat, aes(y=Bias))+
  geom_boxplot()+
  labs(y="Sqaured Bias")

p6 <- ggplot(sdat, aes(y=SampVar))+
  geom_boxplot()+
  labs(y="Sampling Variance of Estimates")


p <- (p1 + p2 + p3)/(p4 + p5 + p6) + 
  plot_annotation(title="Summarizing bias indices of LEVEL-1 FACTOR COVARIANCE")
p

Single Condition Breakdown

Estimation Method

ggplot(sdat, aes(y=estMean))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance",
       title="LEVEL-1 FACTOR COVARIANCE by Estimation Method",
       subtitle="Parameter Estimates")+
  facet_wrap(.~Estimator)

ggplot(sdat, aes(y=estSD))+
  geom_boxplot()+
  labs(y="SD of Level-1 Factor Covariances",
       title="LEVEL-1 FACTOR COVARIANCE by Estimation Method",
       subtitle="Standard Deviation of Estimates")+
  facet_wrap(.~Estimator)

ggplot(sdat, aes(y=RB))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias",
       title="LEVEL-1 FACTOR COVARIANCE by Estimation Method",
       subtitle="Relative Bias of Estimates")+
  facet_wrap(.~Estimator)

ggplot(sdat, aes(y=RMSE))+
  geom_boxplot()+
  labs(y="Root Mean Square Error",
       title="LEVEL-1 FACTOR COVARIANCE by Estimation Method",
       subtitle="Root Mean Square Error of Estimates")+
  facet_wrap(.~Estimator)

ggplot(sdat, aes(y=Bias))+
  geom_boxplot()+
  labs(y="Sqaured Bias",
       title="LEVEL-1 FACTOR COVARIANCE by Estimation Method",
       subtitle="Squared Bias of Estiamtes")+
  facet_wrap(.~Estimator)

ggplot(sdat, aes(y=SampVar))+
  geom_boxplot()+
  labs(y="Sampling Variance",
       title="LEVEL-1 FACTOR COVARIANCE by Estimation Method",
       subtitle="Sampling Variance of Estimates")+
  facet_wrap(.~Estimator)

c <- sdat %>%
  group_by(Estimator) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi),
            Bias = weighted.mean(Bias, wi),
            SampVar =weighted.mean(SampVar, wi))

kable(c, format='html', digits=3,
      caption="Summary Indices of LEVEL-1 FACTOR COVARIANCE by Estimation Method") %>%
  kable_styling(full_width = T)
Summary Indices of LEVEL-1 FACTOR COVARIANCE by Estimation Method
Estimator est RB RMSE Bias SampVar
MLR 0.301 0.186 0.006 0 0.006
ULSMV 0.301 0.246 0.007 0 0.007
WLSMV 0.305 1.515 0.005 0 0.005

Level-2 Sample Size

ggplot(sdat, aes(y=estMean))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance",
       title="LEVEL-1 FACTOR COVARIANCE by Level-2 Sample Size",
       subtitle="Parameter Estimates")+
  facet_wrap(.~N2)

ggplot(sdat, aes(y=estSD))+
  geom_boxplot()+
  labs(y="SD of Level-1 Factor Covariances",
       title="LEVEL-1 FACTOR COVARIANCE by Level-2 Sample Size",
       subtitle="Standard Deviation of Parameter Estimates")+
  facet_wrap(.~N2)

ggplot(sdat, aes(y=RB))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias",
       title="LEVEL-1 FACTOR COVARIANCE by Level-2 Sample Size",
       subtitle="Relative Bias Parameter Estimates")+
  facet_wrap(.~N2)

ggplot(sdat, aes(y=RMSE))+
  geom_boxplot()+
  labs(y="Root Mean Square Error",
       title="LEVEL-1 FACTOR COVARIANCE by Level-2 Sample Size",
       subtitle="Root Mean Square Error")+
  facet_wrap(.~N2)

ggplot(sdat, aes(y=Bias))+
  geom_boxplot()+
  labs(y="Sqaured Bias",
       title="LEVEL-1 FACTOR COVARIANCE by Level-2 Sample Size",
       subtitle="Squared Bias of Parameter Estimates")+
  facet_wrap(.~N2)

ggplot(sdat, aes(y=SampVar))+
  geom_boxplot()+
  labs(y="Sampling Variance of Estimates",
       title="LEVEL-1 FACTOR COVARIANCE by Level-2 Sample Size",
       subtitle="Sampling Variance of Parameter Estimates")+
  facet_wrap(.~N2)

c <- sdat %>%
  group_by(N2) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi),
            Bias = weighted.mean(Bias, wi),
            SampVar =weighted.mean(SampVar, wi))

kable(c, format='html', digits=3, 
      caption="Summary Indices of LEVEL-1 FACTOR COVARIANCE by Level-2 Sample Size") %>%
  kable_styling(full_width = T)
Summary Indices of LEVEL-1 FACTOR COVARIANCE by Level-2 Sample Size
N2 est RB RMSE Bias SampVar
30 0.303 1.032 0.014 0 0.014
50 0.303 0.886 0.008 0 0.008
100 0.302 0.556 0.004 0 0.004
200 0.301 0.209 0.002 0 0.002

Level-1 Sample Size

ggplot(sdat, aes(y=estMean))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance",
       title="LEVEL-1 FACTOR COVARIANCE by Level-1",
       subtitle="Parameter Estimates")+
  facet_wrap(.~N1)

ggplot(sdat, aes(y=estSD))+
  geom_boxplot()+
  labs(y="SD of Level-1 Factor Covariances",
       title="LEVEL-1 FACTOR COVARIANCE by Level-1 Sample Size",
       subtitle="Standard Deviation of Parameter Estimates")+
  facet_wrap(.~N1)

ggplot(sdat, aes(y=RB))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias",
       title="LEVEL-1 FACTOR COVARIANCE by Level-1 Sample Size",
       subtitle="Relative Bias of Parameter Estimates")+
  facet_wrap(.~N1)

ggplot(sdat, aes(y=RMSE))+
  geom_boxplot()+
  labs(y="Root Mean Square Error",
       title="LEVEL-1 FACTOR COVARIANCE by Level-1 Sample Size",
       subtitle="Root Mean Square Error")+
  facet_wrap(.~N1)

ggplot(sdat, aes(y=Bias))+
  geom_boxplot()+
  labs(y="Sqaured Bias",
       title="LEVEL-1 FACTOR COVARIANCE by Level-1 Sample Size",
       subtitle="Squared Bias of Parameter Estimates")+
  facet_wrap(.~N1)

ggplot(sdat, aes(y=SampVar))+
  geom_boxplot()+
  labs(y="Sampling Variance of Estimates",
       title="LEVEL-1 FACTOR COVARIANCE by Level-1 Sample Size",
       subtitle="Sampling Variance of Parameter Estimates")+
  facet_wrap(.~N1)

c <- sdat %>%
  group_by(N1) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi),
            Bias = weighted.mean(Bias, wi),
            SampVar =weighted.mean(SampVar, wi))

kable(c, format='html', digits=3,
      caption="Summary Indices of LEVEL-1 FACTOR COVARIANCE  by Level-1 Sample Size") %>%
  kable_styling(full_width = T)
Summary Indices of LEVEL-1 FACTOR COVARIANCE by Level-1 Sample Size
N1 est RB RMSE Bias SampVar
5 0.303 1.050 0.013 0 0.012
10 0.302 0.682 0.005 0 0.005
30 0.301 0.247 0.002 0 0.002

ICC Observed Variables

ggplot(sdat, aes(y=estMean))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Observed Variables",
       subtitle="Parameter Estimates")+
  facet_wrap(.~ICC_OV)

ggplot(sdat, aes(y=estSD))+
  geom_boxplot()+
  labs(y="SD of Level-1 Factor Covariances",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Observed Variables",
       subtitle="Standard Deviation of Parameter Estimates")+
  facet_wrap(.~ICC_OV)

ggplot(sdat, aes(y=RB))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Observed Variables",
       subtitle="Relative Bias of Parameter Estimates")+
  facet_wrap(.~ICC_OV)

ggplot(sdat, aes(y=RMSE))+
  geom_boxplot()+
  labs(y="Root Mean Square Error",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Observed Variables",
       subtitle="Root Mean Square Error of Parameter Estimates")+
  facet_wrap(.~ICC_OV)

ggplot(sdat, aes(y=Bias))+
  geom_boxplot()+
  labs(y="Sqaured Bias",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Observed Variables",
       subtitle="Squared Bias of Parameter Estimates")+
  facet_wrap(.~ICC_OV)

ggplot(sdat, aes(y=SampVar))+
  geom_boxplot()+
  labs(y="Sampling Variance of Estimates",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Observed Variables",
       subtitle="Sampling Variance of Parameter Estimates")+
  facet_wrap(.~ICC_OV)

c <- sdat %>%
  group_by(ICC_OV) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi),
            Bias = weighted.mean(Bias, wi),
            SampVar =weighted.mean(SampVar, wi))

kable(c, format='html', digits=3, caption="Summary Indices of LEVEL-1 FACTOR COVARIANCE by ICC of Observed Variables") %>%
  kable_styling(full_width = T)
Summary Indices of LEVEL-1 FACTOR COVARIANCE by ICC of Observed Variables
ICC_OV est RB RMSE Bias SampVar
0.1 0.302 0.820 0.004 0 0.004
0.3 0.302 0.784 0.006 0 0.006
0.5 0.301 0.268 0.008 0 0.008

ICC Latent Variables

ggplot(sdat, aes(y=estMean))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Latent Variables",
       subtitle="Parameter Estimates")+
  facet_wrap(.~ICC_LV)

ggplot(sdat, aes(y=estSD))+
  geom_boxplot()+
  labs(y="SD of Level-1 Factor Covariances",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Latent Variables",
       subtitle="Standard Deviation of Parameter Estimates")+
  facet_wrap(.~ICC_LV)

ggplot(sdat, aes(y=RB))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Latent Variables",
       subtitle="Relative Bias of Parameter Estimates")+
  facet_wrap(.~ICC_LV)

ggplot(sdat, aes(y=RMSE))+
  geom_boxplot()+
  labs(y="Root Mean Square Error",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Latent Variables",
       subtitle="Root Mean Square Error of Parameter Estimates")+
  facet_wrap(.~ICC_LV)

ggplot(sdat, aes(y=Bias))+
  geom_boxplot()+
  labs(y="Sqaured Bias",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Latent Variables",
       subtitle="Squared Bias of Parameter Estimates")+
  facet_wrap(.~ICC_LV)

ggplot(sdat, aes(y=SampVar))+
  geom_boxplot()+
  labs(y="Sampling Variance of Estimates",
       title="LEVEL-1 FACTOR COVARIANCE by ICC of Latent Variables",
       subtitle="Sampling Variance of Parameter Estimates")+
  facet_wrap(.~ICC_LV)

c <- sdat %>%
  group_by(ICC_LV) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi),
            Bias = weighted.mean(Bias, wi),
            SampVar =weighted.mean(SampVar, wi))

kable(c, format='html', digits=3,
      caption="Summary Indices of LEVEL-1 FACTOR COVARIANCE by ICC of Latent Variables") %>%
  kable_styling(full_width = T)
Summary Indices of LEVEL-1 FACTOR COVARIANCE by ICC of Latent Variables
ICC_LV est RB RMSE Bias SampVar
0.1 0.304 1.407 0.005 0 0.005
0.5 0.300 -0.023 0.007 0 0.007

Loadings by Estimation Method and Sample Sizes

Estimation Method & Level-2 Sample Size

ggplot(sdat, aes(y=estMean))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance")+
  facet_grid(N2~Estimator)

ggplot(sdat, aes(y=RB))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias")+
  facet_grid(N2~Estimator)

ggplot(sdat, aes(y=RMSE))+
  geom_boxplot()+
  labs(y="Root Mean Square Error")+
  facet_grid(N2~Estimator)

c <- sdat %>%
  group_by(Estimator, N2) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi),
            Bias = weighted.mean(Bias, wi),
            SampVar =weighted.mean(SampVar, wi))

c1 <- cbind(c[ c$Estimator == 'MLR', c( 'N2', 'est', 'RB', 'RMSE')], 
           c[ c$Estimator == 'ULSMV', c('est', 'RB', 'RMSE')], 
           c[ c$Estimator == 'WLSMV', c('est', 'RB', 'RMSE')])
colnames(c1) <- c('N2',  rep(c('est', 'RB', 'RMSE'), 3))

kable(c1, format='html', digits=3, row.names = F) %>%
  kable_styling(full_width = T) %>%
  add_header_above(c(' '=1, 'MLR'=3, 'ULSMV'=3, 'WLSMV'=3))
MLR
ULSMV
WLSMV
N2 est RB RMSE est RB RMSE est RB RMSE
30 0.300 0.155 0.013 0.301 0.281 0.016 0.309 3.058 0.012
50 0.301 0.452 0.007 0.301 0.354 0.010 0.306 1.994 0.007
100 0.301 0.218 0.004 0.301 0.213 0.005 0.304 1.292 0.004
200 0.300 -0.040 0.002 0.301 0.173 0.002 0.302 0.504 0.002

Estimation Method & Level-1 Sample Size

ggplot(sdat, aes(y=estMean))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance")+
  facet_grid(N1~Estimator)

ggplot(sdat, aes(y=RB))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias")+
  facet_grid(N1~Estimator)

ggplot(sdat, aes(y=RMSE))+
  geom_boxplot()+
  labs(y="Root Mean Square Error")+
  facet_grid(N1~Estimator)

c <- sdat %>%
  group_by(Estimator, N1) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi),
            Bias = weighted.mean(Bias, wi),
            SampVar =weighted.mean(SampVar, wi))

c1 <- cbind(c[ c$Estimator == 'MLR', c( 'N1', 'est', 'RB', 'RMSE')], 
           c[ c$Estimator == 'ULSMV', c('est', 'RB', 'RMSE')], 
           c[ c$Estimator == 'WLSMV', c('est', 'RB', 'RMSE')])
colnames(c1) <- c('N1',  rep(c('est', 'RB', 'RMSE'), 3))

kable(c1, format='html', digits=3, row.names = F) %>%
  kable_styling(full_width = T) %>%
  add_header_above(c(' '=1, 'MLR'=3, 'ULSMV'=3, 'WLSMV'=3))
MLR
ULSMV
WLSMV
N1 est RB RMSE est RB RMSE est RB RMSE
5 0.301 0.326 0.012 0.301 0.366 0.015 0.308 2.71 0.011
10 0.300 0.165 0.005 0.301 0.450 0.007 0.305 1.52 0.005
30 0.300 0.092 0.002 0.300 -0.016 0.003 0.302 0.69 0.002

Estimation Method, Level-2 Sample Size & Level-1 Sample Size

ggplot(sdat, aes(y=estMean,x=N1, group=N1))+
  geom_boxplot()+
  geom_hline(yintercept = TRUEVALUE, color="red")+
  labs(y="Average Level-1 Factor Covariance")+
  facet_grid(N2~Estimator)

ggplot(sdat, aes(y=RB,x=N1, group=N1))+
  geom_boxplot()+
  geom_hline(yintercept=-10, color="red", linetype="dashed")+
  geom_hline(yintercept=10, color="red", linetype="dashed")+
  labs(y="Relative Bias")+
  facet_grid(N2~Estimator)

ggplot(sdat, aes(y=RMSE,x=N1, group=N1))+
  geom_boxplot()+
  labs(y="Root Mean Square Error")+
  facet_grid(N2~Estimator)

c <- sdat %>%
  group_by(Estimator, N2, N1) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi),
            Bias = weighted.mean(Bias, wi),
            SampVar =weighted.mean(SampVar, wi))

c1 <- cbind(c[ c$Estimator == 'MLR', c( 'N2','N1', 'est', 'RB', 'RMSE')], 
           c[ c$Estimator == 'ULSMV', c('est', 'RB', 'RMSE')], 
           c[ c$Estimator == 'WLSMV', c('est', 'RB', 'RMSE')])
colnames(c1) <- c('N2','N1',  rep(c('est', 'RB', 'RMSE'), 3))

kable(c1, format='html', digits=3, row.names = F) %>%
  kable_styling(full_width = T) %>%
  add_header_above(c(' '=2, 'MLR'=3, 'ULSMV'=3, 'WLSMV'=3))
MLR
ULSMV
WLSMV
N2 N1 est RB RMSE est RB RMSE est RB RMSE
30 5 0.302 0.530 0.028 0.301 0.355 0.038 0.316 5.268 0.030
30 10 0.298 -0.628 0.011 0.301 0.448 0.015 0.309 2.842 0.011
30 30 0.302 0.538 0.003 0.300 0.117 0.006 0.306 2.077 0.004
50 5 0.302 0.567 0.015 0.300 0.047 0.021 0.311 3.679 0.016
50 10 0.302 0.705 0.006 0.301 0.454 0.009 0.307 2.381 0.006
50 30 0.300 0.142 0.002 0.301 0.459 0.003 0.302 0.716 0.002
100 5 0.300 0.096 0.007 0.300 0.140 0.010 0.307 2.462 0.007
100 10 0.301 0.461 0.003 0.302 0.657 0.004 0.304 1.197 0.003
100 30 0.300 0.083 0.001 0.300 -0.145 0.002 0.302 0.523 0.001
200 5 0.301 0.224 0.004 0.302 0.744 0.004 0.304 1.283 0.004
200 10 0.300 0.000 0.002 0.301 0.260 0.002 0.301 0.483 0.002
200 30 0.299 -0.331 0.000 0.299 -0.426 0.001 0.300 -0.156 0.000

Relative Efficiency by Sample Sizes

c <- sdat %>%
  group_by(Estimator, N2, N1) %>%
  summarise(mu = weighted.mean(muRE, wi),
            mw = weighted.mean(mwRE, wi),
            uw = weighted.mean(uwRE, wi))

c1 <- cbind(c[ c$Estimator == 'MLR', c( 'N2','N1', 'mu', 'mw', 'uw')])
colnames(c1) <- c('N2','N1',c('MLR/ULSMV', 'MLR/WLSMV', 'ULSMV/WLSMV'))

kable(c1, format='html', digits=3, row.names = F) %>%
  kable_styling(full_width = T)
N2 N1 MLR/ULSMV MLR/WLSMV ULSMV/WLSMV
30 5 1.806 1.829 1.13
30 10 1.082 1.281 1.19
30 30 0.925 1.161 1.31
50 5 1.149 1.331 1.20
50 10 0.975 1.146 1.21
50 30 0.940 1.037 1.13
100 5 1.039 1.153 1.14
100 10 0.963 1.071 1.14
100 30 0.865 1.011 1.31
200 5 0.974 1.045 1.08
200 10 0.956 1.014 1.07
200 30 0.893 0.998 1.27

Manuscript Tables

c <- sdat %>%
  group_by(Estimator, N2, N1) %>%
  summarise(est = weighted.mean(estMean, wi),
            RB = weighted.mean(RB, wi),
            RMSE = weighted.mean(RMSE, wi))

c1 <- cbind(c[ c$Estimator == 'MLR', c( 'N2','N1', 'est', 'RB', 'RMSE')], 
           c[ c$Estimator == 'ULSMV', c('est', 'RB', 'RMSE')], 
           c[ c$Estimator == 'WLSMV', c('est', 'RB', 'RMSE')])
colnames(c1) <- c('N2','N1',  rep(c('est', 'RB', 'RMSE'), 3))

kable(c1, format='html', digits=3, row.names = F) %>%
  kable_styling(full_width = T) %>%
  add_header_above(c(' '=2, 'MLR'=3, 'ULSMV'=3, 'WLSMV'=3))
MLR
ULSMV
WLSMV
N2 N1 est RB RMSE est RB RMSE est RB RMSE
30 5 0.302 0.530 0.028 0.301 0.355 0.038 0.316 5.268 0.030
30 10 0.298 -0.628 0.011 0.301 0.448 0.015 0.309 2.842 0.011
30 30 0.302 0.538 0.003 0.300 0.117 0.006 0.306 2.077 0.004
50 5 0.302 0.567 0.015 0.300 0.047 0.021 0.311 3.679 0.016
50 10 0.302 0.705 0.006 0.301 0.454 0.009 0.307 2.381 0.006
50 30 0.300 0.142 0.002 0.301 0.459 0.003 0.302 0.716 0.002
100 5 0.300 0.096 0.007 0.300 0.140 0.010 0.307 2.462 0.007
100 10 0.301 0.461 0.003 0.302 0.657 0.004 0.304 1.197 0.003
100 30 0.300 0.083 0.001 0.300 -0.145 0.002 0.302 0.523 0.001
200 5 0.301 0.224 0.004 0.302 0.744 0.004 0.304 1.283 0.004
200 10 0.300 0.000 0.002 0.301 0.260 0.002 0.301 0.483 0.002
200 30 0.299 -0.331 0.000 0.299 -0.426 0.001 0.300 -0.156 0.000
print(xtable(c1, digits = 3,align=c("l", "l","l", rep("r",9)),
             display=c("s", "d","d", rep("f",9)),
             caption="Mean Level-1 Factor Covariance, Relative Bias, and RMSE by Estimation Method",
             label="tb:fct"),
      booktabs = T, include.rownames = F,
      caption.placement = "top")
% latex table generated in R 3.6.1 by xtable 1.8-4 package
% Tue Mar 31 15:43:58 2020
\begin{table}[ht]
\centering
\caption{Mean Level-1 Factor Covariance, Relative Bias, and RMSE by Estimation Method} 
\label{tb:fct}
\begin{tabular}{llrrrrrrrrr}
  \toprule
N2 & N1 & est & RB & RMSE & est & RB & RMSE & est & RB & RMSE \\ 
  \midrule
30 & 5 & 0.302 & 0.530 & 0.028 & 0.301 & 0.355 & 0.038 & 0.316 & 5.268 & 0.030 \\ 
  30 & 10 & 0.298 & -0.628 & 0.011 & 0.301 & 0.448 & 0.015 & 0.309 & 2.842 & 0.011 \\ 
  30 & 30 & 0.302 & 0.538 & 0.003 & 0.300 & 0.117 & 0.006 & 0.306 & 2.077 & 0.004 \\ 
  50 & 5 & 0.302 & 0.567 & 0.015 & 0.300 & 0.047 & 0.021 & 0.311 & 3.679 & 0.016 \\ 
  50 & 10 & 0.302 & 0.705 & 0.006 & 0.301 & 0.454 & 0.009 & 0.307 & 2.381 & 0.006 \\ 
  50 & 30 & 0.300 & 0.142 & 0.002 & 0.301 & 0.459 & 0.003 & 0.302 & 0.716 & 0.002 \\ 
  100 & 5 & 0.300 & 0.096 & 0.007 & 0.300 & 0.140 & 0.010 & 0.307 & 2.462 & 0.007 \\ 
  100 & 10 & 0.301 & 0.461 & 0.003 & 0.302 & 0.657 & 0.004 & 0.304 & 1.197 & 0.003 \\ 
  100 & 30 & 0.300 & 0.083 & 0.001 & 0.300 & -0.145 & 0.002 & 0.302 & 0.523 & 0.001 \\ 
  200 & 5 & 0.301 & 0.224 & 0.004 & 0.302 & 0.744 & 0.004 & 0.304 & 1.283 & 0.004 \\ 
  200 & 10 & 0.300 & 0.000 & 0.002 & 0.301 & 0.260 & 0.002 & 0.301 & 0.483 & 0.002 \\ 
  200 & 30 & 0.299 & -0.331 & 0.000 & 0.299 & -0.426 & 0.001 & 0.300 & -0.156 & 0.000 \\ 
   \bottomrule
\end{tabular}
\end{table}

sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] xtable_1.8-4          kableExtra_1.1.0      MplusAutomation_0.7-3
 [4] data.table_1.12.6     patchwork_1.0.0       forcats_0.4.0        
 [7] stringr_1.4.0         dplyr_0.8.3           purrr_0.3.3          
[10] readr_1.3.1           tidyr_1.0.0           tibble_2.1.3         
[13] ggplot2_3.2.1         tidyverse_1.3.0      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3        lubridate_1.7.4   lattice_0.20-38   assertthat_0.2.1 
 [5] zeallot_0.1.0     rprojroot_1.3-2   digest_0.6.23     R6_2.4.1         
 [9] cellranger_1.1.0  plyr_1.8.4        backports_1.1.5   reprex_0.3.0     
[13] evaluate_0.14     coda_0.19-3       highr_0.8         httr_1.4.1       
[17] pillar_1.4.2      rlang_0.4.2       lazyeval_0.2.2    readxl_1.3.1     
[21] rstudioapi_0.10   texreg_1.36.23    rmarkdown_1.18    gsubfn_0.7       
[25] labeling_0.3      proto_1.0.0       webshot_0.5.2     pander_0.6.3     
[29] munsell_0.5.0     broom_0.5.2       compiler_3.6.1    httpuv_1.5.2     
[33] modelr_0.1.5      xfun_0.11         pkgconfig_2.0.3   htmltools_0.4.0  
[37] tidyselect_0.2.5  workflowr_1.5.0   viridisLite_0.3.0 crayon_1.3.4     
[41] dbplyr_1.4.2      withr_2.1.2       later_1.0.0       grid_3.6.1       
[45] nlme_3.1-140      jsonlite_1.6      gtable_0.3.0      lifecycle_0.1.0  
[49] DBI_1.0.0         git2r_0.26.1      magrittr_1.5      scales_1.1.0     
[53] cli_1.1.0         stringi_1.4.3     reshape2_1.4.3    farver_2.0.1     
[57] fs_1.3.1          promises_1.1.0    xml2_1.2.2        generics_0.0.2   
[61] vctrs_0.2.0       boot_1.3-22       tools_3.6.1       glue_1.3.1       
[65] hms_0.5.2         parallel_3.6.1    yaml_2.2.0        colorspace_1.4-1 
[69] rvest_0.3.5       knitr_1.26        haven_2.2.0