1 Load Libraries

library(naniar) # for the gg_miss-upset() command
library(psych) # for the describe() command
library(kableExtra) # for tables
library(nFactors) # for factor analysis
library(stringr) # for str_trunc()
library(ggplot2) # for plots

2 Load Data

df <- read.csv(file="data/data_9-16.csv")

2.1 View Missing Data

vars <- c("salg","scid","cvs","rid","tmfs","self","sos","ase","vbs")
n <- 1
for (i in 1:length(vars)) {
  var <- vars[n]
  print(gg_miss_upset(subset(df, select=c(grep(var, colnames(df)))), nsets = (ncol(subset(df, select=c(grep(var, colnames(df)))))-1)) )
  n <- n + 1
}

2.2 View Item Normality

n <- 1
for (i in 1:length(vars)) {
  var <- vars[n]
  desc <- describe(subset(df, select=c(grep(var, colnames(df)))))
  print(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))
  n <- n + 1
}
vars n mean sd median trimmed mad min max range skew kurtosis se
salg1 1 451 3.65 0.95 4 3.69 1.48 1 5 4 -0.11 -0.69 0.04
salg2 2 451 3.35 1.06 3 3.37 1.48 1 5 4 -0.16 -0.61 0.05
salg3 3 451 3.53 1.24 4 3.63 1.48 1 5 4 -0.43 -0.79 0.06
salg4 4 451 3.57 1.37 4 3.72 1.48 1 5 4 -0.63 -0.85 0.06
salg5 5 451 3.12 1.09 3 3.10 1.48 1 5 4 0.07 -0.68 0.05
salg6 6 451 3.62 0.97 4 3.68 1.48 1 5 4 -0.38 -0.12 0.05
salg7 7 451 3.42 1.03 3 3.43 1.48 1 5 4 -0.16 -0.63 0.05
salg8 8 451 3.98 0.96 4 4.09 1.48 1 5 4 -0.64 -0.44 0.05
vars n mean sd median trimmed mad min max range skew kurtosis se
scid1 1 327 2.07 1.11 2 1.92 1.48 1 5 4 0.82 -0.07 0.06
scid2 2 327 2.61 1.24 2 2.52 1.48 1 5 4 0.38 -0.82 0.07
scid3 3 327 2.43 1.37 2 2.29 1.48 1 5 4 0.54 -0.97 0.08
scid4 4 327 2.33 1.24 2 2.21 1.48 1 5 4 0.56 -0.70 0.07
scid5 5 327 2.43 1.27 2 2.32 1.48 1 5 4 0.48 -0.82 0.07
vars n mean sd median trimmed mad min max range skew kurtosis se
cvs3 1 444 3.47 1.47 4 3.46 1.48 1 6 5 0.03 -1.11 0.07
cvs5 2 444 3.61 1.50 4 3.63 1.48 1 6 5 -0.15 -1.13 0.07
cvs7 3 444 3.15 1.52 3 3.09 1.48 1 6 5 0.26 -0.95 0.07
cvs10 4 444 3.05 1.48 3 2.99 1.48 1 6 5 0.32 -0.87 0.07
cvs12 5 444 3.12 1.58 3 3.04 1.48 1 6 5 0.25 -1.02 0.07
cvs14 6 444 3.03 1.52 3 2.95 1.48 1 6 5 0.39 -0.87 0.07
vars n mean sd median trimmed mad min max range skew kurtosis se
rid1 1 432 3.07 1.13 3 3.11 1.48 1 5 4 -0.30 -0.63 0.05
rid3 2 432 3.16 1.17 3 3.20 1.48 1 5 4 -0.31 -0.70 0.06
rid4 3 432 3.05 1.23 3 3.06 1.48 1 5 4 -0.25 -0.88 0.06
rid5 4 432 2.89 1.21 3 2.88 1.48 1 5 4 -0.04 -0.97 0.06
rid7 5 432 2.74 1.31 3 2.68 1.48 1 5 4 0.15 -1.08 0.06
rid8 6 432 3.81 1.13 4 3.96 1.48 1 5 4 -0.93 0.23 0.05
rid9 7 432 3.00 1.19 3 3.00 1.48 1 5 4 -0.01 -0.79 0.06
rid10 8 432 3.99 1.04 4 4.15 1.48 1 5 4 -1.07 0.74 0.05
rid11 9 432 2.91 1.08 3 2.93 1.48 1 5 4 -0.14 -0.47 0.05
rid12 10 238 3.92 1.08 4 4.09 1.48 1 5 4 -1.09 0.71 0.07
rid13 11 432 3.10 1.15 3 3.13 1.48 1 5 4 -0.19 -0.68 0.06
rid14 12 432 3.19 1.15 3 3.23 1.48 1 5 4 -0.38 -0.45 0.06
rid15 13 432 4.05 1.08 4 4.24 1.48 1 5 4 -1.22 0.91 0.05
rid16 14 432 2.22 1.12 2 2.10 1.48 1 5 4 0.67 -0.35 0.05
rid17 15 432 1.80 1.05 1 1.63 0.00 1 5 4 1.22 0.80 0.05
rid18 16 432 2.36 1.14 2 2.27 1.48 1 5 4 0.37 -0.75 0.06
rid19 17 432 2.38 1.18 2 2.28 1.48 1 5 4 0.39 -0.77 0.06
rid20 18 238 3.10 1.26 3 3.12 1.48 1 5 4 -0.16 -0.89 0.08
vars n mean sd median trimmed mad min max range skew kurtosis se
tmfs1 1 394 3.50 2.17 3 3.37 2.97 1 9 8 0.30 -1.26 0.11
tmfs2 2 394 4.70 2.10 5 4.75 1.48 1 9 8 -0.12 -0.61 0.11
tmfs3 3 394 4.20 2.01 4 4.19 2.97 1 10 9 0.11 -0.75 0.10
tmfs4 4 394 4.97 2.15 5 4.99 2.97 1 10 9 -0.08 -0.86 0.11
tmfs5 5 394 5.56 2.28 6 5.62 2.97 1 10 9 -0.21 -0.78 0.12
tmfs6 6 394 4.66 2.29 5 4.69 2.97 1 9 8 -0.19 -1.13 0.12
vars n mean sd median trimmed mad min max range skew kurtosis se
self1 1 244 5.93 0.31 6.0 6.00 0.00 4 6 2 -5.00 25.54 0.02
self2 2 438 4.80 1.01 5.0 4.90 1.48 1 6 5 -0.69 0.48 0.05
self3 3 438 4.66 1.12 5.0 4.77 1.48 1 6 5 -0.86 0.55 0.05
self4 4 438 3.40 1.27 3.0 3.41 1.48 1 6 5 -0.01 -0.49 0.06
self5 5 438 3.12 1.55 3.0 3.04 1.48 1 6 5 0.24 -1.00 0.07
self6 6 436 3.04 1.46 3.0 2.98 1.48 1 6 5 0.19 -0.92 0.07
self7 7 244 4.27 1.01 4.0 4.27 1.48 2 6 4 -0.03 -0.37 0.06
self8 8 438 5.08 0.90 5.0 5.17 1.48 1 6 5 -0.87 0.75 0.04
self9 9 438 4.70 1.31 5.0 4.86 1.48 1 6 5 -0.94 0.39 0.06
self10 10 438 4.34 1.27 4.5 4.45 0.74 1 6 5 -0.56 -0.29 0.06
self11 11 244 5.39 0.81 6.0 5.53 0.00 1 6 5 -1.85 5.90 0.05
self12 12 244 5.09 0.96 5.0 5.20 1.48 1 6 5 -1.18 1.95 0.06
self13 13 244 4.96 1.08 5.0 5.10 1.48 1 6 5 -1.12 1.45 0.07
self14 14 438 4.73 1.18 5.0 4.89 1.48 1 6 5 -1.18 1.42 0.06
self15 15 435 4.41 1.02 4.0 4.44 1.48 1 6 5 -0.18 -0.14 0.05
self16 16 244 5.06 0.93 5.0 5.12 1.48 2 6 4 -0.54 -0.53 0.06
self17 17 438 4.23 1.29 4.0 4.33 1.48 1 6 5 -0.51 -0.34 0.06
self18 18 438 3.34 1.49 3.0 3.32 1.48 1 6 5 -0.06 -0.89 0.07
self19 19 244 5.14 0.89 5.0 5.26 1.48 3 6 3 -0.83 -0.10 0.06
self20 20 244 4.61 1.05 5.0 4.67 1.48 2 6 4 -0.43 -0.45 0.07
self21 21 244 5.03 0.84 5.0 5.09 1.48 3 6 3 -0.48 -0.54 0.05
self22 22 438 3.93 1.18 4.0 3.97 1.48 1 6 5 -0.31 -0.03 0.06
self23 23 438 4.71 1.01 5.0 4.79 1.48 1 6 5 -0.54 0.12 0.05
self24 24 244 4.91 1.29 5.0 5.11 1.48 1 6 5 -1.14 0.63 0.08
self25 25 438 3.61 1.59 4.0 3.64 1.48 1 6 5 -0.16 -1.04 0.08
self26 26 244 5.00 1.07 5.0 5.14 1.48 1 6 5 -1.22 1.84 0.07
self27 27 244 4.63 1.51 5.0 4.86 1.48 1 6 5 -0.90 -0.18 0.10
self28 28 244 5.21 0.87 5.0 5.34 1.48 2 6 4 -1.09 0.96 0.06
self29 29 244 4.21 1.43 4.0 4.34 1.48 1 6 5 -0.54 -0.48 0.09
self30 30 244 4.80 0.97 5.0 4.85 1.48 2 6 4 -0.23 -0.79 0.06
self31 31 438 5.05 0.90 5.0 5.14 1.48 1 6 5 -0.90 0.97 0.04
self32 32 437 4.78 1.09 5.0 4.91 1.48 1 6 5 -1.02 1.26 0.05
self33 33 244 4.99 0.97 5.0 5.11 1.48 2 6 4 -0.73 -0.22 0.06
self34 34 244 3.28 1.55 4.0 3.22 1.48 1 6 5 0.02 -0.98 0.10
self35 35 244 4.63 1.07 5.0 4.71 1.48 2 6 4 -0.48 -0.31 0.07
self36 36 438 5.01 0.96 5.0 5.12 1.48 1 6 5 -0.88 0.64 0.05
self37 37 244 5.37 0.77 6.0 5.48 0.00 3 6 3 -0.95 0.01 0.05
self38 38 244 5.13 1.06 5.0 5.31 1.48 1 6 5 -1.51 2.65 0.07
self39 39 244 5.06 1.04 5.0 5.19 1.48 1 6 5 -1.24 1.97 0.07
self40 40 244 4.83 1.13 5.0 4.98 1.48 1 6 5 -1.02 1.01 0.07
self41 41 192 2.11 1.13 2.0 1.98 1.48 1 5 4 0.73 -0.50 0.08
self42 42 192 2.02 1.21 2.0 1.85 1.48 1 5 4 0.94 -0.29 0.09
self43 43 194 1.86 0.96 2.0 1.74 1.48 1 5 4 0.91 0.12 0.07
self44 44 194 3.01 1.16 3.0 3.03 1.48 1 5 4 -0.25 -0.81 0.08
self45 45 194 3.32 1.25 4.0 3.40 1.48 1 5 4 -0.60 -0.73 0.09
self46 46 192 2.26 1.13 2.0 2.17 1.48 1 5 4 0.41 -0.92 0.08
self47 47 193 1.50 0.83 1.0 1.33 0.00 1 5 4 1.90 3.86 0.06
self48 48 194 2.85 1.32 3.0 2.81 1.48 1 5 4 0.09 -1.32 0.09
self49 49 194 2.28 1.23 2.0 2.19 1.48 1 5 4 0.54 -0.99 0.09
self50 50 191 2.87 1.25 3.0 2.86 1.48 1 5 4 -0.10 -1.07 0.09
self51 51 194 2.63 1.09 3.0 2.63 1.48 1 5 4 0.07 -0.89 0.08
self52 52 194 4.52 0.89 5.0 4.73 0.00 1 5 4 -2.42 6.22 0.06
self53 53 194 4.03 0.95 4.0 4.13 1.48 1 5 4 -1.00 1.13 0.07
self54 54 194 4.50 0.68 5.0 4.60 0.00 1 5 4 -1.69 4.25 0.05
self55 55 194 4.27 0.77 4.0 4.38 1.48 1 5 4 -1.05 1.36 0.06
self56 56 194 3.73 0.88 4.0 3.77 1.48 1 5 4 -0.41 -0.07 0.06
self57 57 192 4.21 0.78 4.0 4.28 1.48 1 5 4 -0.65 0.03 0.06
self58 58 192 4.15 0.94 4.0 4.29 1.48 1 5 4 -1.26 1.62 0.07
vars n mean sd median trimmed mad min max range skew kurtosis se
sos1 1 244 5.41 0.81 6.0 5.55 0.00 2 6 4 -1.43 2.04 0.05
sos2 2 441 4.32 1.05 4.0 4.31 1.48 1 6 5 -0.11 -0.41 0.05
sos3 3 441 4.44 1.08 5.0 4.48 1.48 1 6 5 -0.35 -0.44 0.05
sos4 4 441 4.65 1.04 5.0 4.72 1.48 1 6 5 -0.50 -0.01 0.05
sos5 5 440 2.79 1.38 3.0 2.69 1.48 1 6 5 0.37 -0.65 0.07
sos6 6 440 2.79 1.56 3.0 2.64 1.48 1 6 5 0.57 -0.70 0.07
sos7 7 244 5.23 0.73 5.0 5.29 1.48 4 6 2 -0.39 -1.09 0.05
sos8 8 441 4.77 1.09 5.0 4.88 1.48 1 6 5 -0.79 0.34 0.05
sos9 9 441 3.74 1.08 4.0 3.73 1.48 1 6 5 0.08 -0.07 0.05
sos10 10 441 4.57 1.06 5.0 4.63 1.48 1 6 5 -0.37 -0.33 0.05
sos11 11 244 5.11 1.01 5.0 5.29 1.48 1 6 5 -1.55 2.76 0.06
sos12 12 244 5.13 1.07 5.0 5.31 1.48 1 6 5 -1.56 2.85 0.07
sos13 13 244 5.30 0.90 6.0 5.44 0.00 1 6 5 -1.67 4.00 0.06
sos14 14 441 3.99 1.11 4.0 3.96 1.48 1 6 5 -0.03 -0.27 0.05
sos15 15 441 4.66 1.01 5.0 4.72 1.48 1 6 5 -0.41 -0.37 0.05
sos16 16 244 5.33 0.85 6.0 5.46 0.00 2 6 4 -1.24 1.34 0.05
sos17 17 441 4.42 1.08 5.0 4.43 1.48 1 6 5 -0.21 -0.70 0.05
sos18 18 440 2.80 1.34 3.0 2.70 1.48 1 6 5 0.39 -0.44 0.06
sos19 19 244 5.30 0.78 5.0 5.40 1.48 3 6 3 -0.79 -0.28 0.05
sos20 20 244 5.55 0.63 6.0 5.64 0.00 3 6 3 -1.27 1.35 0.04
sos21 21 244 5.16 0.82 5.0 5.24 1.48 2 6 4 -0.85 0.78 0.05
sos22 22 441 4.84 1.01 5.0 4.95 1.48 1 6 5 -0.73 0.26 0.05
sos23 23 441 4.89 0.95 5.0 4.97 1.48 1 6 5 -0.67 0.44 0.05
sos24 24 244 4.55 1.18 5.0 4.64 1.48 1 6 5 -0.65 0.04 0.08
sos25 25 440 3.09 1.60 3.0 2.99 1.48 1 6 5 0.33 -0.94 0.08
sos26 26 244 4.71 1.14 5.0 4.83 1.48 1 6 5 -0.77 0.39 0.07
sos27 27 244 3.75 1.42 4.0 3.81 1.48 1 6 5 -0.29 -0.64 0.09
sos28 28 244 5.25 0.87 5.0 5.38 1.48 2 6 4 -1.12 0.98 0.06
sos29 29 244 4.39 1.27 4.0 4.50 1.48 1 6 5 -0.47 -0.41 0.08
sos30 30 244 5.40 0.72 6.0 5.51 0.00 3 6 3 -0.90 -0.08 0.05
sos31 31 441 4.10 1.16 4.0 4.10 1.48 1 6 5 -0.06 -0.72 0.06
sos32 32 441 4.05 1.15 4.0 4.00 1.48 1 6 5 0.20 -0.81 0.05
sos33 33 244 5.07 0.94 5.0 5.18 1.48 2 6 4 -0.93 0.58 0.06
sos34 34 244 3.84 1.30 4.0 3.86 1.48 1 6 5 -0.16 -0.54 0.08
sos35 35 244 4.73 1.07 5.0 4.83 1.48 2 6 4 -0.59 -0.31 0.07
sos36 36 441 4.44 1.08 5.0 4.48 1.48 1 6 5 -0.43 -0.03 0.05
sos37 37 244 4.81 1.10 5.0 4.94 1.48 1 6 5 -0.81 0.36 0.07
sos38 38 244 4.89 1.09 5.0 5.01 1.48 1 6 5 -0.91 0.74 0.07
sos39 39 244 5.38 0.82 6.0 5.51 0.00 2 6 4 -1.32 1.58 0.05
sos40 40 244 4.71 1.05 5.0 4.81 1.48 1 6 5 -0.61 0.30 0.07
sos41 41 196 1.82 0.98 1.5 1.69 0.74 1 5 4 1.00 0.29 0.07
sos42 42 196 2.46 1.06 3.0 2.42 1.48 1 5 4 0.16 -0.74 0.08
sos43 43 196 2.32 1.14 2.0 2.25 1.48 1 5 4 0.39 -0.98 0.08
sos44 44 196 2.48 1.10 3.0 2.47 1.48 1 5 4 0.03 -1.15 0.08
sos45 45 196 2.51 1.17 3.0 2.46 1.48 1 5 4 0.19 -0.95 0.08
sos46 46 196 1.91 0.94 2.0 1.80 1.48 1 5 4 0.84 0.14 0.07
sos47 47 196 1.49 0.85 1.0 1.31 0.00 1 5 4 1.82 2.97 0.06
sos48 48 196 2.20 1.10 2.0 2.09 1.48 1 5 4 0.57 -0.44 0.08
sos49 49 196 1.92 1.03 2.0 1.79 1.48 1 5 4 0.86 -0.02 0.07
sos50 50 196 2.78 1.17 3.0 2.78 1.48 1 5 4 -0.09 -0.91 0.08
sos51 51 196 1.82 0.92 2.0 1.72 1.48 1 5 4 0.87 0.13 0.07
sos52 52 197 4.37 0.80 5.0 4.50 0.00 1 5 4 -1.48 3.08 0.06
sos53 53 197 3.63 0.92 3.0 3.65 1.48 1 5 4 0.01 -0.60 0.07
sos54 54 197 3.64 0.89 4.0 3.64 1.48 1 5 4 0.10 -0.70 0.06
sos55 55 197 4.54 0.64 5.0 4.65 0.00 2 5 3 -1.19 0.76 0.05
sos56 56 197 4.17 0.76 4.0 4.25 1.48 1 5 4 -0.92 1.65 0.05
sos57 57 197 4.15 0.78 4.0 4.20 1.48 1 5 4 -0.58 0.09 0.06
sos58 58 197 3.69 0.86 4.0 3.66 1.48 1 5 4 0.18 -0.73 0.06
vars n mean sd median trimmed mad min max range skew kurtosis se
ase1 1 248 5.49 1.24 6 5.63 1.48 1 7 6 -1.16 1.66 0.08
ase2 2 248 5.49 1.37 6 5.66 1.48 1 7 6 -0.95 0.64 0.09
ase3 3 248 5.10 1.37 5 5.20 1.48 1 7 6 -0.65 0.21 0.09
ase4 4 248 4.17 1.68 4 4.22 1.48 1 7 6 -0.29 -0.80 0.11
ase5 5 248 4.54 1.43 5 4.63 1.48 1 7 6 -0.50 -0.11 0.09
ase6 6 248 4.79 1.41 5 4.88 1.48 1 7 6 -0.63 0.21 0.09
ase7 7 248 5.21 1.24 5 5.27 1.48 1 7 6 -0.61 0.90 0.08
ase8 8 248 5.67 1.19 6 5.78 1.48 1 7 6 -0.86 0.75 0.08
vars n mean sd median trimmed mad min max range skew kurtosis se
vbs1 1 244 4.14 1.01 4 4.33 1.48 1 5 4 -1.27 1.10 0.06
vbs2 2 244 4.22 0.97 4 4.39 1.48 1 5 4 -1.36 1.56 0.06
vbs3 3 244 4.20 1.03 4 4.42 1.48 1 5 4 -1.48 1.66 0.07
vbs4 4 244 4.24 0.99 5 4.40 0.00 1 5 4 -1.29 1.17 0.06
vbs5 5 244 3.22 1.19 3 3.27 1.48 1 5 4 -0.14 -0.79 0.08
vbs6 6 244 2.54 1.07 3 2.52 1.48 1 5 4 0.11 -0.85 0.07
vbs7 7 244 2.24 1.16 2 2.10 1.48 1 5 4 0.78 -0.19 0.07
vbs8 8 244 3.56 1.06 4 3.62 1.48 1 5 4 -0.46 -0.35 0.07
vbs9 9 244 4.30 0.87 5 4.44 0.00 1 5 4 -1.22 1.17 0.06
vbs10 10 244 4.57 0.83 5 4.77 0.00 1 5 4 -2.16 4.72 0.05
vbs11 11 244 3.00 1.28 3 3.00 1.48 1 5 4 -0.07 -0.94 0.08
vbs12 12 244 3.75 1.05 4 3.87 1.48 1 5 4 -0.77 0.11 0.07
vbs13 13 244 4.19 1.04 4 4.40 1.48 1 5 4 -1.53 1.93 0.07
vbs14 14 244 3.57 1.14 4 3.64 1.48 1 5 4 -0.45 -0.74 0.07
vbs15 15 244 3.89 1.06 4 4.02 1.48 1 5 4 -0.83 -0.05 0.07

