1 Load Libraries

library(digest) # to create UIDs, digest()
library(dplyr) # for recoding
library(psych) # for describe()
library(kableExtra) # for tables
library(ggplot2) # for plots
library(tidyr) # for histogram function
library(nFactors) # for factor analysis

2 Load Data

2.1 Notes

  • issue with s23_pre – multiple select for Q5, Q6, & Q7 not enabled
f22_post <- read.csv(file="data/FA22 Post_September 21, 2023_18.07.csv", header = F, na.strings = c(""," "))
list <- data.frame(subset(t(f22_post), select=c(1:2)))
f22_post <- f22_post[-c(1,2,3),]
colnames(f22_post) <- list[[1]]
f22_post <- subset(f22_post, Progress == 100)

s23_pre <- read.csv(file="data/SP 23 Pre_January 27, 2023_10.06.csv", header = F, na.strings = c(""," "))
list <- data.frame(subset(t(s23_pre), select=c(1:2)))
s23_pre <- s23_pre[-c(1,2,3),]
colnames(s23_pre) <- list[[1]]
s23_pre <- subset(s23_pre, Progress == 100)

s23_post <- read.csv(file="data/SP 23 Post_May 3, 2023_19.10.csv", header = F, na.strings = c(""," "))
list <- data.frame(subset(t(s23_post), select=c(1:2)))
s23_post <- s23_post[-c(1,2,3),]
colnames(s23_post) <- list[[1]]
s23_post <- subset(s23_post, Progress == 100)

2.2 Create IDs

f22_post$Q28 <- tolower(f22_post$Q28)
f22_post$UID <- as.vector(sapply(f22_post$Q28, digest, algo="md5"))
f22_post <- subset(f22_post, select=-c(3:4, 7:17, Q28))

s23_pre$Q28 <- tolower(s23_pre$Q28)
s23_pre$UID <- as.vector(sapply(s23_pre$Q28, digest, algo="md5"))
s23_pre <- subset(s23_pre, select=-c(3:4, 7:17, Q28))

s23_post$Q28 <- tolower(s23_post$Q28)
s23_post$UID <- as.vector(sapply(s23_post$Q28, digest, algo="md5"))
s23_post <- subset(s23_post, select=-c(3:4, 7:17, Q28))

2.3 Variable Names

pre_vars <- c("start","end","progress","time",
               "major","classes","classestxt","gender","gendertxt","sexuality","sexualitytxt","race","racetxt","ethnicity","parented1","parented2","immi1","immi2","immi3",
               "pre_int1","pre_int2","pre_int3","pre_int4","pre_int5","pre_int6","pre_int7","pre_int8","pre_int9","pre_int10",
               "pre_ase1","pre_ase2","pre_ase3","pre_ase4","pre_ase5",
               "pre_id1","pre_id2","pre_id3","pre_id4","pre_id5","pre_id6","pre_id7","pre_id8","pre_id9","pre_id10",
               "pre_ar1","pre_ar2","pre_ar3","pre_ar4","pre_ar5","pre_ar6","pre_ar7","pre_ar8","pre_ar9","pre_ar10","pre_ar11","pre_ar12","pre_ar13",
               "UID")

post_vars <- c("start","end","progress","time",
               "post_int1","post_int2","post_int3","post_int4","post_int5","post_int6","post_int7","post_int8","post_int9","post_int10",
               "post_ase1","post_ase2","post_ase3","post_ase4","post_ase5",
               "post_id1","post_id2","post_id3","post_id4","post_id5","post_id6","post_id7","post_id8","post_id9","post_id10",
               "post_ar1","post_ar2","post_ar3","post_ar4","post_ar5","post_ar6","post_ar7","post_ar8","post_ar9","post_ar10","post_ar11","post_ar12","post_ar13",
               "UID")

colnames(f22_post) <- pre_vars
colnames(s23_pre) <- pre_vars

colnames(s23_post) <- post_vars

3 Clean Data

3.1 Recode Function

# Function to recode selected columns by position as numeric
recode_to_numeric <- function(data, columns_to_recode) {
  recoded_data <- data %>%
    mutate(across(
      .cols = columns_to_recode,
      .fns = as.numeric
    ))
  return(recoded_data)
}

columns_to_recode <- c(5,8,10,12,15:57)
f22_post <- recode_to_numeric(f22_post, columns_to_recode)
s23_pre <- recode_to_numeric(s23_pre, columns_to_recode)

columns_to_recode <- c(5:42)
s23_post <- recode_to_numeric(s23_post, columns_to_recode)

3.2 Recode Major

f22_post <- f22_post %>%
  mutate(major = recode(major,
                        `1` = "Current major",
                        `2` = "Current minor",
                        `3` = "Planning to major",
                        `4` = "Planning to minor",
                        `5` = "Considering a major or minor",
                        `6` = "No, my studies are in a different area"))

