#Load packages

#load psych package
library(psych)

#load tidyverse package
library(tidyverse)

library(viridis) # For color-blind-friendly palettes

#lavaan for cfa and sem
library(lavaan)

#load corrplot
library(corrplot)

library(ggcorrplot)

#Read in data

YNEES_W1 <- read.csv("YNEES.Data.Clean.csv")

YNEES <- read.csv("YNEES.W1andW2_Data.Clean.csv")

#Create White vs POC variable

#table for race variable
table(YNEES_W1$race)
## 
##           Asian           Black          Latinx  Middle Eastern     Multiracial 
##              34             122              77               3              31 
## Native American           White 
##              14             145
#Create White vs POC Variable
YNEES_W1$race2 <- ifelse(YNEES_W1$race == "White", 0, 1 )

table(YNEES_W1$race2)
## 
##   0   1 
## 145 281
# Label the AgeGroup variable
YNEES_W1$race2 <- factor(YNEES_W1$race2, 
                         levels = c(0, 1), 
                         labels = c("White", "People of Color"))

##Check descriptives for Christian Nat items at Wave 1

#Create matrix of cns variables at time 1
# 'YNEES' is the dataframe we're working with
CNatvars <- YNEES_W1 %>%
  select(cns_1, cns_2, cns_3, cns_4r, cns_5, cns_6r) %>% 
  as.matrix()

# View the matrix
#CNatvars


#descriptives for cns vars
describe(CNatvars)
##        vars   n mean   sd median trimmed  mad min max range  skew kurtosis   se
## cns_1     1 427 3.44 1.81      4    3.43 2.97   1   6     5 -0.02    -1.35 0.09
## cns_2     2 427 3.49 1.74      4    3.49 1.48   1   6     5 -0.15    -1.29 0.08
## cns_3     3 426 3.41 1.81      4    3.38 2.97   1   6     5 -0.03    -1.37 0.09
## cns_4r    4 424 2.66 1.54      2    2.46 1.48   1   6     5  0.76    -0.35 0.07
## cns_5     5 424 3.78 1.79      4    3.84 1.48   1   6     5 -0.37    -1.21 0.09
## cns_6r    6 426 3.06 1.74      3    2.96 1.48   1   6     5  0.39    -1.12 0.08
#create a correlation matrix for cns vars
CNCorMat <-cor(CNatvars, use = "complete.obs")

#Now visualize the correlation matrix with GGplot and corrplot
ggcorrplot(CNCorMat, hc.order = TRUE, type = "lower", lab = TRUE, ggtheme = ggplot2::theme_gray,
   colors = c("#6D9EC1", "white", "#E46726"))

#CFA for christian nationalism

#CFA for Critical Nationalism Measures
Cnat_CFA <- 'C_nat =~ 1*cns_1 + cns_2 + cns_3 + cns_4r + cns_5 + cns_6r'

Cnat_CFA <- sem(Cnat_CFA, data = YNEES_W1, estimator = "MLR") #robust estimator with "MLR"