3 Exploratory Factor Analysis

3.1 SALG

d <- na.omit(subset(df, select=c(grep("salg", colnames(df)))))

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(d, 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE) 
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
## salg1 salg2 salg3 salg4 salg5 salg6 salg7 salg8 
## 0.356 0.504 0.169 0.463 0.302 0.255 0.209 0.830 
## 
## Loadings:
##       Factor1 Factor2
## salg5  0.828         
## salg6  0.846         
## salg7  0.945         
## salg1          0.658 
## salg2          0.692 
## salg3          1.003 
## salg4          0.679 
## salg8  0.421         
## 
##                Factor1 Factor2
## SS loadings      2.539   2.387
## Proportion Var   0.317   0.298
## Cumulative Var   0.317   0.616
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000  -0.659
## Factor2  -0.659   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 135.88 on 13 degrees of freedom.
## The p-value is 1.41e-22
d <- subset(d, select=-c(salg8))

fit <- factanal(d, 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE) 
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
## salg1 salg2 salg3 salg4 salg5 salg6 salg7 
## 0.353 0.498 0.178 0.465 0.306 0.253 0.204 
## 
## Loadings:
##       Factor1 Factor2
## salg1  0.671         
## salg2  0.704         
## salg3  0.994         
## salg4  0.675         
## salg5          0.822 
## salg6          0.847 
## salg7          0.947 
## 
##                Factor1 Factor2
## SS loadings      2.399   2.351
## Proportion Var   0.343   0.336
## Cumulative Var   0.343   0.679
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000   0.658
## Factor2   0.658   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 121.99 on 8 degrees of freedom.
## The p-value is 1.29e-22