table(f22_post$major)
## 
##     Current major     Current minor Planning to major Planning to minor 
##               106                14                 4                 3
s23_pre <- s23_pre %>%
  mutate(major = recode(major,
                        `1` = "Current major",
                        `2` = "Current minor",
                        `3` = "Planning to major",
                        `4` = "Planning to minor",
                        `5` = "Considering a major or minor",
                        `6` = "No, my studies are in a different area"))

table(s23_pre$major)
## 
##                          Current major                          Current minor 
##                                     60                                     13 
## No, my studies are in a different area                      Planning to major 
##                                      2                                      1 
##                      Planning to minor 
##                                      1

3.3 Recode Gender

f22_post <- f22_post %>%
  mutate(gender = recode(gender,
                                 `1` = "Woman",
                                 `2` = "Man",
                                 `3` = "Agender",
                                 `4` = "Genderqueer",
                                 `5` = "Non-binary",
                                 `6` = "Cisgender",
                                 `7` = "Transgender",
                                 `8` = "Not listed",
                                 `9` = "Prefer not to say"))

table(f22_post$gender)
## 
##     Agender         Man  Non-binary Transgender       Woman 
##           1          36           4           1          84
s23_pre <- s23_pre %>%
  mutate(gender = recode(gender,
                                 `1` = "Woman",
                                 `2` = "Man",
                                 `3` = "Agender",
                                 `4` = "Genderqueer",
                                 `5` = "Non-binary",
                                 `6` = "Cisgender",
                                 `7` = "Transgender",
                                 `8` = "Not listed",
                                 `9` = "Prefer not to say"))

table(s23_pre$gender)
## 
##       Genderqueer               Man        Non-binary Prefer not to say 
##                 1                10                 1                 1 
##             Woman 
##                64

3.4 Recode Sexuality

f22_post <- f22_post %>%
  mutate(sexuality = recode(sexuality,
                                 `1` = "Heterosexual/straight",
                                 `2` = "Homosexual/gay/lesbian",
                                 `3` = "Bisexual",
                                 `4` = "Pansexual",
                                 `5` = "Asexual",
                                 `6` = "Not listed",
                                 `7` = "Prefer not to say"))

table(f22_post$sexuality)
## 
##                Asexual               Bisexual  Heterosexual/straight 
##                      3                     13                     99 
## Homosexual/gay/lesbian             Not listed              Pansexual 
##                      5                      3                      3 
##      Prefer not to say 
##                      1
s23_pre <- s23_pre %>%
  mutate(sexuality = recode(sexuality,
                                 `1` = "Heterosexual/straight",
                                 `2` = "Homosexual/gay/lesbian",
                                 `3` = "Bisexual",
                                 `4` = "Pansexual",
                                 `5` = "Asexual",
                                 `6` = "Not listed",
                                 `7` = "Prefer not to say"))

table(s23_pre$sexuality)
## 
##               Bisexual  Heterosexual/straight Homosexual/gay/lesbian 
##                     11                     60                      2 
##             Not listed              Pansexual 
##                      1                      3

3.5 Recode Race

f22_post <- f22_post %>%
  mutate(race = recode(race,
                               `1` = "AIAN",
                               `2` = "Asian",
                               `3` = "Black/Afam",
                               `4` = "Latine",
                               `5` = "MENA",
                               `6` = "NHPI",
                               `7` = "White",
                               `8` = "Not listed",
                               `9` = "Prefer not to say"))

table(f22_post$race)
## 
##      Asian Black/Afam     Latine       MENA Not listed      White 
##         20          9          6          2          6         84
s23_pre <- s23_pre %>%
  mutate(race = recode(race,
                               `1` = "AIAN",
                               `2` = "Asian",
                               `3` = "Black/Afam",
                               `4` = "Latine",
                               `5` = "MENA",
                               `6` = "NHPI",
                               `7` = "White",
                               `8` = "Not listed",
                               `9` = "Prefer not to say"))

table(s23_pre$race)
## 
##             Asian        Black/Afam            Latine              MENA 
##                 7                 4                 2                 1 
##        Not listed Prefer not to say             White 
##                 1                 1                61

3.6 Recode First Gen

f22_post <- f22_post %>%
  mutate(firstgen = ifelse(parented1 >= 4 | parented2 >= 4, "congen", "firstgen"))

s23_pre <- s23_pre %>%
  mutate(firstgen = ifelse(parented1 >= 4 | parented2 >= 4, "congen", "firstgen"))

table(f22_post$firstgen)
## 
##   congen firstgen 
##       94       33
table(s23_pre$firstgen)
## 
##   congen firstgen 
##       54       23

3.7 Recode Immigration Background

f22_post <- f22_post %>%
  mutate(immi = case_when(
    immi1 == 1 & (immi2 == 2 | immi3 == 2) ~ "secondgen",
    immi1 == 2 ~ "firstgen",
    TRUE ~ "thirdgen"
  ))