summary(Cnat_CFA, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-19 ended normally after 25 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        12
## 
##                                                   Used       Total
##   Number of observations                           421         427
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                56.560      44.611
##   Degrees of freedom                                 9           9
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.268
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1441.705     863.940
##   Degrees of freedom                                15          15
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.669
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.967       0.958
##   Tucker-Lewis Index (TLI)                       0.944       0.930
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.968
##   Robust Tucker-Lewis Index (TLI)                            0.947
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -4284.376   -4284.376
##   Scaling correction factor                                  1.357
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -4256.096   -4256.096
##   Scaling correction factor                                  1.319
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                8592.752    8592.752
##   Bayesian (BIC)                              8641.263    8641.263
##   Sample-size adjusted Bayesian (SABIC)       8603.183    8603.183
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.112       0.097
##   90 Percent confidence interval - lower         0.085       0.073
##   90 Percent confidence interval - upper         0.141       0.123
##   P-value H_0: RMSEA <= 0.050                    0.000       0.001
##   P-value H_0: RMSEA >= 0.080                    0.974       0.879
##                                                                   
##   Robust RMSEA                                               0.109
##   90 Percent confidence interval - lower                     0.078
##   90 Percent confidence interval - upper                     0.142
##   P-value H_0: Robust RMSEA <= 0.050                         0.001
##   P-value H_0: Robust RMSEA >= 0.080                         0.942
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.054       0.054
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.668    0.922
##     cns_2             0.949    0.029   32.432    0.000    1.583    0.911
##     cns_3             0.910    0.032   28.393    0.000    1.518    0.840
##     cns_4r           -0.174    0.055   -3.153    0.002   -0.291   -0.189
##     cns_5             0.865    0.038   22.732    0.000    1.443    0.807
##     cns_6r            0.278    0.057    4.873    0.000    0.464    0.265
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.488    0.091    5.365    0.000    0.488    0.149
##    .cns_2             0.512    0.089    5.752    0.000    0.512    0.170
##    .cns_3             0.963    0.124    7.795    0.000    0.963    0.295
##    .cns_4r            2.284    0.141   16.147    0.000    2.284    0.964
##    .cns_5             1.116    0.140    7.987    0.000    1.116    0.349
##    .cns_6r            2.840    0.139   20.448    0.000    2.840    0.930
##     C_nat             2.783    0.159   17.556    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.851
##     cns_2             0.830
##     cns_3             0.705
##     cns_4r            0.036
##     cns_5             0.651
##     cns_6r            0.070
resid(Cnat_CFA)
## $type
## [1] "raw"
## 
## $cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5 cns_6r
## cns_1   0.000                                   
## cns_2  -0.007  0.000                            
## cns_3   0.043 -0.018  0.000                     
## cns_4r  0.033 -0.047  0.037  0.000              
## cns_5  -0.023  0.022 -0.035 -0.088  0.000       
## cns_6r -0.079  0.102 -0.249  0.536  0.319  0.000

##Item 6r “religion has no place in government” is throwing off the fit for the CFA. We can make an argument to drop it or think of a rationale to keep it despite questionable fit. I’d defer to you on this, my gut say’s drop for parsimony and to increase fit.

#Also is 4 “The federal government should allow all faiths to display religious symbols in public spaces.” supposed to be reverse scored? I don’t currently have it reverse scored.

##Second cfa for cnat without item cns_6r

Cnat_CFA2 <- 'C_nat =~ 1*cns_1 + cns_2 + cns_3 + cns_4r + cns_5'

Cnat_CFA2 <- sem(Cnat_CFA2, data = YNEES_W1, estimator = "MLR") #robust estimator with "MLR"

summary(Cnat_CFA2, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-19 ended normally after 24 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        10
## 
##                                                   Used       Total
##   Number of observations                           422         427
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 5.418       4.457
##   Degrees of freedom                                 5           5
##   P-value (Chi-square)                           0.367       0.486
##   Scaling correction factor                                  1.216
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1367.407     747.612
##   Degrees of freedom                                10          10
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.829
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       0.999       1.001
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.001
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -3473.562   -3473.562
##   Scaling correction factor                                  1.444
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -3470.853   -3470.853
##   Scaling correction factor                                  1.368
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                6967.124    6967.124
##   Bayesian (BIC)                              7007.575    7007.575
##   Sample-size adjusted Bayesian (SABIC)       6975.841    6975.841
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.014       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.070       0.059
##   P-value H_0: RMSEA <= 0.050                    0.804       0.899
##   P-value H_0: RMSEA >= 0.080                    0.021       0.005
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.070
##   P-value H_0: Robust RMSEA <= 0.050                         0.830
##   P-value H_0: Robust RMSEA >= 0.080                         0.023
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.012       0.012
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.675    0.925
##     cns_2             0.943    0.029   32.775    0.000    1.579    0.909
##     cns_3             0.911    0.032   28.526    0.000    1.526    0.843
##     cns_4r           -0.177    0.055   -3.250    0.001   -0.297   -0.193
##     cns_5             0.858    0.038   22.793    0.000    1.437    0.804
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.475    0.090    5.269    0.000    0.475    0.145
##    .cns_2             0.525    0.088    5.954    0.000    0.525    0.174
##    .cns_3             0.949    0.122    7.804    0.000    0.949    0.289
##    .cns_4r            2.276    0.141   16.140    0.000    2.276    0.963
##    .cns_5             1.130    0.139    8.130    0.000    1.130    0.354
##     C_nat             2.804    0.158   17.735    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.855
##     cns_2             0.826
##     cns_3             0.711
##     cns_4r            0.037
##     cns_5             0.646
resid(Cnat_CFA2)
## $type
## [1] "raw"
## 
## $cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5
## cns_1   0.000                            
## cns_2  -0.006  0.000                     
## cns_3   0.030 -0.020  0.000              
## cns_4r  0.042 -0.039  0.045  0.000       
## cns_5  -0.020  0.038 -0.034 -0.081  0.000

#Check descritives and correlation between SDO items

#Create matrix for SDO items 
SDOvars <- YNEES_W1 %>%
  select(sdod_1, sdoe_1) %>% 
  as.matrix()

# View the matrix
#SDOvars


#descriptives for sdo vars
describe(SDOvars)
##        vars   n mean   sd median trimmed  mad min max range  skew kurtosis   se
## sdod_1    1 427 3.75 2.00      4    3.69 2.97   1   7     6 -0.01    -1.14 0.10
## sdoe_1    2 427 5.80 1.37      6    5.95 1.48   1   7     6 -0.84    -0.20 0.07
#create a correlation matrix for sdo vars
SDOCorMat <-cor(SDOvars, use = "complete.obs")

#Now visualize the correlation matrix with GGplot and corrplot
ggcorrplot(SDOCorMat, hc.order = TRUE, type = "lower", lab = TRUE, ggtheme = ggplot2::theme_gray,
   colors = c("#6D9EC1", "white", "#E46726"))

#correlation between sdo_e and sdo_d
cor.test(YNEES_W1$sdod_1, YNEES_W1$sdoe_1)
## 
##  Pearson's product-moment correlation
## 
## data:  YNEES_W1$sdod_1 and YNEES_W1$sdoe_1
## t = -3.0519, df = 425, p-value = 0.002416
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.23803433 -0.05227312
## sample estimates:
##        cor 
## -0.1464445

##Given the correlation of .15 between the sdo items, it is best not to combine them into one composite variable.

#SEM assessing predictive validity w/ sdoe_1

Cnat_SEM1 <- 'C_nat =~ 1*cns_1 + cns_2 + cns_3 + cns_4r + cns_5
              sdoe_1 ~~ C_nat'

Cnat_SEM1 <- sem(Cnat_SEM1, data = YNEES_W1, estimator = "MLR") #robust estimator with "MLR"

summary(Cnat_SEM1, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-19 ended normally after 28 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        12
## 
##                                                   Used       Total
##   Number of observations                           422         427
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                37.049      30.049
##   Degrees of freedom                                 9           9
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.233
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1401.810     868.670
##   Degrees of freedom                                15          15
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.614
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.980       0.975
##   Tucker-Lewis Index (TLI)                       0.966       0.959
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.981
##   Robust Tucker-Lewis Index (TLI)                            0.969
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -4203.398   -4203.398
##   Scaling correction factor                                  1.354
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -4184.873   -4184.873
##   Scaling correction factor                                  1.302
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                8430.795    8430.795
##   Bayesian (BIC)                              8479.335    8479.335
##   Sample-size adjusted Bayesian (SABIC)       8441.255    8441.255
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.086       0.074
##   90 Percent confidence interval - lower         0.058       0.049
##   90 Percent confidence interval - upper         0.116       0.102
##   P-value H_0: RMSEA <= 0.050                    0.018       0.058
##   P-value H_0: RMSEA >= 0.080                    0.665       0.396
##                                                                   
##   Robust RMSEA                                               0.083
##   90 Percent confidence interval - lower                     0.051
##   90 Percent confidence interval - upper                     0.116
##   P-value H_0: Robust RMSEA <= 0.050                         0.045
##   P-value H_0: Robust RMSEA >= 0.080                         0.590
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.051       0.051
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.675    0.925
##     cns_2             0.942    0.029   32.624    0.000    1.578    0.908
##     cns_3             0.911    0.032   28.495    0.000    1.527    0.844
##     cns_4r           -0.176    0.055   -3.221    0.001   -0.295   -0.192
##     cns_5             0.857    0.038   22.782    0.000    1.436    0.804
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat ~~                                                              
##     sdoe_1           -0.192    0.106   -1.812    0.070   -0.115   -0.084
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.472    0.090    5.241    0.000    0.472    0.144
##    .cns_2             0.529    0.089    5.933    0.000    0.529    0.175
##    .cns_3             0.945    0.122    7.777    0.000    0.945    0.288
##    .cns_4r            2.277    0.141   16.155    0.000    2.277    0.963
##    .cns_5             1.131    0.139    8.132    0.000    1.131    0.354
##     sdoe_1            1.873    0.123   15.232    0.000    1.873    1.000
##     C_nat             2.807    0.158   17.775    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.856
##     cns_2             0.825
##     cns_3             0.712
##     cns_4r            0.037
##     cns_5             0.646
resid(Cnat_SEM1)
## $type
## [1] "raw"
## 
## $cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5 sdoe_1
## cns_1   0.000                                   
## cns_2  -0.005  0.000                            
## cns_3   0.027 -0.019  0.000                     
## cns_4r  0.039 -0.043  0.043  0.000              
## cns_5  -0.020  0.040 -0.034 -0.084  0.000       
## sdoe_1 -0.051  0.102 -0.169 -0.444  0.074  0.000

#SEM assessing predictive validity w/ sdod_1

Cnat_SEM3 <- 'C_nat =~ 1*cns_1 + cns_2 + cns_3 + cns_4r + cns_5
              sdod_1 ~~ C_nat'

Cnat_SEM3 <- sem(Cnat_SEM3, data = YNEES_W1, estimator = "MLR") #robust estimator with "MLR"

summary(Cnat_SEM3, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-19 ended normally after 28 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        12
## 
##                                                   Used       Total
##   Number of observations                           422         427
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                23.262      20.403
##   Degrees of freedom                                 9           9
##   P-value (Chi-square)                           0.006       0.016
##   Scaling correction factor                                  1.140
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1473.156     928.242
##   Degrees of freedom                                15          15
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.587
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.990       0.988
##   Tucker-Lewis Index (TLI)                       0.984       0.979
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.991
##   Robust Tucker-Lewis Index (TLI)                            0.985
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -4320.173   -4320.173
##   Scaling correction factor                                  1.351
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -4308.542   -4308.542
##   Scaling correction factor                                  1.261
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                8664.346    8664.346
##   Bayesian (BIC)                              8712.886    8712.886
##   Sample-size adjusted Bayesian (SABIC)       8674.806    8674.806
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.061       0.055
##   90 Percent confidence interval - lower         0.031       0.025
##   90 Percent confidence interval - upper         0.093       0.085
##   P-value H_0: RMSEA <= 0.050                    0.239       0.354
##   P-value H_0: RMSEA >= 0.080                    0.176       0.086
##                                                                   
##   Robust RMSEA                                               0.059
##   90 Percent confidence interval - lower                     0.024
##   90 Percent confidence interval - upper                     0.093
##   P-value H_0: Robust RMSEA <= 0.050                         0.298
##   P-value H_0: Robust RMSEA >= 0.080                         0.163
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.026       0.026
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.680    0.928
##     cns_2             0.936    0.028   33.644    0.000    1.573    0.905
##     cns_3             0.912    0.032   28.655    0.000    1.532    0.846
##     cns_4r           -0.178    0.054   -3.300    0.001   -0.300   -0.195
##     cns_5             0.852    0.037   22.880    0.000    1.430    0.800
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat ~~                                                              
##     sdod_1            1.504    0.181    8.327    0.000    0.895    0.448
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.458    0.087    5.277    0.000    0.458    0.140
##    .cns_2             0.544    0.088    6.176    0.000    0.544    0.180
##    .cns_3             0.930    0.120    7.773    0.000    0.930    0.284
##    .cns_4r            2.275    0.141   16.149    0.000    2.275    0.962
##    .cns_5             1.148    0.139    8.267    0.000    1.148    0.360
##     sdod_1            3.986    0.182   21.933    0.000    3.986    1.000
##     C_nat             2.821    0.156   18.042    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.860
##     cns_2             0.820
##     cns_3             0.716
##     cns_4r            0.038
##     cns_5             0.640
resid(Cnat_SEM3)
## $type
## [1] "raw"
## 
## $cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5 sdod_1
## cns_1   0.000                                   
## cns_2  -0.004  0.000                            
## cns_3   0.013 -0.020  0.000                     
## cns_4r  0.048 -0.037  0.051  0.000              
## cns_5  -0.016  0.057 -0.032 -0.080  0.000       
## sdod_1  0.059 -0.104  0.204 -0.190 -0.222  0.000

###Correlation between christian nationalism and SDO dominance is very strong as we’d expect. Folks who view hierarchy as natural (item: “Some groups of people are simply inferior to other groups.”) are more likely to endorse christian nationalism. I did not run a predictive model where SDO is a predictor of christian nationalism or vice versa, but I can. Though with cross-sectional data we’re only in the space of make correlational claims anyway. The beta coefficient for cns predicting SDO or vice versa along with the model fit would be equivelalent in all three models (cns correlated with sdo, cns predicting sdo, etc., ) as well.

#SEM assessing predictive validity w/ eri centrality

Cnat_SEM4 <- 'C_nat =~ 1*cns_1 + cns_2 + cns_3 + cns_4r + cns_5
              ERI_C =~ 1*eric_1 + eric_2 + eric_3'

Cnat_SEM4 <- sem(Cnat_SEM4, data = YNEES_W1, estimator = "MLR") #robust estimator with "MLR"

summary(Cnat_SEM4, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-19 ended normally after 34 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        17
## 
##                                                   Used       Total
##   Number of observations                           422         427
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                64.070      55.733
##   Degrees of freedom                                19          19
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.150
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1889.550    1280.457
##   Degrees of freedom                                28          28
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.476
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.976       0.971
##   Tucker-Lewis Index (TLI)                       0.964       0.957
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.977
##   Robust Tucker-Lewis Index (TLI)                            0.966
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5360.124   -5360.124
##   Scaling correction factor                                  1.459
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -5328.090   -5328.090
##   Scaling correction factor                                  1.296
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               10754.249   10754.249
##   Bayesian (BIC)                             10823.014   10823.014
##   Sample-size adjusted Bayesian (SABIC)      10769.067   10769.067
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.075       0.068
##   90 Percent confidence interval - lower         0.055       0.049
##   90 Percent confidence interval - upper         0.096       0.087
##   P-value H_0: RMSEA <= 0.050                    0.020       0.061
##   P-value H_0: RMSEA >= 0.080                    0.364       0.157
##                                                                   
##   Robust RMSEA                                               0.073
##   90 Percent confidence interval - lower                     0.051
##   90 Percent confidence interval - upper                     0.095
##   P-value H_0: Robust RMSEA <= 0.050                         0.044
##   P-value H_0: Robust RMSEA >= 0.080                         0.312
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.065       0.065
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.674    0.924
##     cns_2             0.944    0.029   32.892    0.000    1.580    0.909
##     cns_3             0.911    0.032   28.512    0.000    1.525    0.843
##     cns_4r           -0.179    0.055   -3.270    0.001   -0.299   -0.195
##     cns_5             0.859    0.038   22.819    0.000    1.438    0.804
##   ERI_C =~                                                              
##     eric_1            1.000                               0.914    0.779
##     eric_2            1.217    0.092   13.176    0.000    1.112    0.939
##     eric_3            0.926    0.096    9.664    0.000    0.846    0.549
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat ~~                                                              
##     ERI_C             0.216    0.094    2.287    0.022    0.141    0.141
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.478    0.091    5.267    0.000    0.478    0.146
##    .cns_2             0.522    0.087    6.006    0.000    0.522    0.173
##    .cns_3             0.950    0.122    7.794    0.000    0.950    0.290
##    .cns_4r            2.275    0.141   16.118    0.000    2.275    0.962
##    .cns_5             1.127    0.139    8.128    0.000    1.127    0.353
##    .eric_1            0.541    0.095    5.690    0.000    0.541    0.393
##    .eric_2            0.167    0.076    2.207    0.027    0.167    0.119
##    .eric_3            1.662    0.146   11.404    0.000    1.662    0.699
##     C_nat             2.801    0.159   17.651    0.000    1.000    1.000
##     ERI_C             0.835    0.113    7.422    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.854
##     cns_2             0.827
##     cns_3             0.710
##     cns_4r            0.038
##     cns_5             0.647
##     eric_1            0.607
##     eric_2            0.881
##     eric_3            0.301
resid(Cnat_SEM4)
## $type
## [1] "raw"
## 
## $cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5 eric_1 eric_2 eric_3
## cns_1   0.000                                                 
## cns_2  -0.006  0.000                                          
## cns_3   0.033 -0.020  0.000                                   
## cns_4r  0.045 -0.036  0.049  0.000                            
## cns_5  -0.020  0.035 -0.034 -0.078  0.000                     
## eric_1 -0.096  0.071 -0.051 -0.286  0.052  0.000              
## eric_2 -0.057 -0.025 -0.057 -0.234  0.040  0.002  0.000       
## eric_3  0.501  0.459  0.347 -0.318  0.242 -0.020  0.000  0.000

###Interesting that even when we look at the correlation among the complete sample not broken down by race, there is still a small but significant correlation between ERI centrality and christian nationalism.

#Multigroup model looking at eri centrality and cns

Cnat_SEM5 <- 'C_nat =~ 1*cns_1 + cns_2 + cns_3 + cns_4r + cns_5
              ERI_C =~ 1*eric_1 + eric_2 + eric_3'

Cnat_SEM5 <- sem(Cnat_SEM5, data = YNEES_W1, estimator = "MLR", group = "race2") #robust estimator with "MLR"
## Warning: lavaan->lav_data_full():  
##    group variable 'race2' contains missing values
summary(Cnat_SEM5, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-19 ended normally after 55 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        50
## 
##   Number of observations per group:               Used       Total
##     People of Color                                279         281
##     White                                          142         145
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                91.536      80.309
##   Degrees of freedom                                38          38
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.140
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     People of Color                             50.688      50.688
##     White                                       29.621      29.621
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1932.718    1347.074
##   Degrees of freedom                                56          56
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.435
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.971       0.967
##   Tucker-Lewis Index (TLI)                       0.958       0.952
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.974
##   Robust Tucker-Lewis Index (TLI)                            0.962
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5313.828   -5313.828
##   Scaling correction factor                                  1.281
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -5268.060   -5268.060
##   Scaling correction factor                                  1.220
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               10727.656   10727.656
##   Bayesian (BIC)                             10929.787   10929.787
##   Sample-size adjusted Bayesian (SABIC)      10771.122   10771.122
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.082       0.073
##   90 Percent confidence interval - lower         0.061       0.052
##   90 Percent confidence interval - upper         0.103       0.093
##   P-value H_0: RMSEA <= 0.050                    0.009       0.038
##   P-value H_0: RMSEA >= 0.080                    0.576       0.298
##                                                                   
##   Robust RMSEA                                               0.078
##   90 Percent confidence interval - lower                     0.054
##   90 Percent confidence interval - upper                     0.101
##   P-value H_0: Robust RMSEA <= 0.050                         0.030
##   P-value H_0: Robust RMSEA >= 0.080                         0.457
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.062       0.062
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [People of Color]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.631    0.920
##     cns_2             0.932    0.039   23.846    0.000    1.520    0.887
##     cns_3             0.930    0.041   22.808    0.000    1.517    0.837
##     cns_4r           -0.190    0.069   -2.744    0.006   -0.309   -0.195
##     cns_5             0.860    0.054   16.032    0.000    1.402    0.772
##   ERI_C =~                                                              
##     eric_1            1.000                               0.934    0.789
##     eric_2            1.161    0.123    9.417    0.000    1.085    0.914
##     eric_3            0.808    0.119    6.819    0.000    0.755    0.503
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat ~~                                                              
##     ERI_C             0.022    0.112    0.195    0.845    0.014    0.014
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             3.222    0.106   30.371    0.000    3.222    1.818
##    .cns_2             3.262    0.103   31.781    0.000    3.262    1.903
##    .cns_3             3.204    0.109   29.517    0.000    3.204    1.767
##    .cns_4r            2.670    0.095   28.165    0.000    2.670    1.686
##    .cns_5             3.656    0.109   33.611    0.000    3.656    2.012
##    .eric_1            4.774    0.071   67.382    0.000    4.774    4.034
##    .eric_2            4.774    0.071   67.210    0.000    4.774    4.024
##    .eric_3            4.197    0.090   46.722    0.000    4.197    2.797
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.480    0.110    4.375    0.000    0.480    0.153
##    .cns_2             0.627    0.125    5.008    0.000    0.627    0.213
##    .cns_3             0.986    0.144    6.852    0.000    0.986    0.300
##    .cns_4r            2.412    0.174   13.895    0.000    2.412    0.962
##    .cns_5             1.334    0.200    6.655    0.000    1.334    0.404
##    .eric_1            0.528    0.143    3.689    0.000    0.528    0.377
##    .eric_2            0.231    0.111    2.076    0.038    0.231    0.164
##    .eric_3            1.681    0.184    9.138    0.000    1.681    0.747
##     C_nat             2.660    0.196   13.586    0.000    1.000    1.000
##     ERI_C             0.872    0.142    6.126    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.847
##     cns_2             0.787
##     cns_3             0.700
##     cns_4r            0.038
##     cns_5             0.596
##     eric_1            0.623
##     eric_2            0.836
##     eric_3            0.253
## 
## 
## Group 2 [White]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.677    0.926
##     cns_2             0.953    0.045   21.158    0.000    1.598    0.943
##     cns_3             0.882    0.061   14.450    0.000    1.478    0.845
##     cns_4r           -0.164    0.093   -1.769    0.077   -0.275   -0.190
##     cns_5             0.891    0.046   19.308    0.000    1.494    0.873
##   ERI_C =~                                                              
##     eric_1            1.000                               0.903    0.784
##     eric_2            1.242    0.120   10.358    0.000    1.122    0.959
##     eric_3            1.113    0.164    6.786    0.000    1.006    0.629
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat ~~                                                              
##     ERI_C             0.601    0.187    3.213    0.001    0.397    0.397
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             3.831    0.152   25.202    0.000    3.831    2.115
##    .cns_2             3.908    0.142   27.483    0.000    3.908    2.306
##    .cns_3             3.754    0.147   25.574    0.000    3.754    2.146
##    .cns_4r            2.620    0.121   21.569    0.000    2.620    1.810
##    .cns_5             3.972    0.144   27.656    0.000    3.972    2.321
##    .eric_1            4.725    0.097   48.900    0.000    4.725    4.104
##    .eric_2            4.577    0.098   46.590    0.000    4.577    3.910
##    .eric_3            3.894    0.134   29.008    0.000    3.894    2.434
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.469    0.167    2.817    0.005    0.469    0.143
##    .cns_2             0.317    0.079    4.011    0.000    0.317    0.110
##    .cns_3             0.873    0.222    3.932    0.000    0.873    0.285
##    .cns_4r            2.019    0.240    8.397    0.000    2.019    0.964
##    .cns_5             0.696    0.111    6.302    0.000    0.696    0.238
##    .eric_1            0.510    0.100    5.078    0.000    0.510    0.385
##    .eric_2            0.111    0.075    1.482    0.138    0.111    0.081
##    .eric_3            1.548    0.211    7.338    0.000    1.548    0.605
##     C_nat             2.812    0.285    9.861    0.000    1.000    1.000
##     ERI_C             0.816    0.188    4.350    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.857
##     cns_2             0.890
##     cns_3             0.715
##     cns_4r            0.036
##     cns_5             0.762
##     eric_1            0.615
##     eric_2            0.919
##     eric_3            0.395
resid(Cnat_SEM5)
## $`People of Color`
## $`People of Color`$type
## [1] "raw"
## 
## $`People of Color`$cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5 eric_1 eric_2 eric_3
## cns_1   0.000                                                 
## cns_2   0.003  0.000                                          
## cns_3   0.028 -0.041  0.000                                   
## cns_4r  0.051 -0.035  0.053  0.000                            
## cns_5  -0.042  0.044  0.011 -0.157  0.000                     
## eric_1 -0.162  0.085 -0.089 -0.346  0.054  0.000              
## eric_2 -0.083  0.025 -0.081 -0.224  0.116  0.000  0.000       
## eric_3  0.455  0.538  0.284 -0.315  0.196 -0.001  0.000  0.000
## 
## $`People of Color`$mean
##  cns_1  cns_2  cns_3 cns_4r  cns_5 eric_1 eric_2 eric_3 
##      0      0      0      0      0      0      0      0 
## 
## 
## $White
## $White$type
## [1] "raw"
## 
## $White$cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5 eric_1 eric_2 eric_3
## cns_1   0.000                                                 
## cns_2  -0.027  0.000                                          
## cns_3   0.036  0.023  0.000                                   
## cns_4r  0.030 -0.046  0.038  0.000                            
## cns_5   0.025  0.032 -0.124  0.076  0.000                     
## eric_1  0.029  0.036  0.044 -0.175  0.028  0.000              
## eric_2  0.035 -0.081  0.055 -0.264 -0.113  0.004  0.000       
## eric_3  0.574  0.297  0.483 -0.318  0.267 -0.078  0.003  0.000
## 
## $White$mean
##  cns_1  cns_2  cns_3 cns_4r  cns_5 eric_1 eric_2 eric_3 
##      0      0      0      0      0      0      0      0

###Wow! As hypothesized though, White people are driving this correlation between eri centrality and christian nationalism. For White people (r = .40, p = .001), while for POC the correlation is not sig. (r = .01, p = .85). Model fit is pretty good too.

#Multigroup SEM assessing predictive validity w/ sdod_1

Cnat_SEM7 <- 'C_nat =~ 1*cns_1 + cns_2 + cns_3 + cns_4r + cns_5
              sdod_1 ~~ C_nat'

Cnat_SEM7 <- sem(Cnat_SEM7, data = YNEES_W1, estimator = "MLR", group = "race2") #robust estimator with "MLR"
## Warning: lavaan->lav_data_full():  
##    group variable 'race2' contains missing values
summary(Cnat_SEM7, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-19 ended normally after 56 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        36
## 
##   Number of observations per group:               Used       Total
##     People of Color                                279         281
##     White                                          142         145
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                40.807      37.146
##   Degrees of freedom                                18          18
##   P-value (Chi-square)                           0.002       0.005
##   Scaling correction factor                                  1.099
##     Yuan-Bentler correction (Mplus variant)                       
##   Test statistic for each group:
##     People of Color                             10.643      10.643
##     White                                       26.503      26.503
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1487.070     968.834
##   Degrees of freedom                                30          30
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.535
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.984       0.980
##   Tucker-Lewis Index (TLI)                       0.974       0.966
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.985
##   Robust Tucker-Lewis Index (TLI)                            0.976
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -4287.799   -4287.799
##   Scaling correction factor                                  1.224
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -4267.396   -4267.396
##   Scaling correction factor                                  1.182
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                8647.599    8647.599
##   Bayesian (BIC)                              8793.133    8793.133
##   Sample-size adjusted Bayesian (SABIC)       8678.894    8678.894
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.078       0.071
##   90 Percent confidence interval - lower         0.046       0.039
##   90 Percent confidence interval - upper         0.109       0.102
##   P-value H_0: RMSEA <= 0.050                    0.073       0.123
##   P-value H_0: RMSEA >= 0.080                    0.481       0.343
##                                                                   
##   Robust RMSEA                                               0.075
##   90 Percent confidence interval - lower                     0.040
##   90 Percent confidence interval - upper                     0.109
##   P-value H_0: Robust RMSEA <= 0.050                         0.111
##   P-value H_0: Robust RMSEA >= 0.080                         0.426
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.028       0.028
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## 
## Group 1 [People of Color]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.635    0.923
##     cns_2             0.927    0.038   24.427    0.000    1.515    0.884
##     cns_3             0.931    0.041   22.794    0.000    1.522    0.839
##     cns_4r           -0.189    0.068   -2.754    0.006   -0.308   -0.195
##     cns_5             0.855    0.053   16.122    0.000    1.397    0.769
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat ~~                                                              
##     sdod_1            1.228    0.219    5.606    0.000    0.751    0.389
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             3.222    0.106   30.371    0.000    3.222    1.818
##    .cns_2             3.262    0.103   31.781    0.000    3.262    1.903
##    .cns_3             3.204    0.109   29.517    0.000    3.204    1.767
##    .cns_4r            2.670    0.095   28.165    0.000    2.670    1.686
##    .cns_5             3.656    0.109   33.611    0.000    3.656    2.012
##     sdod_1            3.606    0.116   31.185    0.000    3.606    1.867
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.467    0.107    4.368    0.000    0.467    0.149
##    .cns_2             0.644    0.126    5.114    0.000    0.644    0.219
##    .cns_3             0.972    0.143    6.809    0.000    0.972    0.296
##    .cns_4r            2.413    0.173   13.909    0.000    2.413    0.962
##    .cns_5             1.348    0.200    6.740    0.000    1.348    0.409
##     sdod_1            3.730    0.216   17.232    0.000    3.730    1.000
##     C_nat             2.674    0.194   13.769    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.851
##     cns_2             0.781
##     cns_3             0.704
##     cns_4r            0.038
##     cns_5             0.591
## 
## 
## Group 2 [White]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat =~                                                              
##     cns_1             1.000                               1.680    0.928
##     cns_2             0.949    0.043   21.947    0.000    1.595    0.941
##     cns_3             0.884    0.060   14.720    0.000    1.485    0.849
##     cns_4r           -0.166    0.092   -1.801    0.072   -0.279   -0.192
##     cns_5             0.886    0.046   19.426    0.000    1.488    0.869
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   C_nat ~~                                                              
##     sdod_1            1.829    0.297    6.161    0.000    1.089    0.521
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             3.831    0.152   25.202    0.000    3.831    2.115
##    .cns_2             3.908    0.142   27.483    0.000    3.908    2.306
##    .cns_3             3.754    0.147   25.574    0.000    3.754    2.146
##    .cns_4r            2.620    0.121   21.569    0.000    2.620    1.810
##    .cns_5             3.972    0.144   27.656    0.000    3.972    2.321
##     sdod_1            3.937    0.175   22.442    0.000    3.937    1.883
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .cns_1             0.458    0.157    2.914    0.004    0.458    0.140
##    .cns_2             0.327    0.077    4.245    0.000    0.327    0.114
##    .cns_3             0.853    0.220    3.883    0.000    0.853    0.279
##    .cns_4r            2.017    0.240    8.404    0.000    2.017    0.963
##    .cns_5             0.715    0.114    6.248    0.000    0.715    0.244
##     sdod_1            4.369    0.319   13.692    0.000    4.369    1.000
##     C_nat             2.823    0.281   10.043    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     cns_1             0.860
##     cns_2             0.886
##     cns_3             0.721
##     cns_4r            0.037
##     cns_5             0.756
resid(Cnat_SEM7)
## $`People of Color`
## $`People of Color`$type
## [1] "raw"
## 
## $`People of Color`$cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5 sdod_1
## cns_1   0.000                                   
## cns_2   0.006  0.000                            
## cns_3   0.015 -0.040  0.000                     
## cns_4r  0.051 -0.038  0.053  0.000              
## cns_5  -0.040  0.059  0.012 -0.159  0.000       
## sdod_1  0.046 -0.103  0.159 -0.024 -0.164  0.000
## 
## $`People of Color`$mean
##  cns_1  cns_2  cns_3 cns_4r  cns_5 sdod_1 
##      0      0      0      0      0      0 
## 
## 
## $White
## $White$type
## [1] "raw"
## 
## $White$cov
##         cns_1  cns_2  cns_3 cns_4r  cns_5 sdod_1
## cns_1   0.000                                   
## cns_2  -0.027  0.000                            
## cns_3   0.019  0.016  0.000                     
## cns_4r  0.037 -0.041  0.045  0.000              
## cns_5   0.030  0.046 -0.126  0.080  0.000       
## sdod_1  0.118 -0.094  0.346 -0.531 -0.312  0.000
## 
## $White$mean
##  cns_1  cns_2  cns_3 cns_4r  cns_5 sdod_1 
##      0      0      0      0      0      0

###As you’d expect as well, SDO is sig. correlated with christian nationalism for both groups, but the correlation is a bit stronger for White folks.

#I guess we should run some predicitve validity models too? These variables I feel like theoretically would precede more christian nationalism rather than be an outocome of it, what do you think? It seemed at first to me that we’d be running a bunch of model but as I run them, I can see how some DVs would be interesting to assess.

#Visualize christian nationalism by race

# Filter out NA values in race2 column
YNEES_clean <- YNEES_W1 %>%
  filter(!is.na(race))

ggplot(YNEES_clean, aes(x = race2, y = c_nat)) +
  geom_boxplot() + # Customize outliers
  geom_jitter(aes(color = race2), width = 0.2) + # Add jittered points
  scale_color_viridis_d(option = "D") + # Discrete viridis palette
  labs(title = "Box Plot for Christian Nationalism by Race", x = "Race", y = "c_nat") +
  theme_classic()
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_point()`).

#Christian nationalism by gender

ggplot(YNEES, aes(x = gender, y = c_nat)) +
  geom_boxplot() + # Customize outliers
  geom_jitter(aes(color = gender), width = 0.2) + # Add jittered points
  scale_color_viridis_d(option = "D") + # Discrete viridis palette
  labs(title = "Box Plot for Christian Nationalism by Gender", x = "Gender", y = "c_nat") +
  theme_classic()
## Warning: Removed 6 rows containing non-finite outside the scale range
## (`stat_boxplot()`).
## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_point()`).