---
title: "CFA Analysis"
author: "Christian Lindke Based on Code from Stephanie Rifai"
date: "3/25/2022"
output: html_document
---

```{r Setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)

r = getOption("repos")
r["CRAN"] = "http://cran.us.r-project.org"
options(repos = r)

library(readxl)
library(sqldf)
#install.packages("psych")
library(psych)
#install.packages("dplyr")
library(dplyr)
#install.packages("rlang")
library(rlang)

library(splithalf)
library(knitr)
library(corrplot)
library(lavaan)
#install.packages("stargazer")
library(stargazer)


```


Import data set and filter for attention check.

```{r, Import Data, warning = FALSE, echo=FALSE}

dat<- read_xlsx("https://www.christianlindke.com/uploads/2/8/0/0/28002995/raw_data_final.xlsx")
scales <- filter(dat, as.numeric(dat$gc) == 1)
scales[, c(32:252)] <- sapply(scales[, c(32:252)], as.numeric)
scales[, c(14,15,20,22,29,23,30)] <- sapply(scales[, c(14,15,20,22,29,23,30)], as.numeric)


scales <-filter(scales, as.numeric(scales$attention_and_strongly_agree) == "1")
scales_failed <-filter(scales, as.numeric(scales$attention_and_strongly_agree) == "0")
scales_passed <-filter(scales, as.numeric(scales$passed_attention_check) == "1")
scales_failed <-filter(scales, as.numeric(scales$passed_attention_check) == "0")



scales <- sqldf("Select *, case when race = 1 then 1 else 0 end as white,
              case when race = 2 then 1 else 0 end as black,
              case when race not in (1,2) then 1 else 0 end as other,
              case when gender = 1 then 1 else 0 end as male,
              case when political_affil = 1 then 1 else 0 end as republican,
              case when political_affil = 2 then 1 else 0 end as democrat,
              case when household_income = 14 then 4
                   when household_income = 11 then 5
                   when household_income = 12 then 6 else household_income end as hhi
      from scales")
```


Run Confirmatory Factor Analysis for Various Scales

## Helicopter Norms Analysis

```{r, Helicopter Norms, echo=FALSE}

oldw <- getOption("warn")
options(warn = -1)

## Evaluate Helicopter Norms hn_1:2, hn_4:6, hn_12:17 As Stated in Paper and Based on EFA

# Passed Attention Check
m1a <- ' Helicopter.Norms =~ hn_1 + hn_2 + hn_4 + hn_5 + hn_6 + hn_12 + hn_13 + hn_14 + hn_15 + hn_16 + hn_17'
Helicopter_Norms_Passed <- cfa(m1a, data = scales_passed)
summary(Helicopter_Norms_Passed)
summary(Helicopter_Norms_Passed, fit.measures = TRUE, standardized = TRUE)


# All Respondents
m1b <- ' Helicopter.Norms =~ hn_1 + hn_2 + hn_4 + hn_5 + hn_6 + hn_12 + hn_13 + hn_14 + hn_15 + hn_16 + hn_17'
Helicopter_Norms_All <- cfa(m1b, data = scales)
summary(Helicopter_Norms_All)
summary(Helicopter_Norms_All, fit.measures = TRUE, standardized = TRUE)




```

## General vs. Specific Paternalism Analysis