s23_pre <- s23_pre %>%
  mutate(immi = case_when(
    immi1 == 1 & (immi2 == 2 | immi3 == 2) ~ "secondgen",
    immi1 == 2 ~ "firstgen",
    TRUE ~ "thirdgen"
  ))

table(f22_post$immi)
## 
##  firstgen secondgen  thirdgen 
##        14        24        89
table(s23_pre$immi)
## 
##  firstgen secondgen  thirdgen 
##         3         8        66

3.8 Reverse Code

f22_post$pre_int3 <- abs(f22_post$pre_int3 - 5)
s23_pre$pre_int3 <- abs(s23_pre$pre_int3 - 5)
s23_post$post_int3 <- abs(s23_post$post_int3 - 5)

f22_post$pre_ase3 <- abs(f22_post$pre_ase3 - 5)
s23_pre$pre_ase3 <- abs(s23_pre$pre_ase3 - 5)
s23_post$post_ase3 <- abs(s23_post$post_ase3 - 5)

f22_post$pre_ase5 <- abs(f22_post$pre_ase5 - 5)
s23_pre$pre_ase5 <- abs(s23_pre$pre_ase5 - 5)
s23_post$post_ase5 <- abs(s23_post$post_ase5 - 5)

4 Item Normality

temp1 <- subset(f22_post, select=c(20:57))
temp2 <- subset(s23_pre, select=c(20:57))
temp3 <- subset(s23_post, select=c(5:42))
colnames(temp3) <- colnames(temp2)
temp <- rbind.data.frame(temp1, temp2, temp3)

desc <- describe(temp)
kable(round(desc, digits = 2)) %>%
    kable_styling() %>%
    row_spec(which(desc$kurtosis > 2), bold = T) %>%
    row_spec(which(desc$kurtosis < -2), bold = T) %>%
    row_spec(which(desc$skew > 2), italic = T) %>%
    row_spec(which(desc$skew < -2), italic = T)
vars n mean sd median trimmed mad min max range skew kurtosis se
pre_int1 1 272 3.67 0.57 4.0 3.76 0.00 1 4 3 -2.01 5.28 0.03
pre_int2 2 272 3.45 0.62 4.0 3.51 0.00 1 4 3 -1.05 1.70 0.04
pre_int3 3 272 3.61 0.60 4.0 3.70 0.00 1 4 3 -1.56 2.72 0.04
pre_int4 4 272 3.39 0.62 3.0 3.43 0.00 1 4 3 -0.95 2.07 0.04
pre_int5 5 272 3.57 0.57 4.0 3.63 0.00 1 4 3 -1.29 2.53 0.03
pre_int6 6 272 3.69 0.50 4.0 3.75 0.00 1 4 3 -1.35 1.89 0.03
pre_int7 7 272 3.59 0.59 4.0 3.68 0.00 2 4 2 -1.12 0.23 0.04
pre_int8 8 272 3.41 0.61 3.0 3.47 1.48 2 4 2 -0.51 -0.65 0.04
pre_int9 9 272 3.43 0.63 4.0 3.51 0.00 2 4 2 -0.66 -0.56 0.04
pre_int10 10 271 3.18 0.66 3.0 3.24 0.00 1 4 3 -0.44 0.24 0.04
pre_ase1 11 272 3.43 0.53 3.0 3.44 0.00 2 4 2 -0.04 -1.33 0.03
pre_ase2 12 272 3.11 0.58 3.0 3.15 0.00 1 4 3 -0.35 1.20 0.04
pre_ase3 13 270 3.00 0.72 3.0 3.02 0.00 1 4 3 -0.24 -0.45 0.04
pre_ase4 14 271 2.62 0.65 3.0 2.60 0.00 1 4 3 -0.07 -0.21 0.04
pre_ase5 15 270 2.73 0.70 3.0 2.74 0.00 1 4 3 -0.49 0.28 0.04
pre_id1 16 268 3.44 0.62 3.5 3.50 0.74 1 4 3 -0.82 0.54 0.04
pre_id2 17 269 3.24 0.70 3.0 3.31 1.48 1 4 3 -0.56 -0.11 0.04
pre_id3 18 269 3.00 0.59 3.0 3.00 0.00 2 4 2 0.00 -0.10 0.04
pre_id4 19 268 3.35 0.62 3.0 3.40 0.00 1 4 3 -0.49 -0.17 0.04
pre_id5 20 268 3.18 0.62 3.0 3.23 0.00 1 4 3 -0.33 0.26 0.04
pre_id6 21 269 3.24 0.68 3.0 3.31 0.00 1 4 3 -0.48 -0.23 0.04
pre_id7 22 270 3.42 0.56 3.0 3.44 0.00 1 4 3 -0.42 -0.05 0.03
pre_id8 23 269 3.34 0.65 3.0 3.41 1.48 1 4 3 -0.63 0.13 0.04
pre_id9 24 270 3.50 0.55 4.0 3.53 0.00 2 4 2 -0.47 -0.91 0.03
pre_id10 25 270 3.34 0.58 3.0 3.37 0.00 2 4 2 -0.20 -0.69 0.04
pre_ar1 26 269 3.10 0.73 3.0 3.13 1.48 1 4 3 -0.27 -0.74 0.04
pre_ar2 27 269 3.20 0.76 3.0 3.27 1.48 1 4 3 -0.56 -0.43 0.05
pre_ar3 28 268 3.03 0.86 3.0 3.10 1.48 1 4 3 -0.52 -0.50 0.05
pre_ar4 29 266 3.16 0.81 3.0 3.23 1.48 1 4 3 -0.60 -0.41 0.05
pre_ar5 30 266 3.02 0.84 3.0 3.07 1.48 1 4 3 -0.41 -0.67 0.05
pre_ar6 31 267 3.00 0.87 3.0 3.08 1.48 1 4 3 -0.55 -0.45 0.05
pre_ar7 32 267 3.21 0.74 3.0 3.28 1.48 1 4 3 -0.58 -0.24 0.05
pre_ar8 33 268 2.31 0.97 2.0 2.26 1.48 1 4 3 0.21 -0.96 0.06
pre_ar9 34 268 2.91 0.91 3.0 2.96 1.48 1 4 3 -0.32 -0.89 0.06
pre_ar10 35 269 2.87 0.75 3.0 2.87 1.48 1 4 3 -0.10 -0.59 0.05
pre_ar11 36 269 3.05 0.72 3.0 3.07 0.00 1 4 3 -0.25 -0.56 0.04
pre_ar12 37 269 3.03 0.76 3.0 3.06 1.48 1 4 3 -0.31 -0.56 0.05
pre_ar13 38 269 2.94 0.82 3.0 2.97 1.48 1 4 3 -0.33 -0.56 0.05