3.2 SCID

d <- na.omit(subset(df, select=c(grep("scid", colnames(df)))))

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(d, 1, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## scid1 scid2 scid3 scid4 scid5 
## 0.554 0.201 0.223 0.259 0.147 
## 
## Loadings:
## [1] 0.668 0.894 0.882 0.861 0.924
## 
##                Factor1
## SS loadings      3.616
## Proportion Var   0.723
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 15.11 on 5 degrees of freedom.
## The p-value is 0.0099

3.3 CVS

d <- na.omit(subset(df, select=c(grep("cvs", colnames(df)))))

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(d, 1, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
##  cvs3  cvs5  cvs7 cvs10 cvs12 cvs14 
## 0.391 0.322 0.217 0.153 0.163 0.100 
## 
## Loadings:
## [1] 0.781 0.823 0.885 0.920 0.915 0.949
## 
##                Factor1
## SS loadings      4.653
## Proportion Var   0.775
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 133.25 on 9 degrees of freedom.
## The p-value is 2.55e-24

3.4 RID

Items 12 and 20 were omitted in some surveys

3.4.1 Full list of items

d <- na.omit(subset(df, select=c(grep("rid", colnames(df)))))

colnames(d) <- str_trunc(c(
  "I use services in communities similar to where I grew up",
  "I participate in activities that help people like me who are in need",
  "I help kids with backgrounds like mine through mentoring or volunteering",
  "I donate money to organizations and causes that support people of my background",
  "I attend political rallies that fight social unfairness",
  "I owe my success to the support of friends and family",
  "I feel like I am only doing well if people like me are, as a whole, are doing well",
  "I understand how hard it is for poor folks from my background",
  "I like living around people that look like me",
  "We have to change the problems in our communities ourselves",
  "People from similar backgrounds need to stick together",
  "Having political leaders who share my race/background makes me feel like I can do more to help my community",
  "My background is an important part of who I am",
  "I keep my distance from most people with my background",
  "I have to turn my back on poor people from my race/background in order to get ahead",
  "I can barely deal with my own issues, let alone those in communities like the one I grew up in",
  "I wish I were more comfortable around others from my background",
  "I don't want people to think I am like typical people from my race/background"), width=45)

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(d, 4, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 4, rotation = "promax")
## 
## Uniquenesses:
## I use services in communities similar to w... 
##                                         0.743 
## I participate in activities that help peop... 
##                                         0.258 
## I help kids with backgrounds like mine thr... 
##                                         0.256 
## I donate money to organizations and causes... 
##                                         0.619 
## I attend political rallies that fight soci... 
##                                         0.685 
## I owe my success to the support of friends... 
##                                         0.646 
## I feel like I am only doing well if people... 
##                                         0.466 
## I understand how hard it is for poor folks... 
##                                         0.410 
## I like living around people that look like me 
##                                         0.600 
## We have to change the problems in our comm... 
##                                         0.682 
## People from similar backgrounds need to st... 
##                                         0.418 
## Having political leaders who share my race... 
##                                         0.280 
## My background is an important part of who ... 
##                                         0.592 
## I keep my distance from most people with m... 
##                                         0.684 
## I have to turn my back on poor people from... 
##                                         0.505 
## I can barely deal with my own issues, let ... 
##                                         0.327 
## I wish I were more comfortable around othe... 
##                                         0.685 
## I don't want people to think I am like typ... 
##                                         0.685 
## 
## Loadings:
##                                               Factor1 Factor2 Factor3 Factor4
## I feel like I am only doing well if people...  0.787                         
## I like living around people that look like me  0.587                         
## People from similar backgrounds need to st...  0.749                         
## Having political leaders who share my race...  0.887                         
## I participate in activities that help peop...          0.780                 
## I help kids with backgrounds like mine thr...          0.928                 
## I donate money to organizations and causes...          0.594                 
## I keep my distance from most people with m...                  0.550         
## I have to turn my back on poor people from...                  0.699         
## I can barely deal with my own issues, let ...                  0.823         
## I wish I were more comfortable around othe...                  0.539         
## I understand how hard it is for poor folks...                          0.764 
## I use services in communities similar to w...          0.309                 
## I attend political rallies that fight soci...          0.458                 
## I owe my success to the support of friends...  0.401                         
## We have to change the problems in our comm...                          0.493 
## My background is an important part of who ...  0.377                         
## I don't want people to think I am like typ...          0.421   0.378         
## 
##                Factor1 Factor2 Factor3 Factor4
## SS loadings      2.843   2.371   2.129   1.171
## Proportion Var   0.158   0.132   0.118   0.065
## Cumulative Var   0.158   0.290   0.408   0.473
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3 Factor4
## Factor1   1.000 -0.1908 -0.6071   0.455
## Factor2  -0.191  1.0000  0.0367  -0.128
## Factor3  -0.607  0.0367  1.0000  -0.361
## Factor4   0.455 -0.1281 -0.3615   1.000
## 
## Test of the hypothesis that 4 factors are sufficient.
## The chi square statistic is 258.45 on 87 degrees of freedom.
## The p-value is 6.58e-19

3.4.2 Dropping 18 and 20

d <- subset(df, select=c(grep("rid", colnames(df))))
d <- subset(d, select=-c(rid12,rid20))
d <- na.omit(d)

colnames(d) <- str_trunc(c(
  "I use services in communities similar to where I grew up",
  "I participate in activities that help people like me who are in need",
  "I help kids with backgrounds like mine through mentoring or volunteering",
  "I donate money to organizations and causes that support people of my background",
  "I attend political rallies that fight social unfairness",
  "I owe my success to the support of friends and family",
  "I feel like I am only doing well if people like me are, as a whole, are doing well",
  "I understand how hard it is for poor folks from my background",
  "I like living around people that look like me",
  "People from similar backgrounds need to stick together",
  "Having political leaders who share my race/background makes me feel like I can do more to help my community",
  "My background is an important part of who I am",
  "I keep my distance from most people with my background",
  "I have to turn my back on poor people from my race/background in order to get ahead",
  "I can barely deal with my own issues, let alone those in communities like the one I grew up in",
  "I wish I were more comfortable around others from my background"), width=45)

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(d, 3, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 3, rotation = "promax")
## 
## Uniquenesses:
## I use services in communities similar to w... 
##                                         0.732 
## I participate in activities that help peop... 
##                                         0.322 
## I help kids with backgrounds like mine thr... 
##                                         0.370 
## I donate money to organizations and causes... 
##                                         0.621 
## I attend political rallies that fight soci... 
##                                         0.726 
## I owe my success to the support of friends... 
##                                         0.768 
## I feel like I am only doing well if people... 
##                                         0.677 
## I understand how hard it is for poor folks... 
##                                         0.876 
## I like living around people that look like me 
##                                         0.663 
## People from similar backgrounds need to st... 
##                                         0.453 
## Having political leaders who share my race... 
##                                         0.369 
## My background is an important part of who ... 
##                                         0.664 
## I keep my distance from most people with m... 
##                                         0.596 
## I have to turn my back on poor people from... 
##                                         0.486 
## I can barely deal with my own issues, let ... 
##                                         0.310 
## I wish I were more comfortable around othe... 
##                                         0.617 
## 
## Loadings:
##                                               Factor1 Factor2 Factor3
## I feel like I am only doing well if people...  0.512                 
## I like living around people that look like me  0.553                 
## People from similar backgrounds need to st...  0.821                 
## Having political leaders who share my race...  0.834                 
## My background is an important part of who ...  0.524                 
## I participate in activities that help peop...          0.814         
## I help kids with backgrounds like mine thr...          0.881         
## I donate money to organizations and causes...          0.612         
## I attend political rallies that fight soci...          0.511         
## I keep my distance from most people with m...                  0.635 
## I have to turn my back on poor people from...                  0.726 
## I can barely deal with my own issues, let ...                  0.819 
## I wish I were more comfortable around othe...                  0.620 
## I use services in communities similar to w...          0.451         
## I owe my success to the support of friends...                 -0.307 
## I understand how hard it is for poor folks...                        
## 
##                Factor1 Factor2 Factor3
## SS loadings      2.439   2.345   2.196
## Proportion Var   0.152   0.147   0.137
## Cumulative Var   0.152   0.299   0.436
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3
## Factor1   1.000   0.148  -0.602
## Factor2   0.148   1.000  -0.146
## Factor3  -0.602  -0.146   1.000
## 
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 239.79 on 75 degrees of freedom.
## The p-value is 4.06e-19

3.5 TMFS

d <- na.omit(subset(df, select=c(grep("tmfs", colnames(df)))))

colnames(d) <- str_trunc(c(
  "I consider myself: Totally Masculine...Totally Feminine",
  "Ideally, I would like to be: Totally Masculine...Totally Feminine",
  "Traditionally, my interests would be considered as: Totally Masculine...Totally Feminine",
  "Traditionally, my attitudes and beliefs would be considered: Totally Masculine...Totally Feminine",
  "Traditionally, my behavior would be considered: Totally Masculine...Totally Feminine",
  "Traditionally, my outer appearance would be considered: Totally Masculine...Totally Feminine"
), width=45)

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(d, 3, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 3, rotation = "promax")
## 
## Uniquenesses:
## I consider myself: Totally Masculine...Tot... 
##                                         0.475 
## Ideally, I would like to be: Totally Mascu... 
##                                         0.614 
## Traditionally, my interests would be consi... 
##                                         0.461 
## Traditionally, my attitudes and beliefs wo... 
##                                         0.527 
## Traditionally, my behavior would be consid... 
##                                         0.005 
## Traditionally, my outer appearance would b... 
##                                         0.763 
## 
## Loadings:
##                                               Factor1 Factor2 Factor3
## Traditionally, my behavior would be consid...  1.096                 
## Traditionally, my interests would be consi...          0.803         
## I consider myself: Totally Masculine...Tot...                  0.678 
## Ideally, I would like to be: Totally Mascu...          0.365         
## Traditionally, my attitudes and beliefs wo...  0.343   0.460         
## Traditionally, my outer appearance would b...                  0.458 
## 
##                Factor1 Factor2 Factor3
## SS loadings      1.497   1.052   0.721
## Proportion Var   0.249   0.175   0.120
## Cumulative Var   0.249   0.425   0.545
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3
## Factor1   1.000  -0.617  -0.209
## Factor2  -0.617   1.000   0.401
## Factor3  -0.209   0.401   1.000
## 
## The degrees of freedom for the model is 0 and the fit was 0.0012
fit <- factanal(d, 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
## I consider myself: Totally Masculine...Tot... 
##                                         0.390 
## Ideally, I would like to be: Totally Mascu... 
##                                         0.591 
## Traditionally, my interests would be consi... 
##                                         0.706 
## Traditionally, my attitudes and beliefs wo... 
##                                         0.483 
## Traditionally, my behavior would be consid... 
##                                         0.417 
## Traditionally, my outer appearance would b... 
##                                         0.840 
## 
## Loadings:
##                                               Factor1 Factor2
## Ideally, I would like to be: Totally Mascu...  0.509         
## Traditionally, my attitudes and beliefs wo...  0.759         
## Traditionally, my behavior would be consid...  0.849         
## I consider myself: Totally Masculine...Tot...          0.876 
## Traditionally, my interests would be consi...          0.383 
## Traditionally, my outer appearance would b...          0.360 
## 
##                Factor1 Factor2
## SS loadings      1.667   1.132
## Proportion Var   0.278   0.189
## Cumulative Var   0.278   0.467
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000  -0.524
## Factor2  -0.524   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 37.42 on 4 degrees of freedom.
## The p-value is 1.47e-07
fit <- factanal(d, 1, rotation="promax") 
print(fit, digits = 3, cutoff = 0, sort = F)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## I consider myself: Totally Masculine...Tot... 
##                                         0.921 
## Ideally, I would like to be: Totally Mascu... 
##                                         0.579 
## Traditionally, my interests would be consi... 
##                                         0.762 
## Traditionally, my attitudes and beliefs wo... 
##                                         0.519 
## Traditionally, my behavior would be consid... 
##                                         0.551 
## Traditionally, my outer appearance would b... 
##                                         0.922 
## 
## Loadings:
##                                               Factor1
## I consider myself: Totally Masculine...Tot... 0.282  
## Ideally, I would like to be: Totally Mascu... 0.649  
## Traditionally, my interests would be consi... 0.487  
## Traditionally, my attitudes and beliefs wo... 0.694  
## Traditionally, my behavior would be consid... 0.670  
## Traditionally, my outer appearance would b... 0.280  
## 
##                Factor1
## SS loadings      1.747
## Proportion Var   0.291
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 118.5 on 9 degrees of freedom.
## The p-value is 2.71e-21

3.6 Views of Self and Stereotypes of Scientists

3.6.1 Stereotypes of Scientists, Scale 1

d <- subset(df, select=c(grep("sos", colnames(df))), term == "f16" | term == "w17")
d <- subset(d, select=-c(sos1))
d <- d[, !apply(is.na(d), 2, all)]
d <- na.omit(d)

colnames(d) <- str_trunc(c(
  "They have fun with colleagues at work",
  "They maintain friendships with colleagues in other departments",
  "They know a lot about the latest discoveries",
  "They do not have a lot of friends",
  "They are out of touch with what is happening in the world",
  "They are the ones who know how equipment works",
  "They are careful with expensive instruments",
  "They have happy marriages",
  "They are competitive",
  "They are cooperative",
  "They are independent",
  "They are work oriented",
  "They are family oriented",
  "They are technically competent",
  "They are competent",
  "They are self-confident",
  "They are insecure",
  "They are collaborative",
  "They are highly focused",
  "They are able to learn to use new equipment quickly",
  "They are especially intelligent",
  "They are logical",
  "They were committed to their hobbies (like sports or art) as children.",
  "They struggled to do well in school.",
  "They defy expectations about what they're 'supposed' to be like.",
  "They had parents who struggled to make ends meet.",
  "They have imagination.",
  "They enjoy literature and writing.",
  "They think outside the box.",
  "They are warm and caring people.",
  "They are devoted to their families.",
  "They succeed in spite of failure.",
  "They chose their career because of advice from their family.",
  "They chose their career because it lets them focus on learning.",
  "They chose a career because it lets them help others.",
  "They are determined to have fun with their work.",
  "They work with a lot of people everyday.",
  "They are forward thinkers who want to improve the world.",
  "They give back to the communities they came from."), width=35)

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(d, 5, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 5, rotation = "promax")
## 
## Uniquenesses:
## They have fun with colleagues at... They maintain friendships with c... 
##                               0.664                               0.531 
## They know a lot about the latest...   They do not have a lot of friends 
##                               0.644                               0.543 
## They are out of touch with what ... They are the ones who know how e... 
##                               0.634                               0.542 
## They are careful with expensive ...           They have happy marriages 
##                               0.655                               0.657 
##                They are competitive                They are cooperative 
##                               0.673                               0.656 
##                They are independent              They are work oriented 
##                               0.566                               0.582 
##            They are family oriented      They are technically competent 
##                               0.333                               0.599 
##                  They are competent             They are self-confident 
##                               0.439                               0.620 
##                   They are insecure              They are collaborative 
##                               0.793                               0.558 
##             They are highly focused They are able to learn to use ne... 
##                               0.534                               0.610 
##     They are especially intelligent                    They are logical 
##                               0.448                               0.444 
## They were committed to their hob... They struggled to do well in sch... 
##                               0.654                               0.696 
## They defy expectations about wha... They had parents who struggled t... 
##                               0.697                               0.788 
##              They have imagination.  They enjoy literature and writing. 
##                               0.587                               0.519 
##         They think outside the box.    They are warm and caring people. 
##                               0.449                               0.239 
## They are devoted to their families.   They succeed in spite of failure. 
##                               0.353                               0.523 
## They chose their career because ... They chose their career because ... 
##                               0.569                               0.790 
## They chose a career because it l... They are determined to have fun ... 
##                               0.005                               0.584 
## They work with a lot of people e... They are forward thinkers who wa... 
##                               0.472                               0.420 
## They give back to the communitie... 
##                               0.596 
## 
## Loadings:
##                                     Factor1 Factor2 Factor3 Factor4 Factor5
## They know a lot about the latest...  0.682                                 
## They are the ones who know how e...  0.631                                 
## They are careful with expensive ...  0.721                                 
## They are independent                 0.639                                 
## They are technically competent       0.583                                 
## They are self-confident              0.524                                 
## They are highly focused              0.634                           0.313 
## They are able to learn to use ne...  0.769                                 
## They have imagination.               0.509                                 
## They think outside the box.          0.748                                 
## They succeed in spite of failure.    0.660                                 
## They are forward thinkers who wa...  0.555                           0.356 
## They are family oriented                     0.965                         
## They enjoy literature and writing.           0.562                         
## They are warm and caring people.             0.983                   0.381 
## They are devoted to their families.          0.958                         
## They are determined to have fun ...          0.521                         
## They do not have a lot of friends           -0.323   0.766                 
## They chose their career because ...                  0.631                 
## They chose a career because it l...                          1.041         
## They are especially intelligent                                      0.595 
## They are logical                                                     0.717 
## They have fun with colleagues at...          0.366                         
## They maintain friendships with c...  0.412   0.379                         
## They are out of touch with what ...                  0.422                 
## They have happy marriages                    0.377                         
## They are competitive                 0.484                                 
## They are cooperative                 0.428                                 
## They are work oriented               0.463                                 
## They are competent                   0.342                   0.439         
## They are insecure                                    0.423                 
## They are collaborative               0.413                                 
## They were committed to their hob...          0.493                         
## They struggled to do well in sch...          0.304   0.308                 
## They defy expectations about wha...          0.362                         
## They had parents who struggled t...          0.395                         
## They chose their career because ...                                        
## They work with a lot of people e...  0.310   0.331                         
## They give back to the communitie...          0.313                         
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5
## SS loadings      6.713   5.320   2.038   1.840   1.803
## Proportion Var   0.172   0.136   0.052   0.047   0.046
## Cumulative Var   0.172   0.309   0.361   0.408   0.454
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3 Factor4 Factor5
## Factor1   1.000  -0.555   0.524   0.138  -0.130
## Factor2  -0.555   1.000  -0.608  -0.120   0.238
## Factor3   0.524  -0.608   1.000   0.382   0.130
## Factor4   0.138  -0.120   0.382   1.000   0.328
## Factor5  -0.130   0.238   0.130   0.328   1.000
## 
## Test of the hypothesis that 5 factors are sufficient.
## The chi square statistic is 1453.97 on 556 degrees of freedom.
## The p-value is 1.73e-81

Negatively worded items loading on their own factor - removing 5, 34, 6, 18, 25

d <- subset(df, select=c(grep("sos", colnames(df))), term == "f16" | term == "w17")
d <- subset(d, select=-c(sos1, sos5, sos6, sos18, sos25, sos34))
d <- d[, !apply(is.na(d), 2, all)]
d <- na.omit(d)

colnames(d) <- str_trunc(c(
  "They have fun with colleagues at work",
  "They maintain friendships with colleagues in other departments",
  "They know a lot about the latest discoveries",
  "They are the ones who know how equipment works",
  "They are careful with expensive instruments",
  "They have happy marriages",
  "They are competitive",
  "They are cooperative",
  "They are independent",
  "They are work oriented",
  "They are family oriented",
  "They are technically competent",
  "They are competent",
  "They are self-confident",
  "They are collaborative",
  "They are highly focused",
  "They are able to learn to use new equipment quickly",
  "They are especially intelligent",
  "They are logical",
  "They were committed to their hobbies (like sports or art) as children.",
  "They defy expectations about what they're 'supposed' to be like.",
  "They had parents who struggled to make ends meet.",
  "They have imagination.",
  "They enjoy literature and writing.",
  "They think outside the box.",
  "They are warm and caring people.",
  "They are devoted to their families.",
  "They succeed in spite of failure.",
  "They chose their career because it lets them focus on learning.",
  "They chose a career because it lets them help others.",
  "They are determined to have fun with their work.",
  "They work with a lot of people everyday.",
  "They are forward thinkers who want to improve the world.",
  "They give back to the communities they came from."), width=45)

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(d, 3, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 3, rotation = "promax")
## 
## Uniquenesses:
##         They have fun with colleagues at work 
##                                         0.694 
## They maintain friendships with colleagues ... 
##                                         0.556 
##  They know a lot about the latest discoveries 
##                                         0.681 
## They are the ones who know how equipment w... 
##                                         0.542 
##   They are careful with expensive instruments 
##                                         0.669 
##                     They have happy marriages 
##                                         0.717 
##                          They are competitive 
##                                         0.723 
##                          They are cooperative 
##                                         0.711 
##                          They are independent 
##                                         0.612 
##                        They are work oriented 
##                                         0.646 
##                      They are family oriented 
##                                         0.315 
##                They are technically competent 
##                                         0.607 
##                            They are competent 
##                                         0.550 
##                       They are self-confident 
##                                         0.662 
##                        They are collaborative 
##                                         0.598 
##                       They are highly focused 
##                                         0.559 
## They are able to learn to use new equipmen... 
##                                         0.632 
##               They are especially intelligent 
##                                         0.463 
##                              They are logical 
##                                         0.512 
## They were committed to their hobbies (like... 
##                                         0.678 
## They defy expectations about what they're ... 
##                                         0.693 
## They had parents who struggled to make end... 
##                                         0.848 
##                        They have imagination. 
##                                         0.624 
##            They enjoy literature and writing. 
##                                         0.520 
##                   They think outside the box. 
##                                         0.510 
##              They are warm and caring people. 
##                                         0.231 
##           They are devoted to their families. 
##                                         0.396 
##             They succeed in spite of failure. 
##                                         0.526 
## They chose their career because it lets th... 
##                                         0.814 
## They chose a career because it lets them h... 
##                                         0.658 
## They are determined to have fun with their... 
##                                         0.610 
##      They work with a lot of people everyday. 
##                                         0.472 
## They are forward thinkers who want to impr... 
##                                         0.416 
## They give back to the communities they cam... 
##                                         0.616 
## 
## Loadings:
##                                               Factor1 Factor2 Factor3
## They know a lot about the latest discoveries   0.584                 
## They are the ones who know how equipment w...  0.734                 
## They are careful with expensive instruments    0.597                 
## They are independent                           0.519                 
## They are technically competent                 0.509                 
## They are able to learn to use new equipmen...  0.746                 
## They think outside the box.                    0.610                 
## They succeed in spite of failure.              0.791                 
## They have happy marriages                              0.509         
## They are family oriented                               0.965         
## They enjoy literature and writing.                     0.557         
## They are warm and caring people.              -0.401   0.928   0.458 
## They are devoted to their families.                    0.840         
## They are determined to have fun with their...          0.506         
## They are especially intelligent                                0.709 
## They are logical                                               0.758 
## They are forward thinkers who want to impr...  0.359           0.569 
## They have fun with colleagues at work                  0.334         
## They maintain friendships with colleagues ...  0.344   0.349         
## They are competitive                           0.486                 
## They are cooperative                           0.310                 
## They are work oriented                         0.319                 
## They are competent                             0.309           0.446 
## They are self-confident                        0.418                 
## They are collaborative                         0.382                 
## They are highly focused                        0.423           0.395 
## They were committed to their hobbies (like...          0.455         
## They defy expectations about what they're ...          0.347         
## They had parents who struggled to make end...          0.455         
## They have imagination.                         0.347           0.356 
## They chose their career because it lets th...                        
## They chose a career because it lets them h...          0.365         
## They work with a lot of people everyday.       0.473   0.423         
## They give back to the communities they cam...          0.354   0.368 
## 
##                Factor1 Factor2 Factor3
## SS loadings      5.572   4.946   2.763
## Proportion Var   0.164   0.145   0.081
## Cumulative Var   0.164   0.309   0.391
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3
## Factor1   1.000  -0.641   0.264
## Factor2  -0.641   1.000  -0.570
## Factor3   0.264  -0.570   1.000
## 
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 1314.38 on 462 degrees of freedom.
## The p-value is 8.94e-83

Dropping two items loading only on third factor: 22 and 23

d <- subset(df, select=c(grep("sos", colnames(df))), term == "f16" | term == "w17")
d <- subset(d, select=-c(sos1, sos5, sos6, sos18, sos22, sos23, sos25, sos34))
d <- d[, !apply(is.na(d), 2, all)]
d <- na.omit(d)

colnames(d) <- str_trunc(c(
  "They have fun with colleagues at work",
  "They maintain friendships with colleagues in other departments",
  "They know a lot about the latest discoveries",
  "They are the ones who know how equipment works",
  "They are careful with expensive instruments",
  "They have happy marriages",
  "They are competitive",
  "They are cooperative",
  "They are independent",
  "They are work oriented",
  "They are family oriented",
  "They are technically competent",
  "They are competent",
  "They are self-confident",
  "They are collaborative",
  "They are highly focused",
  "They are able to learn to use new equipment quickly",
  "They were committed to their hobbies (like sports or art) as children.",
  "They defy expectations about what they're 'supposed' to be like.",
  "They had parents who struggled to make ends meet.",
  "They have imagination.",
  "They enjoy literature and writing.",
  "They think outside the box.",
  "They are warm and caring people.",
  "They are devoted to their families.",
  "They succeed in spite of failure.",
  "They chose their career because it lets them focus on learning.",
  "They chose a career because it lets them help others.",
  "They are determined to have fun with their work.",
  "They work with a lot of people everyday.",
  "They are forward thinkers who want to improve the world.",
  "They give back to the communities they came from."), width=45)

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(d, 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
##         They have fun with colleagues at work 
##                                         0.692 
## They maintain friendships with colleagues ... 
##                                         0.553 
##  They know a lot about the latest discoveries 
##                                         0.700 
## They are the ones who know how equipment w... 
##                                         0.646 
##   They are careful with expensive instruments 
##                                         0.651 
##                     They have happy marriages 
##                                         0.713 
##                          They are competitive 
##                                         0.736 
##                          They are cooperative 
##                                         0.693 
##                          They are independent 
##                                         0.617 
##                        They are work oriented 
##                                         0.662 
##                      They are family oriented 
##                                         0.310 
##                They are technically competent 
##                                         0.616 
##                            They are competent 
##                                         0.597 
##                       They are self-confident 
##                                         0.670 
##                        They are collaborative 
##                                         0.582 
##                       They are highly focused 
##                                         0.593 
## They are able to learn to use new equipmen... 
##                                         0.683 
## They were committed to their hobbies (like... 
##                                         0.684 
## They defy expectations about what they're ... 
##                                         0.702 
## They had parents who struggled to make end... 
##                                         0.846 
##                        They have imagination. 
##                                         0.647 
##            They enjoy literature and writing. 
##                                         0.536 
##                   They think outside the box. 
##                                         0.479 
##              They are warm and caring people. 
##                                         0.413 
##           They are devoted to their families. 
##                                         0.399 
##             They succeed in spite of failure. 
##                                         0.619 
## They chose their career because it lets th... 
##                                         0.822 
## They chose a career because it lets them h... 
##                                         0.668 
## They are determined to have fun with their... 
##                                         0.638 
##      They work with a lot of people everyday. 
##                                         0.558 
## They are forward thinkers who want to impr... 
##                                         0.492 
## They give back to the communities they cam... 
##                                         0.658 
## 
## Loadings:
##                                               Factor1 Factor2
## They know a lot about the latest discoveries   0.640         
## They are careful with expensive instruments    0.736         
## They are competitive                           0.532         
## They are cooperative                           0.508         
## They are independent                           0.514         
## They are technically competent                 0.572         
## They are competent                             0.681         
## They are collaborative                         0.527         
## They are highly focused                        0.745         
## They are able to learn to use new equipmen...  0.622         
## They have imagination.                         0.629         
## They think outside the box.                    0.786         
## They succeed in spite of failure.              0.527         
## They are forward thinkers who want to impr...  0.866         
## They have happy marriages                              0.558 
## They are family oriented                      -0.335   1.009 
## They were committed to their hobbies (like...          0.570 
## They had parents who struggled to make end...          0.509 
## They enjoy literature and writing.                     0.692 
## They are warm and caring people.                       0.768 
## They are devoted to their families.                    0.867 
## They are determined to have fun with their...          0.599 
## They work with a lot of people everyday.               0.591 
## They have fun with colleagues at work                  0.389 
## They maintain friendships with colleagues ...  0.361   0.375 
## They are the ones who know how equipment w...  0.426         
## They are work oriented                         0.446         
## They are self-confident                        0.427         
## They defy expectations about what they're ...          0.409 
## They chose their career because it lets th...          0.310 
## They chose a career because it lets them h...          0.355 
## They give back to the communities they cam...  0.338   0.305 
## 
##                Factor1 Factor2
## SS loadings      7.012   5.668
## Proportion Var   0.219   0.177
## Cumulative Var   0.219   0.396
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000  -0.651
## Factor2  -0.651   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 1271.49 on 433 degrees of freedom.
## The p-value is 2.25e-83

Dropping three cross-loading items: 14, 3, 40. Adding 17 to drop list

d <- subset(df, select=c(grep("sos", colnames(df))), term == "f16" | term == "w17")
d <- subset(d, select=-c(sos1, sos3, sos5, sos6, sos14, sos17, sos18, sos22, sos23, sos25, sos34, sos40))
d <- d[, !apply(is.na(d), 2, all)]
d <- na.omit(d)

colnames(d) <- str_trunc(c(
  "They have fun with colleagues at work",
  "They know a lot about the latest discoveries",
  "They are the ones who know how equipment works",
  "They are careful with expensive instruments",
  "They have happy marriages",
  "They are competitive",
  "They are cooperative",
  "They are independent",
  "They are work oriented",
  "They are technically competent",
  "They are competent",
  "They are collaborative",
  "They are highly focused",
  "They are able to learn to use new equipment quickly",
  "They were committed to their hobbies (like sports or art) as children.",
  "They defy expectations about what they're 'supposed' to be like.",
  "They had parents who struggled to make ends meet.",
  "They have imagination.",
  "They enjoy literature and writing.",
  "They think outside the box.",
  "They are warm and caring people.",
  "They are devoted to their families.",
  "They succeed in spite of failure.",
  "They chose their career because it lets them focus on learning.",
  "They chose a career because it lets them help others.",
  "They are determined to have fun with their work.",
  "They work with a lot of people everyday.",
  "They are forward thinkers who want to improve the world."), width=45)

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(d, 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
##         They have fun with colleagues at work 
##                                         0.681 
##  They know a lot about the latest discoveries 
##                                         0.693 
## They are the ones who know how equipment w... 
##                                         0.639 
##   They are careful with expensive instruments 
##                                         0.644 
##                     They have happy marriages 
##                                         0.712 
##                          They are competitive 
##                                         0.729 
##                          They are cooperative 
##                                         0.695 
##                          They are independent 
##                                         0.634 
##                        They are work oriented 
##                                         0.648 
##                They are technically competent 
##                                         0.614 
##                            They are competent 
##                                         0.591 
##                        They are collaborative 
##                                         0.576 
##                       They are highly focused 
##                                         0.595 
## They are able to learn to use new equipmen... 
##                                         0.698 
## They were committed to their hobbies (like... 
##                                         0.663 
## They defy expectations about what they're ... 
##                                         0.661 
## They had parents who struggled to make end... 
##                                         0.848 
##                        They have imagination. 
##                                         0.654 
##            They enjoy literature and writing. 
##                                         0.465 
##                   They think outside the box. 
##                                         0.474 
##              They are warm and caring people. 
##                                         0.504 
##           They are devoted to their families. 
##                                         0.482 
##             They succeed in spite of failure. 
##                                         0.605 
## They chose their career because it lets th... 
##                                         0.814 
## They chose a career because it lets them h... 
##                                         0.666 
## They are determined to have fun with their... 
##                                         0.660 
##      They work with a lot of people everyday. 
##                                         0.490 
## They are forward thinkers who want to impr... 
##                                         0.486 
## 
## Loadings:
##                                               Factor1 Factor2
## They know a lot about the latest discoveries   0.628         
## They are careful with expensive instruments    0.707         
## They are cooperative                           0.503         
## They are competent                             0.634         
## They are collaborative                         0.516         
## They are highly focused                        0.707         
## They are able to learn to use new equipmen...  0.549         
## They have imagination.                         0.578         
## They think outside the box.                    0.754         
## They are forward thinkers who want to impr...  0.833         
## They have happy marriages                              0.581 
## They were committed to their hobbies (like...          0.609 
## They defy expectations about what they're ...          0.526 
## They enjoy literature and writing.                     0.805 
## They are warm and caring people.                       0.694 
## They are devoted to their families.                    0.795 
## They are determined to have fun with their...          0.580 
## They work with a lot of people everyday.               0.724 
## They have fun with colleagues at work                  0.452 
## They are the ones who know how equipment w...  0.369         
## They are competitive                           0.492         
## They are independent                           0.455         
## They are work oriented                         0.429         
## They are technically competent                 0.500         
## They had parents who struggled to make end...          0.496 
## They succeed in spite of failure.              0.432         
## They chose their career because it lets th...          0.368 
## They chose a career because it lets them h...          0.402 
## 
##                Factor1 Factor2
## SS loadings      5.633   4.811
## Proportion Var   0.201   0.172
## Cumulative Var   0.201   0.373
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000  -0.622
## Factor2  -0.622   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 958.12 on 323 degrees of freedom.
## The p-value is 3.55e-64

3.7 SOS Composite and Scatter

d <- subset(df, select=c(grep("sos", colnames(df))), term == "f16" | term == "w17")
d <- subset(d, select=-c(sos1, sos3, sos5, sos6, sos14, sos17, sos18, sos22, sos23, sos25, sos34, sos40))
d <- d[, !apply(is.na(d), 2, all)]
d <- na.omit(d)

fit <- factanal(d, 2, rotation="promax") 
print(fit, digits = 3, cutoff = 0.3, sort = TRUE)
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
##  sos2  sos4  sos7  sos8  sos9 sos10 sos11 sos12 sos13 sos15 sos16 sos19 sos20 
## 0.681 0.693 0.639 0.644 0.712 0.729 0.695 0.634 0.648 0.614 0.591 0.576 0.595 
## sos21 sos24 sos26 sos27 sos28 sos29 sos30 sos31 sos32 sos33 sos35 sos36 sos37 
## 0.698 0.663 0.661 0.848 0.654 0.465 0.474 0.504 0.482 0.605 0.814 0.666 0.660 
## sos38 sos39 
## 0.490 0.486 
## 
## Loadings:
##       Factor1 Factor2
## sos4   0.628         
## sos8   0.707         
## sos11  0.503         
## sos16  0.634         
## sos19  0.516         
## sos20  0.707         
## sos21  0.549         
## sos28  0.578         
## sos30  0.754         
## sos39  0.833         
## sos9           0.581 
## sos24          0.609 
## sos26          0.526 
## sos29          0.805 
## sos31          0.694 
## sos32          0.795 
## sos37          0.580 
## sos38          0.724 
## sos2           0.452 
## sos7   0.369         
## sos10  0.492         
## sos12  0.455         
## sos13  0.429         
## sos15  0.500         
## sos27          0.496 
## sos33  0.432         
## sos35          0.368 
## sos36          0.402 
## 
##                Factor1 Factor2
## SS loadings      5.633   4.811
## Proportion Var   0.201   0.172
## Cumulative Var   0.201   0.373
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000  -0.622
## Factor2  -0.622   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 958.12 on 323 degrees of freedom.
## The p-value is 3.55e-64
df$sos_comp <- (df$sos4 + df$sos8 + df$sos11 + df$sos16 + df$sos19 + df$sos20 + df$sos21 + df$sos28 + df$sos30 + df$sos39 + df$sos7 + df$sos10 + df$sos12 + df$sos13 + df$sos15 + df$sos33)/16
df$sos_warm <- (df$sos9 + df$sos24 + df$sos26 + df$sos29 + df$sos31 + df$sos32 + df$sos37 + df$sos38 + df$sos2 + df$sos27 + df$sos25 + df$sos26)/12

df$sos_comp_std <- as.vector(scale(df$sos_comp, center=T, scale=T))
df$sos_warm_std <- as.vector(scale(df$sos_warm, center=T, scale=T))

ggplot(data=df, aes(x = sos_comp_std, y = sos_warm_std)) +
  geom_point() +
  geom_hline(yintercept = 0, color = "red") +
  geom_vline(xintercept = 0, color = "blue")