```{r, General vs Specific Paternalism, echo=FALSE}

## Evaluate Specific vs. General Paternalism Scales (specific_gen1:32)

# Passed Attention Check
m2a <- ' Specific_General =~ specific_gen_1 + specific_gen_2 + specific_gen_3 + 
specific_gen_4 + specific_gen_5 + specific_gen_6 + specific_gen_7 + specific_gen_8 + specific_gen_9 + specific_gen_10 + specific_gen_11 + specific_gen_12 + specific_gen_13 + specific_gen_14 + specific_gen_15 + specific_gen_16 + specific_gen_17 + specific_gen_18 + specific_gen_19 + specific_gen_20 + specific_gen_21 + specific_gen_22 + specific_gen_23 + specific_gen_24 + specific_gen_25 + specific_gen_26 + specific_gen_27 + specific_gen_28 + specific_gen_29 + specific_gen_30 + specific_gen_31 + specific_gen_32' 

Specific_General_Passed <- cfa(m2a, data = scales_passed)
summary(Specific_General_Passed)
summary(Specific_General_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m2b <- ' Specific_General =~ specific_gen_1 + specific_gen_2 + specific_gen_3 + 
specific_gen_4 + specific_gen_5 + specific_gen_6 + specific_gen_7 + specific_gen_8 + specific_gen_9 + specific_gen_10 + specific_gen_11 + specific_gen_12 + specific_gen_13 + specific_gen_14 + specific_gen_15 + specific_gen_16 + specific_gen_17 + specific_gen_18 + specific_gen_19 + specific_gen_20 + specific_gen_21 + specific_gen_22 + specific_gen_23 + specific_gen_24 + specific_gen_25 + specific_gen_26 + specific_gen_27 + specific_gen_28 + specific_gen_29 + specific_gen_30 + specific_gen_31 + specific_gen_32' 

Specific_General_All <- cfa(m2b, data = scales)
summary(Specific_General_All)
summary(Specific_General_All, fit.measures = TRUE, standardized = TRUE)


```

## Religious Paternalism Scale

```{r, Religious Paternalism, echo=FALSE}

## Religious Paternalism (Rows 97:110) religious_p_1:14

# Passed Attention Check
m3a <- ' Religious.Paternalism =~ religious_p_1 + religious_p_2 + religious_p_3 +
religious_p_4 + religious_p_5 + religious_p_6 + religious_p_7 + religious_p_8 + 
religious_p_9 + religious_p_10 + religious_p_11 + religious_p_12 + religious_p_13 + religious_p_14' 

Religious_Passed <- cfa(m3a, data = scales_passed)
summary(Religious_Passed)
summary(Religious_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m3b <- ' Religious.Paternalism =~ religious_p_1 + religious_p_2 + religious_p_3 +
religious_p_4 + religious_p_5 + religious_p_6 + religious_p_7 + religious_p_8 + 
religious_p_9 + religious_p_10 + religious_p_11 + religious_p_12 + religious_p_13 + religious_p_14'

Religious_All <- cfa(m3b, data = scales)
summary(Religious_All)
summary(Religious_All, fit.measures = TRUE, standardized = TRUE)

```

## Employer Paternalism Scale

```{r, Employer Paternalism Scale, echo=FALSE}

## Employer Paternalism (Rows 111:126) employer_p_1:16

# Passed Attention Check
m4a <- ' Employer.Paternalism =~ employer_p_1 + employer_p_2 + employer_p_3 +
employer_p_4 + employer_p_5 + employer_p_6 + employer_p_7 + employer_p_8 + 
employer_p_9 + employer_p_10 + employer_p_11 + employer_p_12 + employer_p_13 + employer_p_14 +
employer_p_15 +employer_p_16' 

Employer_Passed <- cfa(m4a, data = scales_passed)
summary(Employer_Passed)
summary(Employer_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m4b <- ' Employer.Paternalism =~ employer_p_1 + employer_p_2 + employer_p_3 +
employer_p_4 + employer_p_5 + employer_p_6 + employer_p_7 + employer_p_8 + 
employer_p_9 + employer_p_10 + employer_p_11 + employer_p_12 + employer_p_13 + employer_p_14 +
employer_p_15 +employer_p_16' 

Employer_All <- cfa(m4b, data = scales)
summary(Employer_All)
summary(Employer_All, fit.measures = TRUE, standardized = TRUE)


```

## Caregiver Paternalism Scale