5 Factor Analysis

5.1 Histogram Function

plot_all_histograms <- function(data) {
  # Gather the data into long format for easier plotting
  data_long <- data %>%
    gather(variable, value)

  # Create the histogram plot
  ggplot(data_long, aes(x = value)) +
    geom_histogram(binwidth = 1, fill = "blue", color = "black") +
    labs(title = "Histograms of Variables",
         x = "Value", y = "Frequency") +
    theme_minimal() +
    theme(plot.title = element_text(hjust = 0.5)) +
    facet_wrap(~ variable, scales = "free")
}

5.2 Fascination & Value

  • Interest = int2, int4, int6
  • Value = int8, int9, int10
temp1 <- subset(f22_post, select=c(grep("int",colnames(f22_post))))
temp2 <- subset(s23_pre, select=c(grep("int",colnames(s23_pre))))
d <- rbind.data.frame(temp1, temp2)
d <- subset(d, select=-c(pre_int1))
plot_all_histograms(d)

colnames(d) <- c("I look forward to my psychology classes.",
                 "I don't care about learning psychology.",
                 "I am curious about recent discoveries in psychology.",
                 "Psychology makes the world a better place to live.",
                 "In general, I find psychology ________",
                 "I wonder why people think, feel, and behave the way they do.",
                 "Knowing psychology is important for:",
                 "Knowing psychology helps me understand how the world works.",
                 "Thinking like a psychologist will help me do well in:")

ev <- eigen(cor(na.omit(d))) # get eigenvalues
ap <- parallel(subject = nrow(na.omit(d)), var = ncol(na.omit(d)),
               rep = 100,cent = .05)
nS <- nScree(x = ev$values, aparallel = ap$eigen$qevpea)
plotnScree(nS)

fit <- factanal(na.omit(d), 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.2, sort = TRUE) 
## 
## Call:
## factanal(x = na.omit(d), factors = 2, rotation = "promax")
## 
## Uniquenesses:
##                     I look forward to my psychology classes. 
##                                                        0.587 
##                      I don't care about learning psychology. 
##                                                        0.663 
##         I am curious about recent discoveries in psychology. 
##                                                        0.359 
##           Psychology makes the world a better place to live. 
##                                                        0.548 
##                       In general, I find psychology ________ 
##                                                        0.608 
## I wonder why people think, feel, and behave the way they do. 
##                                                        0.807 
##                         Knowing psychology is important for: 
##                                                        0.625 
##  Knowing psychology helps me understand how the world works. 
##                                                        0.548 
##        Thinking like a psychologist will help me do well in: 
##                                                        0.672 
## 
## Loadings:
##                                                              Factor1 Factor2
## Knowing psychology is important for:                          0.702         
## Knowing psychology helps me understand how the world works.   0.672         
## Thinking like a psychologist will help me do well in:         0.591         
## I look forward to my psychology classes.                              0.607 
## I am curious about recent discoveries in psychology.                  0.842 
## Psychology makes the world a better place to live.                    0.708 
## I don't care about learning psychology.                       0.409   0.238 
## In general, I find psychology ________                        0.410   0.291 
## I wonder why people think, feel, and behave the way they do.  0.469         
## 
##                Factor1 Factor2
## SS loadings      1.862   1.758
## Proportion Var   0.207   0.195
## Cumulative Var   0.207   0.402
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000  -0.582
## Factor2  -0.582   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 73.98 on 19 degrees of freedom.
## The p-value is 1.98e-08

