Last updated: 2020-05-27
Checks: 6 1
Knit directory: mcfa-para-est/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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 file has unstaged changes. 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 results in this page were generated with repository version eecb366. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
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: fig/
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: references/
Ignored: sera-presentation/
Untracked files:
Untracked: analysis/ml-cfa-parameter-convergence-correlation-pubfigure.Rmd
Untracked: analysis/ml-cfa-parameter-convergence-trace-plots-factor-loadings.Rmd
Unstaged changes:
Modified: analysis/index.Rmd
Modified: analysis/ml-cfa-parameter-convergence-correlation-factor-loadings.Rmd
Modified: code/load_packages.R
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.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/ml-cfa-parameter-convergence-correlation-factor-loadings.Rmd
) and HTML (docs/ml-cfa-parameter-convergence-correlation-factor-loadings.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | eecb366 | noah-padgett | 2020-05-06 | updated para recovery |
html | eecb366 | noah-padgett | 2020-05-06 | updated para recovery |
rm(list=ls())
source(paste0(getwd(),"/code/load_packages.R"))
source(paste0(getwd(),"/code/get_data.R"))
# subset to data with admissible replications
sim_results <- filter(sim_results, Converge==1 & Admissible==1)
On this page, we are investigating the correlation among parameter estimates between estimation methods. We do this by
# keep variables
keepVar <- c("Condition", "Replication", "ss_l1", "ss_l2", "icc_ov", "icc_lv", "Estimator", paste0("lambda", c(11:16, 26:29, 210)))
sim_res1 <- sim_results[, keepVar]
sim_res1 <- sim_res1%>%
pivot_longer(cols = starts_with("lambda"),
names_to = "lambda",
values_to = "est") %>%
pivot_wider(id_cols=c("Condition","Replication", "ss_l1", "ss_l2", "icc_ov", "icc_lv", "lambda"),
names_from = "Estimator",
values_from = "est")
cor.est <- sim_res1 %>%
group_by(ss_l1, ss_l2, icc_ov, icc_lv, lambda) %>%
summarise(
r_mlr_ulsmv = cor(MLR, ULSMV,use = "pairwise.complete"),
cprop_mlr_ulsmv = (1-(sum(is.na(MLR + ULSMV))/500)) ,
r_mlr_wlsmv = cor(MLR, WLSMV,use = "pairwise.complete"),
cprop_mlr_wlsmv = (1-(sum(is.na(MLR + WLSMV))/500)),
r_ulsmv_wlsmv = cor(ULSMV, WLSMV,use = "pairwise.complete"),
cprop_ulsmv_wlsmv = (1-(sum(is.na(ULSMV + WLSMV))/500))
)
a1 <- cor.est %>%
pivot_longer(cols= starts_with("r_"),
names_to= "Cor",
values_to = "Est") %>%
mutate(Cor = substring(Cor, 3))
a2 <- cor.est %>%
pivot_longer(cols= starts_with("cprop_"),
names_to= "Cor",
values_to = "Cprop")%>%
mutate(Cor = substring(Cor, 7))
cor.est <- left_join(a1[,c(1:5,9:10)], a2[,c(1:5,9:10)]) %>%
group_by(ss_l1, ss_l2, icc_ov, icc_lv, Cor)%>%
summarise(Est = mean(Est),
Cprop = mean(Cprop))
Joining, by = c("ss_l1", "ss_l2", "icc_ov", "icc_lv", "lambda", "Cor")
cor.est$Cor <- factor(cor.est$Cor,
levels=c("mlr_ulsmv", "mlr_wlsmv", "ulsmv_wlsmv"),
labels=c("cor(MLR, ULSMV)",
"cor(MLR, WLSMV)",
"cor(ULSMV, WLSMV)"),
ordered=T)
cor.est$C90 <- as.factor(ifelse(cor.est$Cprop >= 0.9, ">= 90%", "< 90%"))
cor.est$C95 <- as.factor(ifelse(cor.est$Cprop >= 0.95, ">= 95%", "< 95%"))
cols=c("< 90%"="#56B4E9", ">= 90%"="#CC79A7")
p <- ggplot(cor.est, aes(x=Cor, y=Est)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(data=filter(cor.est, C90=="< 90%"),
width=0.3, aes(x=Cor, y=Est, color="< 90%")) +
geom_jitter(data=filter(cor.est, C90==">= 90%"),
width=0.3, aes(x=Cor, y=Est, color=">= 90%")) +
lims(y=c(0,1))+
labs(y="Correlation",
x=NULL,
title="Correlation amoung Estimates: Factor Loadings")+
scale_color_manual(name="% Admissible", values=cols)+
theme_bw()+
theme(panel.grid = element_blank())
p
p <- ggplot(cor.est, aes(x=Cor, y=Est)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(data=filter(cor.est, C90=="< 90%"),
width=0.3, aes(x=Cor, y=Est, color="< 90%")) +
geom_jitter(data=filter(cor.est, C90==">= 90%"),
width=0.3, aes(x=Cor, y=Est, color=">= 90%")) +
lims(y=c(0,1))+
labs(y="Correlation",
x=NULL,
title="Correlation amoung Estimates: Factor Loadings",
subtitle = "Conditional on Level-1 Sample Size")+
scale_color_manual(name="% Admissible", values=cols)+
facet_wrap(.~ss_l1)+
theme_bw()+
theme(panel.grid = element_blank(),
axis.text.x = element_text(angle=90))
p
p <- ggplot(cor.est, aes(x=Cor, y=Est)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(data=filter(cor.est, C90=="< 90%"),
width=0.3, aes(x=Cor, y=Est, color="< 90%")) +
geom_jitter(data=filter(cor.est, C90==">= 90%"),
width=0.3, aes(x=Cor, y=Est, color=">= 90%")) +
lims(y=c(0,1))+
labs(y="Correlation",
x=NULL,
title="Correlation amoung Estimates: Factor Loadings",
subtitle = "Conditional on Level-2 Sample Size")+
scale_color_manual(name="% Admissible", values=cols)+
facet_wrap(.~ss_l2, nrow=1)+
theme_bw()+
theme(panel.grid = element_blank(),
axis.text.x = element_text(angle=90))
p
p <- ggplot(cor.est, aes(x=Cor, y=Est)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(data=filter(cor.est, C90=="< 90%"),
width=0.3, aes(x=Cor, y=Est, color="< 90%")) +
geom_jitter(data=filter(cor.est, C90==">= 90%"),
width=0.3, aes(x=Cor, y=Est, color=">= 90%")) +
lims(y=c(0,1))+
labs(y="Correlation",
x=NULL,
title="Correlation amoung Estimates: Factor Loadings",
subtitle = "Conditional on Observed Variable ICC")+
scale_color_manual(name="% Admissible", values=cols)+
facet_wrap(.~icc_ov)+
theme_bw()+
theme(panel.grid = element_blank(),
axis.text.x = element_text(angle=90))
p
p <- ggplot(cor.est, aes(x=Cor, y=Est)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(data=filter(cor.est, C90=="< 90%"),
width=0.3, aes(x=Cor, y=Est, color="< 90%")) +
geom_jitter(data=filter(cor.est, C90==">= 90%"),
width=0.3, aes(x=Cor, y=Est, color=">= 90%")) +
lims(y=c(0,1))+
labs(y="Correlation",
x=NULL,
title="Correlation amoung Estimates: Factor Loadings",
subtitle = "Conditional on Latent Variable ICC")+
scale_color_manual(name="% Admissible", values=cols)+
facet_wrap(.~icc_lv)+
theme_bw()+
theme(panel.grid = element_blank(),
axis.text.x = element_text(angle=90))
p
cols=c("< 90%"="#56B4E9", ">= 90%"="#CC79A7")
shps=c("< 90%"=16, ">= 90%"=17)
p <- ggplot(cor.est, aes(x=Cor, y=Est)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(data=filter(cor.est, C90=="< 90%"),
width=0.3, size=2, alpha=0.7,
aes(x=Cor, y=Est,
color="< 90%", shape="< 90%")) +
geom_jitter(data=filter(cor.est, C90==">= 90%"),
width=0.3, size=2, alpha=0.7,
aes(x=Cor, y=Est,
color=">= 90%", shape=">= 90%")) +
lims(y=c(0,1))+
labs(y="Correlation",
x=NULL)+
scale_color_manual(name="% Admissible", values=cols)+
scale_shape_manual(name="% Admissible", values=shps)+
theme_bw()+
theme(panel.grid = element_blank(),
legend.position = c(0.5,0.25),
legend.text = element_text(size=12),
legend.title = element_text(size=12),
axis.title.y = element_text(size=12),
axis.text.y = element_text(size=10),
axis.text.x = element_text(angle=20, hjust=1,
vjust = 1, size=12))
p
ggsave("fig/estimate_correlation_factor_loading.pdf",p, units="in", height=3.5, width=5)
sessionInfo()
R version 4.0.0 (2020-04-24)
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 cowplot_1.0.0
[4] MplusAutomation_0.7-3 data.table_1.12.8 patchwork_1.0.0
[7] forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5
[10] purrr_0.3.4 readr_1.3.1 tidyr_1.1.0
[13] tibble_3.0.1 ggplot2_3.3.0 tidyverse_1.3.0
[16] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] httr_1.4.1 jsonlite_1.6.1 viridisLite_0.3.0 gsubfn_0.7
[5] modelr_0.1.8 assertthat_0.2.1 pander_0.6.3 cellranger_1.1.0
[9] yaml_2.2.1 pillar_1.4.4 backports_1.1.6 lattice_0.20-41
[13] glue_1.4.1 digest_0.6.25 promises_1.1.0 rvest_0.3.5
[17] colorspace_1.4-1 htmltools_0.4.0 httpuv_1.5.2 plyr_1.8.6
[21] pkgconfig_2.0.3 broom_0.5.6 haven_2.3.0 scales_1.1.1
[25] webshot_0.5.2 whisker_0.4 later_1.0.0 git2r_0.27.1
[29] farver_2.0.3 generics_0.0.2 ellipsis_0.3.1 withr_2.2.0
[33] cli_2.0.2 proto_1.0.0 magrittr_1.5 crayon_1.3.4
[37] readxl_1.3.1 evaluate_0.14 fs_1.4.1 fansi_0.4.1
[41] nlme_3.1-147 xml2_1.3.2 tools_4.0.0 hms_0.5.3
[45] lifecycle_0.2.0 munsell_0.5.0 reprex_0.3.0 compiler_4.0.0
[49] rlang_0.4.6 grid_4.0.0 rstudioapi_0.11 texreg_1.36.23
[53] labeling_0.3 rmarkdown_2.1 boot_1.3-24 gtable_0.3.0
[57] DBI_1.1.0 R6_2.4.1 lubridate_1.7.8 knitr_1.28
[61] rprojroot_1.3-2 stringi_1.4.6 parallel_4.0.0 Rcpp_1.0.4.6
[65] vctrs_0.3.0 dbplyr_1.4.3 tidyselect_1.1.0 xfun_0.14
[69] coda_0.19-3
sessionInfo()
R version 4.0.0 (2020-04-24)
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 cowplot_1.0.0
[4] MplusAutomation_0.7-3 data.table_1.12.8 patchwork_1.0.0
[7] forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5
[10] purrr_0.3.4 readr_1.3.1 tidyr_1.1.0
[13] tibble_3.0.1 ggplot2_3.3.0 tidyverse_1.3.0
[16] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] httr_1.4.1 jsonlite_1.6.1 viridisLite_0.3.0 gsubfn_0.7
[5] modelr_0.1.8 assertthat_0.2.1 pander_0.6.3 cellranger_1.1.0
[9] yaml_2.2.1 pillar_1.4.4 backports_1.1.6 lattice_0.20-41
[13] glue_1.4.1 digest_0.6.25 promises_1.1.0 rvest_0.3.5
[17] colorspace_1.4-1 htmltools_0.4.0 httpuv_1.5.2 plyr_1.8.6
[21] pkgconfig_2.0.3 broom_0.5.6 haven_2.3.0 scales_1.1.1
[25] webshot_0.5.2 whisker_0.4 later_1.0.0 git2r_0.27.1
[29] farver_2.0.3 generics_0.0.2 ellipsis_0.3.1 withr_2.2.0
[33] cli_2.0.2 proto_1.0.0 magrittr_1.5 crayon_1.3.4
[37] readxl_1.3.1 evaluate_0.14 fs_1.4.1 fansi_0.4.1
[41] nlme_3.1-147 xml2_1.3.2 tools_4.0.0 hms_0.5.3
[45] lifecycle_0.2.0 munsell_0.5.0 reprex_0.3.0 compiler_4.0.0
[49] rlang_0.4.6 grid_4.0.0 rstudioapi_0.11 texreg_1.36.23
[53] labeling_0.3 rmarkdown_2.1 boot_1.3-24 gtable_0.3.0
[57] DBI_1.1.0 R6_2.4.1 lubridate_1.7.8 knitr_1.28
[61] rprojroot_1.3-2 stringi_1.4.6 parallel_4.0.0 Rcpp_1.0.4.6
[65] vctrs_0.3.0 dbplyr_1.4.3 tidyselect_1.1.0 xfun_0.14
[69] coda_0.19-3