```{r, Caregiver Paternalism Scale, echo=FALSE}


## Caregiver Paternalism (Rows 127:143) caregiver_p_1:17

# Passed Attention Check
m5a <- ' Caregiver.Paternalism =~ caregiver_p_1 + caregiver_p_2 + caregiver_p_3 +
caregiver_p_4 + caregiver_p_5 + caregiver_p_6 + caregiver_p_7 + caregiver_p_8 + 
caregiver_p_9 + caregiver_p_10 + caregiver_p_11 + caregiver_p_12 + caregiver_p_13 + caregiver_p_14 +
caregiver_p_15 + caregiver_p_16 + caregiver_p_17' 

Caregiver_Passed <- cfa(m5a, data = scales_passed)
summary(Caregiver_Passed)
summary(Caregiver_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m5b <- ' Caregiver.Paternalism =~ caregiver_p_1 + caregiver_p_2 + caregiver_p_3 +
caregiver_p_4 + caregiver_p_5 + caregiver_p_6 + caregiver_p_7 + caregiver_p_8 + 
caregiver_p_9 + caregiver_p_10 + caregiver_p_11 + caregiver_p_12 + caregiver_p_13 + caregiver_p_14 +
caregiver_p_15 + caregiver_p_16 + caregiver_p_17' 

Caregiver_All <- cfa(m5b, data = scales)
summary(Caregiver_All)
summary(Caregiver_All, fit.measures = TRUE, standardized = TRUE)

```

## Coach Paternalism Scale

```{r, Coach Paternalism Scale, echo=FALSE}

## Coach Paternalism (Rows 144:161) coaching_p_1:18

# Passed Attention Check

m6a <- ' Coaching.Paternalism =~ coaching_p_1 + coaching_p_2 + coaching_p_3 +
coaching_p_4 + coaching_p_5 + coaching_p_6 + coaching_p_7 + coaching_p_8 + 
coaching_p_9 + coaching_p_10 + coaching_p_11 + coaching_p_12 + coaching_p_13 + coaching_p_14 +
coaching_p_15 + coaching_p_16 + coaching_p_17 + coaching_p_18' 

Coaching_Passed <- cfa(m6a, data = scales_passed)
summary(Coaching_Passed)
summary(Coaching_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m6b <- ' Coaching.Paternalism =~ coaching_p_1 + coaching_p_2 + coaching_p_3 +
coaching_p_4 + coaching_p_5 + coaching_p_6 + coaching_p_7 + coaching_p_8 + 
coaching_p_9 + coaching_p_10 + coaching_p_11 + coaching_p_12 + coaching_p_13 + coaching_p_14 +
coaching_p_15 + coaching_p_16 + coaching_p_17 + coaching_p_18'  

Coaching_All <- cfa(m6b, data = scales)
summary(Coaching_All)
summary(Coaching_All, fit.measures = TRUE, standardized = TRUE)

```

## Peer-Ternalism Scale

```{r, Peer-ternalism Scale, echo=FALSE}

## Peer_ternalism (Rows 162:179) peer_p_1:18

# Passed Attention Check

m7a <- ' Peer_ternalism =~ peer_p_1 + peer_p_2 + peer_p_3 +
peer_p_4 + peer_p_5 + peer_p_6 + peer_p_7 + peer_p_8 + 
peer_p_9 + peer_p_10 + peer_p_11 + peer_p_12 + peer_p_13 + peer_p_14 +
peer_p_15 + peer_p_16 + peer_p_17 + peer_p_18' 

Peer_Passed <- cfa(m7a, data = scales_passed)
summary(Peer_Passed)
summary(Peer_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m7b <- ' Peer_ternalism =~ peer_p_1 + peer_p_2 + peer_p_3 +
peer_p_4 + peer_p_5 + peer_p_6 + peer_p_7 + peer_p_8 + 
peer_p_9 + peer_p_10 + peer_p_11 + peer_p_12 + peer_p_13 + peer_p_14 +
peer_p_15 + peer_p_16 + peer_p_17 + peer_p_18'  

Peer_All <- cfa(m7b, data = scales)
summary(Peer_All)
summary(Peer_All, fit.measures = TRUE, standardized = TRUE)

```

## Medical Paternalism Scale