5.3 Academic Self-Efficacy

temp1 <- subset(f22_post, select=c(grep("ase",colnames(f22_post))))
temp2 <- subset(s23_pre, select=c(grep("ase",colnames(s23_pre))))
d <- rbind.data.frame(temp1, temp2)
plot_all_histograms(d)

ev <- eigen(cor(na.omit(d))) # get eigenvalues
ap <- parallel(subject = nrow(na.omit(d)), var = ncol(na.omit(d)),
               rep = 100,cent = .05)
nS <- nScree(x = ev$values, aparallel = ap$eigen$qevpea)
plotnScree(nS)

fit <- factanal(na.omit(d), 1, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = F) 
## 
## Call:
## factanal(x = na.omit(d), factors = 1, rotation = "promax")
## 
## Uniquenesses:
## pre_ase1 pre_ase2 pre_ase3 pre_ase4 pre_ase5 
##    0.751    0.663    0.714    0.760    0.627 
## 
## Loadings:
##          Factor1
## pre_ase1 0.499  
## pre_ase2 0.581  
## pre_ase3 0.534  
## pre_ase4 0.490  
## pre_ase5 0.611  
## 
##                Factor1
## SS loadings      1.485
## Proportion Var   0.297
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 2.83 on 5 degrees of freedom.
## The p-value is 0.726

5.4 Identity

  • Recognition = id2, id3, id4, id5
  • Belonging = id7, id8, id9, id10
temp1 <- subset(f22_post, select=c(grep("id",colnames(f22_post))))
temp2 <- subset(s23_pre, select=c(grep("id",colnames(s23_pre))))
d <- rbind.data.frame(temp1, temp2)
d <- subset(d, select=-c(pre_id1))
plot_all_histograms(d)

colnames(d) <- c("My parents see me as a psychology kind of person.",
                 "My instructors see me as a psychology kind of person.",
                 "My friends see me as a psychology kind of person.",
                 "My peers see me as a psychology kind of person.",
                 "I have had experiences in which I was recognized as a psychology kind of person.",
                 "I feel comfortable in psychology.",
                 "I feel I belong in psychology.",
                 "I enjoy being in psychology.",
                 "I feel comfortable in my psychology classes.")

ev <- eigen(cor(na.omit(d))) # get eigenvalues
ap <- parallel(subject = nrow(na.omit(d)), var = ncol(na.omit(d)),
               rep = 100,cent = .05)
nS <- nScree(x = ev$values, aparallel = ap$eigen$qevpea)
plotnScree(nS)

fit <- factanal(na.omit(d), 1, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = F) 
## 
## Call:
## factanal(x = na.omit(d), factors = 1, rotation = "promax")
## 
## Uniquenesses:
##                                My parents see me as a psychology kind of person. 
##                                                                            0.590 
##                            My instructors see me as a psychology kind of person. 
##                                                                            0.656 
##                                My friends see me as a psychology kind of person. 
##                                                                            0.422 
##                                  My peers see me as a psychology kind of person. 
##                                                                            0.468 
## I have had experiences in which I was recognized as a psychology kind of person. 
##                                                                            0.622 
##                                                I feel comfortable in psychology. 
##                                                                            0.297 
##                                                   I feel I belong in psychology. 
##                                                                            0.243 
##                                                     I enjoy being in psychology. 
##                                                                            0.400 
##                                     I feel comfortable in my psychology classes. 
##                                                                            0.447 
## 
## Loadings:
##                                                                                  Factor1
## My parents see me as a psychology kind of person.                                0.640  
## My instructors see me as a psychology kind of person.                            0.586  
## My friends see me as a psychology kind of person.                                0.761  
## My peers see me as a psychology kind of person.                                  0.729  
## I have had experiences in which I was recognized as a psychology kind of person. 0.615  
## I feel comfortable in psychology.                                                0.838  
## I feel I belong in psychology.                                                   0.870  
## I enjoy being in psychology.                                                     0.775  
## I feel comfortable in my psychology classes.                                     0.744  
## 
##                Factor1
## SS loadings      4.855
## Proportion Var   0.539
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 196.27 on 27 degrees of freedom.
## The p-value is 1.27e-27
fit <- factanal(na.omit(d), 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = F) 
## 
## Call:
## factanal(x = na.omit(d), factors = 2, rotation = "promax")
## 
## Uniquenesses:
##                                My parents see me as a psychology kind of person. 
##                                                                            0.485 
##                            My instructors see me as a psychology kind of person. 
##                                                                            0.630 
##                                My friends see me as a psychology kind of person. 
##                                                                            0.194 
##                                  My peers see me as a psychology kind of person. 
##                                                                            0.242 
## I have had experiences in which I was recognized as a psychology kind of person. 
##                                                                            0.615 
##                                                I feel comfortable in psychology. 
##                                                                            0.284 
##                                                   I feel I belong in psychology. 
##                                                                            0.180 
##                                                     I enjoy being in psychology. 
##                                                                            0.286 
##                                     I feel comfortable in my psychology classes. 
##                                                                            0.419 
## 
## Loadings:
##                                                                                  Factor1
## My parents see me as a psychology kind of person.                                       
## My instructors see me as a psychology kind of person.                                   
## My friends see me as a psychology kind of person.                                       
## My peers see me as a psychology kind of person.                                         
## I have had experiences in which I was recognized as a psychology kind of person.        
## I feel comfortable in psychology.                                                 0.761 
## I feel I belong in psychology.                                                    0.882 
## I enjoy being in psychology.                                                      0.945 
## I feel comfortable in my psychology classes.                                      0.753 
##                                                                                  Factor2
## My parents see me as a psychology kind of person.                                 0.700 
## My instructors see me as a psychology kind of person.                             0.467 
## My friends see me as a psychology kind of person.                                 0.927 
## My peers see me as a psychology kind of person.                                   0.929 
## I have had experiences in which I was recognized as a psychology kind of person.  0.419 
## I feel comfortable in psychology.                                                       
## I feel I belong in psychology.                                                          
## I enjoy being in psychology.                                                            
## I feel comfortable in my psychology classes.                                            
## 
##                Factor1 Factor2
## SS loadings      2.914   2.640
## Proportion Var   0.324   0.293
## Cumulative Var   0.324   0.617
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000   0.743
## Factor2   0.743   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 40.72 on 19 degrees of freedom.
## The p-value is 0.00263

