GSS Factor Analysis

Author

Cristina E. Martinez, MPH

Quarto

Simple factor analysis of key variables in R

library(readxl)
gss <- read_excel("C:/Users/chrys/Documents/UTSA/Dissertation/GSS Data/R and Excel/GSS.xlsx")
# Recode
gss <- gss %>%
  mutate(
    confed.rc = case_when(confed %in% "A GREAT DEAL" ~ 1,
                          confed %in% "ONLY SOME" ~ 2, 
                          confed %in% "HARDLY ANY" ~ 3),
    conmedic.rc = case_when(conmedic %in% "A GREAT DEAL" ~ 1,
                            conmedic %in% "ONLY SOME" ~ 2, 
                            conmedic %in% "HARDLY ANY" ~ 3),
    conjudge.rc = case_when(conjudge %in% "A GREAT DEAL" ~ 1,
                            conjudge %in% "ONLY SOME" ~ 2, 
                            conjudge %in% "HARDLY ANY" ~ 3),
    consci.rc = case_when(consci %in% "A GREAT DEAL" ~ 1,
                          consci %in% "ONLY SOME" ~ 2, 
                          consci %in% "HARDLY ANY" ~ 3),
    conlegis.rc = case_when(conlegis %in% "A GREAT DEAL" ~ 1,
                            conlegis %in% "ONLY SOME" ~ 2, 
                            conlegis %in% "HARDLY ANY" ~ 3),
    toodifme.rc = case_when(toodifme %in% "STRONGLY AGREE" ~ 1,
                            toodifme %in% "AGREE" ~ 2,
                            toodifme %in% "NEITHER AGREE NOR DISAGREE" ~ 3, 
                            toodifme %in% "DISAGREE" ~ 4, 
                            toodifme %in% "STRONGLY DISAGREE" ~ 5),
    othssame.rc = case_when(othssame %in% "STRONGLY AGREE" ~ 1,
                            othssame %in% "AGREE" ~ 2,
                            othssame %in% "NEITHER AGREE NOR DISAGREE" ~ 3, 
                            othssame %in% "DISAGREE" ~ 4, 
                            othssame %in% "STRONGLY DISAGREE" ~ 5),
    helpharm.rc = case_when(helpharm %in% "Agree strongly" ~ 1,
                            helpharm %in% "Agree" ~ 2,
                            helpharm %in% "Neither agree nor disagree" ~ 3,
                            helpharm %in% "Disagree" ~ 4, 
                            helpharm %in% "Disagree strongly" ~ 5),
    grneffme.rc = case_when(grneffme %in% "Agree strongly" ~ 1,
                            grneffme %in% "Agree" ~ 2,
                            grneffme %in% "Neither agree nor disagree" ~ 3,
                            grneffme %in% "Disagree" ~ 4, 
                            grneffme %in% "Disagree strongly" ~ 5),
    grncon.rc = case_when(grncon %in% "Not at all concerned" ~ 5, 
                          grncon %in% "2" ~ 4, 
                          grncon %in% "3" ~ 3,
                          grncon %in% "4" ~ 2, 
                          grncon %in% "Very concerned" ~ 1)
  )
govt10 <- gss %>%
  filter(year == 2010) %>%
  select(confed.rc:conlegis.rc) %>%
  filter(complete.cases(.))

govt21 <- gss %>%
  filter(year == 2021) %>%
  select(confed.rc:conlegis.rc) %>%
  filter(complete.cases(.))

envmt10 <- gss %>%
  filter(year == 2010) %>%
  select(toodifme.rc:grncon.rc) %>%
  filter(complete.cases(.))

envmt21 <- gss %>%
  filter(year == 2021) %>%
  select(toodifme.rc:grncon.rc) %>%
  filter(complete.cases(.))

Trust in government 2010

gvt10.fact <- factanal(x = govt10, factors = 2)
gvt10.fact

Call:
factanal(x = govt10, factors = 2)

Uniquenesses:
  confed.rc conmedic.rc conjudge.rc   consci.rc conlegis.rc 
      0.525       0.819       0.591       0.439       0.467 

Loadings:
            Factor1 Factor2
confed.rc   0.647   0.239  
conmedic.rc 0.186   0.382  
conjudge.rc 0.424   0.479  
consci.rc   0.127   0.738  
conlegis.rc 0.709   0.175  

               Factor1 Factor2
SS loadings      1.151   1.008
Proportion Var   0.230   0.202
Cumulative Var   0.230   0.432

Test of the hypothesis that 2 factors are sufficient.
The chi square statistic is 0.48 on 1 degree of freedom.
The p-value is 0.487 

Trust in government 2021

gvt21.fact <- factanal(x = govt21, factors = 2)
gvt21.fact

Call:
factanal(x = govt21, factors = 2)

Uniquenesses:
  confed.rc conmedic.rc conjudge.rc   consci.rc conlegis.rc 
      0.660       0.432       0.719       0.574       0.197 

Loadings:
            Factor1 Factor2
confed.rc   0.266   0.519  
conmedic.rc 0.744   0.120  
conjudge.rc 0.446   0.286  
consci.rc   0.623   0.196  
conlegis.rc 0.136   0.886  

               Factor1 Factor2
SS loadings      1.229   1.189
Proportion Var   0.246   0.238
Cumulative Var   0.246   0.484

Test of the hypothesis that 2 factors are sufficient.
The chi square statistic is 0.95 on 1 degree of freedom.
The p-value is 0.331 

Environmental 2010

envmt10.fact <- factanal(x = envmt10, factors = 2)
envmt10.fact

Call:
factanal(x = envmt10, factors = 2)

Uniquenesses:
toodifme.rc othssame.rc helpharm.rc grneffme.rc   grncon.rc 
      0.488       0.580       0.790       0.899       0.058 

Loadings:
            Factor1 Factor2
toodifme.rc  0.704  -0.130 
othssame.rc  0.621  -0.186 
helpharm.rc  0.458         
grneffme.rc -0.114   0.297 
grncon.rc            0.971 

               Factor1 Factor2
SS loadings      1.103   1.082
Proportion Var   0.221   0.216
Cumulative Var   0.221   0.437

Test of the hypothesis that 2 factors are sufficient.
The chi square statistic is 0.45 on 1 degree of freedom.
The p-value is 0.504 

Environmental 2021

envmt21.fact <- factanal(x = envmt21, factors = 2)
envmt21.fact

Call:
factanal(x = envmt21, factors = 2)

Uniquenesses:
toodifme.rc othssame.rc helpharm.rc grneffme.rc   grncon.rc 
      0.555       0.578       0.741       0.820       0.005 

Loadings:
            Factor1 Factor2
toodifme.rc -0.186   0.641 
othssame.rc -0.185   0.623 
helpharm.rc          0.501 
grneffme.rc  0.384  -0.181 
grncon.rc    0.988  -0.138 

               Factor1 Factor2
SS loadings       1.20   1.101
Proportion Var    0.24   0.220
Cumulative Var    0.24   0.460

Test of the hypothesis that 2 factors are sufficient.
The chi square statistic is 3.85 on 1 degree of freedom.
The p-value is 0.0498