```{r, Medical Paternalism Scale, echo=FALSE}

## Medical Paternalism (Rows 180:200) physician_p_1:21

# Passed Attention Check

m8a <- ' Doc_ternalism =~ physician_p_1 + physician_p_2 + physician_p_3 +
physician_p_4 + physician_p_5 + physician_p_6 + physician_p_7 + physician_p_8 + 
physician_p_9 + physician_p_10 + physician_p_11 + physician_p_12 + physician_p_13 + physician_p_14 +
physician_p_15 + physician_p_16 + physician_p_17 + physician_p_18 + physician_p_19 + physician_p_20 + physician_p_21' 

Physician_Passed <- cfa(m8a, data = scales_passed)
summary(Physician_Passed)
summary(Physician_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m8b <- ' Doc_ternalism =~ physician_p_1 + physician_p_2 + physician_p_3 +
physician_p_4 + physician_p_5 + physician_p_6 + physician_p_7 + physician_p_8 + 
physician_p_9 + physician_p_10 + physician_p_11 + physician_p_12 + physician_p_13 + physician_p_14 +
physician_p_15 + physician_p_16 + physician_p_17 + physician_p_18 + physician_p_19 + physician_p_20 + physician_p_21' 

Physician_All <- cfa(m8b, data = scales)
summary(Physician_All)
summary(Physician_All, fit.measures = TRUE, standardized = TRUE)

```

## University Paternalism Scale

```{r, University Paternalism, echo=FALSE}

## University Paternalism (234:249) uni_norms_1:15

# Passed Attention Check

m9a <- ' University.Paternalism =~ uni_norms_1 + uni_norms_2 + uni_norms_3 +
uni_norms_4 + uni_norms_5 + uni_norms_6 + uni_norms_7 + uni_norms_8 + 
uni_norms_9 + uni_norms_10 + uni_norms_11 + uni_norms_12 + uni_norms_13 + uni_norms_14 +
uni_norms_15 + uni_norms_16' 

University_Passed <- cfa(m9a, data = scales_passed)
summary(University_Passed)
summary(University_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m9b <- ' University.Paternalism =~ uni_norms_1 + uni_norms_2 + uni_norms_3 +
uni_norms_4 + uni_norms_5 + uni_norms_6 + uni_norms_7 + uni_norms_8 + 
uni_norms_9 + uni_norms_10 + uni_norms_11 + uni_norms_12 + uni_norms_13 + uni_norms_14 +
uni_norms_15 + uni_norms_16' 

University_All <- cfa(m9b, data = scales)
summary(University_All)
summary(University_All, fit.measures = TRUE, standardized = TRUE)

```

## All Paternalism Scales