5.5 Anti-Racism in Psychology

  • Anti-racist self-efficacy = ar1 - ar9
  • Vigilance = ar10 - ar13
temp1 <- subset(f22_post, select=c(grep("pre_ar",colnames(f22_post))))
temp2 <- subset(s23_pre, select=c(grep("pre_ar",colnames(s23_pre))))
d <- rbind.data.frame(temp1, temp2)
plot_all_histograms(d)

colnames(d) <- c("Analyzing the social construction of race and racism in psychology",
                 "Examining the influence of whiteness in the information about psychology that you encounter",
                 "Answering questions or addressing others' anxiety about controversial racial issues in psychology",
                 "Using your knowledge of psychology to challenge racial bias",
                 "Discussing current findings in psychology within their historical and racial contexts",
                 "Encouraging others to explore their racial identity",
                 "Examining information you encounter as a psychology student for negative cultural stereotypes",
                 "Serve as the expert when talking about race and racism in psychology",
                 "Engage in cross race dialogue with fellow psychology students",
                 "I think about why racial minorities are treated stereotypically.",
                 "I think about whether people act in a prejudiced or discriminatory manner.",
                 "I consider whether people's actions are prejudiced or discriminatory.",
                 "I am on the lookout for instances of prejudice or discrimination.")

ev <- eigen(cor(na.omit(d))) # get eigenvalues
ap <- parallel(subject = nrow(na.omit(d)), var = ncol(na.omit(d)),
               rep = 100,cent = .05)
nS <- nScree(x = ev$values, aparallel = ap$eigen$qevpea)
plotnScree(nS)

