-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain_code_part3.Rmd
60 lines (47 loc) · 2.19 KB
/
Main_code_part3.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
title: "Attitudes toward equality - part 3"
author: "Pamela Inostroza Fernández"
date: "December 2020"
output:
html_document:
keep_md: true
toc: TRUE
toc_depth: 1
toc_float:
collapsed: true
number_sections: true
theme: united
highlight: tango
editor_options:
chunk_output_type: console
---
This report gives an insight of findings using Latent Class Analysis in R and Mplus software. The first was implemented using poLCA package, and the second running and extracting results with MplusAutomation package.
Different subset of data and models were applied, the list is as follows
Each cycle (1999)
```{r setup, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
library(tidyverse)
options(scipen = 999)
options(knitr.kable.NA = '')
#setwd("C:/Users/pamel/OneDrive - KU Leuven/Master in Statistics/Master Thesis/")
sys.source("0.functions.R", envir = knitr::knit_global())
load("ICCSAll_lvR.RData")
Id <- VarsToUse %>% filter(Construct == "ID Variables" & Dataset == "ISG") %>% dplyr::select(VariableName) %>% na.omit() %>% pull()
Scales <- c(VarsToUse %>% filter(Domain == "Scales" & Dataset %in% c("ISG","ISE")) %>% dplyr::select(VariableName) %>% na.omit() %>% pull())
Scalesb <- paste0("b", c(VarsToUse %>% filter(Domain == "Scales" & Dataset %in% c("ISG","ISE")) %>% dplyr::select(VariableName) %>% na.omit() %>% pull()))
sampleID <- c("IDJK", "IDCL", "SENWGT")
Man_cate <- VarsToUse %>% filter(Domain %in% "Background questionnaires" & Dataset == "ISG") %>% dplyr::select(VariableName) %>% pull()
#Filter for variables not yet calculated
Man_cate <- c(Man_cate[!grepl("*[1-9]$", Man_cate)], Man_cate[grepl("^T_PROTES*", Man_cate)])
Man_cont <- VarsToUse %>% filter(Domain %in% "Contextual" & Dataset == "ISG") %>% dplyr::select(VariableName) %>% pull() %>% na.omit()
#Add variable separating countries from Europe and Latam
ISC_lvR <- ISC_lvR %>% mutate(Subg = factor(ifelse(COUNTRY %in% c("CHL", "COL", "PER", "DOM", "MEX"), 2, 1), labels = c("LA", "EU")))
```
# Latent Class Analysis (LCA) {.tabset .tabset-fade .tabset-pills}
```{r lca, results = 'asis'}
cat('\n')
cat('\n')
source("7.lcaR.R")
cat('\n')
cat('\n')
```