```{r, All Scales, echo=FALSE}
### Evaluate All Paternalism Scales on Single Factor

# Passed Attention Check

m10a <-  ' All_ternalism =~ religious_p_1 + religious_p_2 + religious_p_3 +
religious_p_4 + religious_p_5 + religious_p_6 + religious_p_7 + religious_p_8 + 
religious_p_9 + religious_p_10 + religious_p_11 + religious_p_12 + religious_p_13 + religious_p_14 +
employer_p_1 + employer_p_2 + employer_p_3 +
employer_p_4 + employer_p_5 + employer_p_6 + employer_p_7 + employer_p_8 + 
employer_p_9 + employer_p_10 + employer_p_11 + employer_p_12 + employer_p_13 + employer_p_14 +
employer_p_15 +employer_p_16 + caregiver_p_1 + caregiver_p_2 + caregiver_p_3 +
caregiver_p_4 + caregiver_p_5 + caregiver_p_6 + caregiver_p_7 + caregiver_p_8 + 
caregiver_p_9 + caregiver_p_10 + caregiver_p_11 + caregiver_p_12 + caregiver_p_13 + caregiver_p_14 +
caregiver_p_15 + caregiver_p_16 + caregiver_p_17 +
coaching_p_1 + coaching_p_2 + coaching_p_3 +
coaching_p_4 + coaching_p_5 + coaching_p_6 + coaching_p_7 + coaching_p_8 + 
coaching_p_9 + coaching_p_10 + coaching_p_11 + coaching_p_12 + coaching_p_13 + coaching_p_14 +
coaching_p_15 + coaching_p_16 + coaching_p_17 + coaching_p_18 +
peer_p_1 + peer_p_2 + peer_p_3 +
peer_p_4 + peer_p_5 + peer_p_6 + peer_p_7 + peer_p_8 + 
peer_p_9 + peer_p_10 + peer_p_11 + peer_p_12 + peer_p_13 + peer_p_14 +
peer_p_15 + peer_p_16 + peer_p_17 + peer_p_18 +
physician_p_1 + physician_p_2 + physician_p_3 +
physician_p_4 + physician_p_5 + physician_p_6 + physician_p_7 + physician_p_8 + 
physician_p_9 + physician_p_10 + physician_p_11 + physician_p_12 + physician_p_13 + physician_p_14 +
physician_p_15 + physician_p_16 + physician_p_17 + physician_p_18 + physician_p_19 + physician_p_20 + physician_p_21 +
uni_norms_1 + uni_norms_2 + uni_norms_3 +
uni_norms_4 + uni_norms_5 + uni_norms_6 + uni_norms_7 + uni_norms_8 + 
uni_norms_9 + uni_norms_10 + uni_norms_11 + uni_norms_12 + uni_norms_13 + uni_norms_14 +
uni_norms_15 + uni_norms_16'

All_Passed <- cfa(m10a, data = scales_passed)
summary(All_Passed)
summary(All_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m10b <-  ' All_ternalism =~ religious_p_1 + religious_p_2 + religious_p_3 +
religious_p_4 + religious_p_5 + religious_p_6 + religious_p_7 + religious_p_8 + 
religious_p_9 + religious_p_10 + religious_p_11 + religious_p_12 + religious_p_13 + religious_p_14 +
employer_p_1 + employer_p_2 + employer_p_3 +
employer_p_4 + employer_p_5 + employer_p_6 + employer_p_7 + employer_p_8 + 
employer_p_9 + employer_p_10 + employer_p_11 + employer_p_12 + employer_p_13 + employer_p_14 +
employer_p_15 +employer_p_16 + caregiver_p_1 + caregiver_p_2 + caregiver_p_3 +
caregiver_p_4 + caregiver_p_5 + caregiver_p_6 + caregiver_p_7 + caregiver_p_8 + 
caregiver_p_9 + caregiver_p_10 + caregiver_p_11 + caregiver_p_12 + caregiver_p_13 + caregiver_p_14 +
caregiver_p_15 + caregiver_p_16 + caregiver_p_17 +
coaching_p_1 + coaching_p_2 + coaching_p_3 +
coaching_p_4 + coaching_p_5 + coaching_p_6 + coaching_p_7 + coaching_p_8 + 
coaching_p_9 + coaching_p_10 + coaching_p_11 + coaching_p_12 + coaching_p_13 + coaching_p_14 +
coaching_p_15 + coaching_p_16 + coaching_p_17 + coaching_p_18 +
peer_p_1 + peer_p_2 + peer_p_3 +
peer_p_4 + peer_p_5 + peer_p_6 + peer_p_7 + peer_p_8 + 
peer_p_9 + peer_p_10 + peer_p_11 + peer_p_12 + peer_p_13 + peer_p_14 +
peer_p_15 + peer_p_16 + peer_p_17 + peer_p_18 +
physician_p_1 + physician_p_2 + physician_p_3 +
physician_p_4 + physician_p_5 + physician_p_6 + physician_p_7 + physician_p_8 + 
physician_p_9 + physician_p_10 + physician_p_11 + physician_p_12 + physician_p_13 + physician_p_14 +
physician_p_15 + physician_p_16 + physician_p_17 + physician_p_18 + physician_p_19 + physician_p_20 + physician_p_21 +
uni_norms_1 + uni_norms_2 + uni_norms_3 +
uni_norms_4 + uni_norms_5 + uni_norms_6 + uni_norms_7 + uni_norms_8 + 
uni_norms_9 + uni_norms_10 + uni_norms_11 + uni_norms_12 + uni_norms_13 + uni_norms_14 +
uni_norms_15 + uni_norms_16'

All_Paternalism <- cfa(m10b, data = scales)
summary(All_Paternalism)
summary(All_Paternalism, fit.measures = TRUE, standardized = TRUE)

### Evaluate Helicopter Norms and Paternalism Scales on Single Factor

# Passed Attention Check

m11a <-  ' Helicop_ternalism =~ religious_p_1 + religious_p_2 + religious_p_3 +
religious_p_4 + religious_p_5 + religious_p_6 + religious_p_7 + religious_p_8 + 
religious_p_9 + religious_p_10 + religious_p_11 + religious_p_12 + religious_p_13 + religious_p_14 +
employer_p_1 + employer_p_2 + employer_p_3 +
employer_p_4 + employer_p_5 + employer_p_6 + employer_p_7 + employer_p_8 + 
employer_p_9 + employer_p_10 + employer_p_11 + employer_p_12 + employer_p_13 + employer_p_14 +
employer_p_15 +employer_p_16 + caregiver_p_1 + caregiver_p_2 + caregiver_p_3 +
caregiver_p_4 + caregiver_p_5 + caregiver_p_6 + caregiver_p_7 + caregiver_p_8 + 
caregiver_p_9 + caregiver_p_10 + caregiver_p_11 + caregiver_p_12 + caregiver_p_13 + caregiver_p_14 +
caregiver_p_15 + caregiver_p_16 + caregiver_p_17 +
coaching_p_1 + coaching_p_2 + coaching_p_3 +
coaching_p_4 + coaching_p_5 + coaching_p_6 + coaching_p_7 + coaching_p_8 + 
coaching_p_9 + coaching_p_10 + coaching_p_11 + coaching_p_12 + coaching_p_13 + coaching_p_14 +
coaching_p_15 + coaching_p_16 + coaching_p_17 + coaching_p_18 +
peer_p_1 + peer_p_2 + peer_p_3 +
peer_p_4 + peer_p_5 + peer_p_6 + peer_p_7 + peer_p_8 + 
peer_p_9 + peer_p_10 + peer_p_11 + peer_p_12 + peer_p_13 + peer_p_14 +
peer_p_15 + peer_p_16 + peer_p_17 + peer_p_18 +
physician_p_1 + physician_p_2 + physician_p_3 +
physician_p_4 + physician_p_5 + physician_p_6 + physician_p_7 + physician_p_8 + 
physician_p_9 + physician_p_10 + physician_p_11 + physician_p_12 + physician_p_13 + physician_p_14 +
physician_p_15 + physician_p_16 + physician_p_17 + physician_p_18 + physician_p_19 + physician_p_20 + physician_p_21 +
uni_norms_1 + uni_norms_2 + uni_norms_3 +
uni_norms_4 + uni_norms_5 + uni_norms_6 + uni_norms_7 + uni_norms_8 + 
uni_norms_9 + uni_norms_10 + uni_norms_11 + uni_norms_12 + uni_norms_13 + uni_norms_14 +
uni_norms_15 + uni_norms_16 + hn_1 + hn_2 + hn_4 + hn_5 + hn_6 + hn_12 + hn_13 + hn_14 + hn_15 + hn_16 + hn_17'

All_Helicopter_Passed <- cfa(m11a, data = scales_passed)
summary(All_Helicopter_Passed)
summary(All_Helicopter_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents

m11b <-  ' Helicop_ternalism =~ religious_p_1 + religious_p_2 + religious_p_3 +
religious_p_4 + religious_p_5 + religious_p_6 + religious_p_7 + religious_p_8 + 
religious_p_9 + religious_p_10 + religious_p_11 + religious_p_12 + religious_p_13 + religious_p_14 +
employer_p_1 + employer_p_2 + employer_p_3 +
employer_p_4 + employer_p_5 + employer_p_6 + employer_p_7 + employer_p_8 + 
employer_p_9 + employer_p_10 + employer_p_11 + employer_p_12 + employer_p_13 + employer_p_14 +
employer_p_15 +employer_p_16 + caregiver_p_1 + caregiver_p_2 + caregiver_p_3 +
caregiver_p_4 + caregiver_p_5 + caregiver_p_6 + caregiver_p_7 + caregiver_p_8 + 
caregiver_p_9 + caregiver_p_10 + caregiver_p_11 + caregiver_p_12 + caregiver_p_13 + caregiver_p_14 +
caregiver_p_15 + caregiver_p_16 + caregiver_p_17 +
coaching_p_1 + coaching_p_2 + coaching_p_3 +
coaching_p_4 + coaching_p_5 + coaching_p_6 + coaching_p_7 + coaching_p_8 + 
coaching_p_9 + coaching_p_10 + coaching_p_11 + coaching_p_12 + coaching_p_13 + coaching_p_14 +
coaching_p_15 + coaching_p_16 + coaching_p_17 + coaching_p_18 +
peer_p_1 + peer_p_2 + peer_p_3 +
peer_p_4 + peer_p_5 + peer_p_6 + peer_p_7 + peer_p_8 + 
peer_p_9 + peer_p_10 + peer_p_11 + peer_p_12 + peer_p_13 + peer_p_14 +
peer_p_15 + peer_p_16 + peer_p_17 + peer_p_18 +
physician_p_1 + physician_p_2 + physician_p_3 +
physician_p_4 + physician_p_5 + physician_p_6 + physician_p_7 + physician_p_8 + 
physician_p_9 + physician_p_10 + physician_p_11 + physician_p_12 + physician_p_13 + physician_p_14 +
physician_p_15 + physician_p_16 + physician_p_17 + physician_p_18 + physician_p_19 + physician_p_20 + physician_p_21 +
uni_norms_1 + uni_norms_2 + uni_norms_3 +
uni_norms_4 + uni_norms_5 + uni_norms_6 + uni_norms_7 + uni_norms_8 + 
uni_norms_9 + uni_norms_10 + uni_norms_11 + uni_norms_12 + uni_norms_13 + uni_norms_14 +
uni_norms_15 + uni_norms_16 + hn_1 + hn_2 + hn_4 + hn_5 + hn_6 + hn_12 + hn_13 + hn_14 + hn_15 + hn_16 + hn_17'

All_Helicopter  <- cfa(m11b, data = scales)
summary(All_Helicopter)
summary(All_Helicopter, fit.measures = TRUE, standardized = TRUE)







```