fit <- factanal(na.omit(d), 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = F) 
## 
## Call:
## factanal(x = na.omit(d), factors = 2, rotation = "promax")
## 
## Uniquenesses:
##                                Analyzing the social construction of race and racism in psychology 
##                                                                                             0.506 
##       Examining the influence of whiteness in the information about psychology that you encounter 
##                                                                                             0.494 
## Answering questions or addressing others' anxiety about controversial racial issues in psychology 
##                                                                                             0.424 
##                                       Using your knowledge of psychology to challenge racial bias 
##                                                                                             0.349 
##             Discussing current findings in psychology within their historical and racial contexts 
##                                                                                             0.493 
##                                               Encouraging others to explore their racial identity 
##                                                                                             0.554 
##     Examining information you encounter as a psychology student for negative cultural stereotypes 
##                                                                                             0.448 
##                              Serve as the expert when talking about race and racism in psychology 
##                                                                                             0.658 
##                                     Engage in cross race dialogue with fellow psychology students 
##                                                                                             0.531 
##                                  I think about why racial minorities are treated stereotypically. 
##                                                                                             0.451 
##                        I think about whether people act in a prejudiced or discriminatory manner. 
##                                                                                             0.228 
##                             I consider whether people's actions are prejudiced or discriminatory. 
##                                                                                             0.253 
##                                 I am on the lookout for instances of prejudice or discrimination. 
##                                                                                             0.411 
## 
## Loadings:
##                                                                                                   Factor1
## Analyzing the social construction of race and racism in psychology                                 0.645 
## Examining the influence of whiteness in the information about psychology that you encounter        0.675 
## Answering questions or addressing others' anxiety about controversial racial issues in psychology  0.830 
## Using your knowledge of psychology to challenge racial bias                                        0.829 
## Discussing current findings in psychology within their historical and racial contexts              0.714 
## Encouraging others to explore their racial identity                                                0.625 
## Examining information you encounter as a psychology student for negative cultural stereotypes      0.746 
## Serve as the expert when talking about race and racism in psychology                               0.560 
## Engage in cross race dialogue with fellow psychology students                                      0.698 
## I think about why racial minorities are treated stereotypically.                                         
## I think about whether people act in a prejudiced or discriminatory manner.                               
## I consider whether people's actions are prejudiced or discriminatory.                                    
## I am on the lookout for instances of prejudice or discrimination.                                        
##                                                                                                   Factor2
## Analyzing the social construction of race and racism in psychology                                       
## Examining the influence of whiteness in the information about psychology that you encounter              
## Answering questions or addressing others' anxiety about controversial racial issues in psychology        
## Using your knowledge of psychology to challenge racial bias                                              
## Discussing current findings in psychology within their historical and racial contexts                    
## Encouraging others to explore their racial identity                                                      
## Examining information you encounter as a psychology student for negative cultural stereotypes            
## Serve as the expert when talking about race and racism in psychology                                     
## Engage in cross race dialogue with fellow psychology students                                            
## I think about why racial minorities are treated stereotypically.                                   0.728 
## I think about whether people act in a prejudiced or discriminatory manner.                         0.913 
## I consider whether people's actions are prejudiced or discriminatory.                              0.895 
## I am on the lookout for instances of prejudice or discrimination.                                  0.723 
## 
##                Factor1 Factor2
## SS loadings      4.516   2.726
## Proportion Var   0.347   0.210
## Cumulative Var   0.347   0.557
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000  -0.579
## Factor2  -0.579   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 137.92 on 53 degrees of freedom.
## The p-value is 1.72e-09

5.6 Create Composite Variables

  • Interest = int2, int4, int5
  • Value = int8, int9, int10
  • Self-efficacy = ase1 - ase5
  • Recognition = id2, id3, id4, id5
  • Belonging = id7, id8, id9, id10
  • Anti-racist self-efficacy = ar1 - ar9
  • Vigilance = ar10 - ar13
attach(f22_post)
f22_post$pre_int <- (pre_int2 + pre_int4 + pre_int6)/3
f22_post$pre_val <- (pre_int8 + pre_int9 + pre_int10)/3
f22_post$pre_se <- (pre_ase1 + pre_ase2 + pre_ase3 + pre_ase4 + pre_ase5)/5
f22_post$pre_rec <- (pre_id2 + pre_id3 + pre_id4 + pre_id5)/4
f22_post$pre_bel <- (pre_id7 + pre_id8 + pre_id9 + pre_id10)/4
f22_post$pre_are <- (pre_ar1 + pre_ar2 + pre_ar3 + pre_ar4 + pre_ar5 + pre_ar6 + pre_ar7 + pre_ar8 + pre_ar9)/9
f22_post$pre_vig <- (pre_ar10 + pre_ar11 + pre_ar12 + pre_ar13)/4
detach(f22_post)

attach(s23_pre)
s23_pre$pre_int <- (pre_int2 + pre_int4 + pre_int6)/3
s23_pre$pre_val <- (pre_int8 + pre_int9 + pre_int10)/3
s23_pre$pre_se <- (pre_ase1 + pre_ase2 + pre_ase3 + pre_ase4 + pre_ase5)/5
s23_pre$pre_rec <- (pre_id2 + pre_id3 + pre_id4 + pre_id5)/4
s23_pre$pre_bel <- (pre_id7 + pre_id8 + pre_id9 + pre_id10)/4
s23_pre$pre_are <- (pre_ar1 + pre_ar2 + pre_ar3 + pre_ar4 + pre_ar5 + pre_ar6 + pre_ar7 + pre_ar8 + pre_ar9)/9
s23_pre$pre_vig <- (pre_ar10 + pre_ar11 + pre_ar12 + pre_ar13)/4
detach(s23_pre)

attach(s23_post)
s23_post$post_int <- (post_int2 + post_int4 + post_int6)/3
s23_post$post_val <- (post_int8 + post_int9 + post_int10)/3
s23_post$post_se <- (post_ase1 + post_ase2 + post_ase3 + post_ase4 + post_ase5)/5
s23_post$post_rec <- (post_id2 + post_id3 + post_id4 + post_id5)/4
s23_post$post_bel <- (post_id7 + post_id8 + post_id9 + post_id10)/4
s23_post$post_are <- (post_ar1 + post_ar2 + post_ar3 + post_ar4 + post_ar5 + post_ar6 + post_ar7 + post_ar8 + post_ar9)/9
s23_post$post_vig <- (post_ar10 + post_ar11 + post_ar12 + post_ar13)/4
detach(s23_post)