```{r, CFA as 2 Correlated Factors, echo=FALSE}

# Passed Attention Check

m12a <-  ' Lone_ternalism =~ religious_p_1 + religious_p_2 + religious_p_3 +
religious_p_4 + religious_p_5 + religious_p_6 + religious_p_7 + religious_p_8 + 
religious_p_9 + religious_p_10 + religious_p_11 + religious_p_12 + religious_p_13 + religious_p_14 +
employer_p_1 + employer_p_2 + employer_p_3 +
employer_p_4 + employer_p_5 + employer_p_6 + employer_p_7 + employer_p_8 + 
employer_p_9 + employer_p_10 + employer_p_11 + employer_p_12 + employer_p_13 + employer_p_14 +
employer_p_15 +employer_p_16 + caregiver_p_1 + caregiver_p_2 + caregiver_p_3 +
caregiver_p_4 + caregiver_p_5 + caregiver_p_6 + caregiver_p_7 + caregiver_p_8 + 
caregiver_p_9 + caregiver_p_10 + caregiver_p_11 + caregiver_p_12 + caregiver_p_13 + caregiver_p_14 +
caregiver_p_15 + caregiver_p_16 + caregiver_p_17 +
coaching_p_1 + coaching_p_2 + coaching_p_3 +
coaching_p_4 + coaching_p_5 + coaching_p_6 + coaching_p_7 + coaching_p_8 + 
coaching_p_9 + coaching_p_10 + coaching_p_11 + coaching_p_12 + coaching_p_13 + coaching_p_14 +
coaching_p_15 + coaching_p_16 + coaching_p_17 + coaching_p_18 +
peer_p_1 + peer_p_2 + peer_p_3 +
peer_p_4 + peer_p_5 + peer_p_6 + peer_p_7 + peer_p_8 + 
peer_p_9 + peer_p_10 + peer_p_11 + peer_p_12 + peer_p_13 + peer_p_14 +
peer_p_15 + peer_p_16 + peer_p_17 + peer_p_18 +
physician_p_1 + physician_p_2 + physician_p_3 +
physician_p_4 + physician_p_5 + physician_p_6 + physician_p_7 + physician_p_8 + 
physician_p_9 + physician_p_10 + physician_p_11 + physician_p_12 + physician_p_13 + physician_p_14 +
physician_p_15 + physician_p_16 + physician_p_17 + physician_p_18 + physician_p_19 + physician_p_20 + physician_p_21 +
uni_norms_1 + uni_norms_2 + uni_norms_3 +
uni_norms_4 + uni_norms_5 + uni_norms_6 + uni_norms_7 + uni_norms_8 + 
uni_norms_9 + uni_norms_10 + uni_norms_11 + uni_norms_12 + uni_norms_13 + uni_norms_14 +
uni_norms_15 + uni_norms_16 
    Helicop_nonternalism =~ hn_1 + hn_2 + hn_4 + hn_5 + hn_6 + hn_12 + hn_13 + hn_14 + hn_15 + hn_16 + hn_17'

Noncopter_Passed <- cfa(m12a, data = scales_passed, std.lv=TRUE)
summary(Noncopter_Passed, fit.measures = TRUE, standardized = TRUE)

# All Respondents
m12b <- ' Lone_ternalism =~ religious_p_1 + religious_p_2 + religious_p_3 +
religious_p_4 + religious_p_5 + religious_p_6 + religious_p_7 + religious_p_8 + 
religious_p_9 + religious_p_10 + religious_p_11 + religious_p_12 + religious_p_13 + religious_p_14 +
employer_p_1 + employer_p_2 + employer_p_3 +
employer_p_4 + employer_p_5 + employer_p_6 + employer_p_7 + employer_p_8 + 
employer_p_9 + employer_p_10 + employer_p_11 + employer_p_12 + employer_p_13 + employer_p_14 +
employer_p_15 +employer_p_16 + caregiver_p_1 + caregiver_p_2 + caregiver_p_3 +
caregiver_p_4 + caregiver_p_5 + caregiver_p_6 + caregiver_p_7 + caregiver_p_8 + 
caregiver_p_9 + caregiver_p_10 + caregiver_p_11 + caregiver_p_12 + caregiver_p_13 + caregiver_p_14 +
caregiver_p_15 + caregiver_p_16 + caregiver_p_17 +
coaching_p_1 + coaching_p_2 + coaching_p_3 +
coaching_p_4 + coaching_p_5 + coaching_p_6 + coaching_p_7 + coaching_p_8 + 
coaching_p_9 + coaching_p_10 + coaching_p_11 + coaching_p_12 + coaching_p_13 + coaching_p_14 +
coaching_p_15 + coaching_p_16 + coaching_p_17 + coaching_p_18 +
peer_p_1 + peer_p_2 + peer_p_3 +
peer_p_4 + peer_p_5 + peer_p_6 + peer_p_7 + peer_p_8 + 
peer_p_9 + peer_p_10 + peer_p_11 + peer_p_12 + peer_p_13 + peer_p_14 +
peer_p_15 + peer_p_16 + peer_p_17 + peer_p_18 +
physician_p_1 + physician_p_2 + physician_p_3 +
physician_p_4 + physician_p_5 + physician_p_6 + physician_p_7 + physician_p_8 + 
physician_p_9 + physician_p_10 + physician_p_11 + physician_p_12 + physician_p_13 + physician_p_14 +
physician_p_15 + physician_p_16 + physician_p_17 + physician_p_18 + physician_p_19 + physician_p_20 + physician_p_21 +
uni_norms_1 + uni_norms_2 + uni_norms_3 +
uni_norms_4 + uni_norms_5 + uni_norms_6 + uni_norms_7 + uni_norms_8 + 
uni_norms_9 + uni_norms_10 + uni_norms_11 + uni_norms_12 + uni_norms_13 + uni_norms_14 +
uni_norms_15 + uni_norms_16 
    Helicop_nonternalism =~ hn_1 + hn_2 + hn_4 + hn_5 + hn_6 + hn_12 + hn_13 + hn_14 + hn_15 + hn_16 + hn_17'

Noncopter  <- cfa(m12b, data = scales, std.lv=TRUE)
summary(Noncopter, fit.measures = TRUE, standardized = TRUE)


```