names(f22_post)
##  [1] "start"        "end"          "progress"     "time"         "major"       
##  [6] "classes"      "classestxt"   "gender"       "gendertxt"    "sexuality"   
## [11] "sexualitytxt" "race"         "racetxt"      "ethnicity"    "parented1"   
## [16] "parented2"    "immi1"        "immi2"        "immi3"        "pre_int1"    
## [21] "pre_int2"     "pre_int3"     "pre_int4"     "pre_int5"     "pre_int6"    
## [26] "pre_int7"     "pre_int8"     "pre_int9"     "pre_int10"    "pre_ase1"    
## [31] "pre_ase2"     "pre_ase3"     "pre_ase4"     "pre_ase5"     "pre_id1"     
## [36] "pre_id2"      "pre_id3"      "pre_id4"      "pre_id5"      "pre_id6"     
## [41] "pre_id7"      "pre_id8"      "pre_id9"      "pre_id10"     "pre_ar1"     
## [46] "pre_ar2"      "pre_ar3"      "pre_ar4"      "pre_ar5"      "pre_ar6"     
## [51] "pre_ar7"      "pre_ar8"      "pre_ar9"      "pre_ar10"     "pre_ar11"    
## [56] "pre_ar12"     "pre_ar13"     "UID"          "firstgen"     "immi"        
## [61] "pre_int"      "pre_val"      "pre_se"       "pre_rec"      "pre_bel"     
## [66] "pre_are"      "pre_vig"
temp1 <- subset(f22_post, select=c(61:67))
temp2 <- subset(s23_pre, select=c(61:67))
temp3 <- subset(s23_post, select=c(44:50))
colnames(temp3) <- colnames(temp2)
temp <- rbind.data.frame(temp1, temp2, temp3)

desc <- describe(temp)
kable(round(desc, digits = 2)) %>%
    kable_styling() %>%
    row_spec(which(desc$kurtosis > 2), bold = T) %>%
    row_spec(which(desc$kurtosis < -2), bold = T) %>%
    row_spec(which(desc$skew > 2), italic = T) %>%
    row_spec(which(desc$skew < -2), italic = T)
vars n mean sd median trimmed mad min max range skew kurtosis se
pre_int 1 272 3.51 0.45 3.67 3.55 0.49 1.67 4 2.33 -1.04 1.74 0.03
pre_val 2 271 3.34 0.49 3.33 3.37 0.49 1.67 4 2.33 -0.54 -0.03 0.03
pre_se 3 269 2.98 0.42 3.00 2.97 0.59 1.60 4 2.40 0.08 -0.19 0.03
pre_rec 4 268 3.19 0.52 3.00 3.21 0.37 1.50 4 2.50 -0.25 -0.15 0.03
pre_bel 5 269 3.40 0.52 3.25 3.43 0.74 1.50 4 2.50 -0.29 -0.66 0.03
pre_are 6 262 2.99 0.62 3.00 3.01 0.66 1.00 4 3.00 -0.21 -0.48 0.04
pre_vig 7 269 2.97 0.66 3.00 2.99 0.74 1.25 4 2.75 -0.12 -0.68 0.04

6 Write Clean Files

f22_post_fin <- subset(f22_post, select=c(58,1:5,8,10,12,59:67))
s23_pre_fin <- subset(s23_pre, select=c(58,1:5,8,10,12,59:67))
names(s23_post)
##  [1] "start"      "end"        "progress"   "time"       "post_int1" 
##  [6] "post_int2"  "post_int3"  "post_int4"  "post_int5"  "post_int6" 
## [11] "post_int7"  "post_int8"  "post_int9"  "post_int10" "post_ase1" 
## [16] "post_ase2"  "post_ase3"  "post_ase4"  "post_ase5"  "post_id1"  
## [21] "post_id2"   "post_id3"   "post_id4"   "post_id5"   "post_id6"  
## [26] "post_id7"   "post_id8"   "post_id9"   "post_id10"  "post_ar1"  
## [31] "post_ar2"   "post_ar3"   "post_ar4"   "post_ar5"   "post_ar6"  
## [36] "post_ar7"   "post_ar8"   "post_ar9"   "post_ar10"  "post_ar11" 
## [41] "post_ar12"  "post_ar13"  "UID"        "post_int"   "post_val"  
## [46] "post_se"    "post_rec"   "post_bel"   "post_are"   "post_vig"
s23_post_fin <- subset(s23_post, select=c(43,1:4,44:50))

s23 <- merge(s23_pre_fin, s23_post_fin, by="UID")

# write.csv(f22_post_fin, file="clean/f22_post.csv", row.names = F)
# write.csv(s23_pre_fin, file="clean/s23_pre.csv", row.names = F)
# write.csv(s23_post_fin, file="clean/s23_post.csv", row.names = F)
# write.csv(s23, file="clean/s23_merged.csv", row.names = F)