Prepare Data

Import surveys, combine into single data frame, delete identifying information, assign IDs, and separate out by scale for item examination.

# https://hansjoerg.me/2018/04/23/rasch-in-r-tutorial/

knitr::knit_hooks$set(
   error = function(x, options) {
     paste('\n\n<div class="alert alert-danger">',
           gsub('##', '\n', gsub('^##\ Error', '**Error**', x)),
           '</div>', sep = '\n')
   },
   warning = function(x, options) {
     paste('\n\n<div class="alert alert-warning">',
           gsub('##', '\n', gsub('^##\ Warning:', '**Warning**', x)),
           '</div>', sep = '\n')
   },
   message = function(x, options) {
     paste('\n\n<div class="alert alert-info">',
           gsub('##', '\n', x),
           '</div>', sep = '\n')
   }
)

# load libraries ----------------------------------------------------------
library(stringi)
library(psych)
library(DT)
library(naniar)
library(UpSetR)
library(nFactors)
library(lavaan)
library(corrplot)
library(tidyr)

library(ggplot2)
library(dplyr)
library("eRm")
library("ltm")
library("difR")
library("psych")

library(readr) # For import the data
library(TAM) # For running the Rating Scale Rasch Model
# library(plyr) # For plot the Item characteristic curves
library(WrightMap)# For plot the variable map
# library(eRm) # For another example

# load data ---------------------------------------------------------------
# alt <- read.csv(file="UBelong Post-Survey Pitt OChem Spring 2022 Alternative Scales_April 28, 2022_12.34.csv", header=T)
# alt <- alt[-c(1,2),]
# alt$scale <- "alt"
# 
# orig <- read.csv(file="UBelong Post-Survey Pitt OChem Spring 2022 Original Scales_April 28, 2022_12.35.csv", header=T)
# orig <- orig[-c(1,2),]
# orig$scale <- "orig"
# 
# df <- rbind.data.frame(alt, orig)
# df <- subset(df, select = -c(1:19))
# names(df)
# myFun <- function(n) {
#   a <- do.call(paste0, replicate(5, sample(LETTERS, n, TRUE), FALSE))
#   paste0(a, sprintf("%04d", sample(9999, n, TRUE)), sample(LETTERS, n, TRUE))
# }
# df$id <- myFun(nrow(df))
# write.csv(df, file="imported_anonymized.csv", row.names = F)

df <- read.csv(file="imported_anonymized.csv", header=T)

# extract items -----------------------------------------------------------
# new items
EEochem <- subset(df, select=c(scale,grep("EEochem", colnames(df)))) # entry expectations
CCdisc <- subset(df, select=c(scale, grep("CCdisc", colnames(df)))) # classroom climate
IDochem <- cbind.data.frame(subset(df, select=c(scale,grep("IDochem", colnames(df)))), subset(df, select=grep("FASochem", colnames(df)))) # identity
CSochem <- subset(df, select=grep("CSochem", colnames(df))) # career satisfaction

# established scales
MSchem <- subset(df, select=c(scale,grep("MSchem", colnames(df)))) # discipline growth mindset (chemistry)
IPchem <- subset(df, select=c(scale, grep("IPchem", colnames(df)))) # instructor growth mindset (chemistry)
SEchem <- subset(df, select=c(scale, grep("SEchem", colnames(df)))) # disciplinary self-efficacy (chemistry)
MSochem <- subset(df, select=c(scale, grep("MSochem", colnames(df)))) # disciplinary growth mindset (organic chemistry)
IPochem <- subset(df, select=c(scale, grep("IPochem", colnames(df)))) # instructor growth mindset (organic chemistry)
SEochem <- subset(df, select=c(scale, grep("SEochem", colnames(df)))) # disciplinary self-efficacy (organic chemistry)
CNEBochem_class <- cbind.data.frame(subset(subset(df, select=grep("CNEBochem", colnames(df))), select=c(1:3))) # entity norms and beliefs
CNEBochem_self <- cbind.data.frame(subset(subset(df, select=grep("CNEBochem", colnames(df))), select=c(4:6))) # entity norms and beliefs
CNHSochem_others <- cbind.data.frame(subset(subset(df, select=grep("CNHSochem", colnames(df))), select=c(1:3))) # help seeking
CNHSochem_self <- cbind.data.frame(subset(subset(df, select=grep("CNHSochem", colnames(df))), select=c(4:6))) # help seeking
CNSWochem <- subset(df, select=c(scale, grep("CNSWochem", colnames(df)))) # help seeking
FCochem <- subset(df, select=c(scale, grep("FCochem", colnames(df)))) # faculty caring

IDochem$FASochem03_rc[IDochem$FASochem03 == 1] <- 4
IDochem$FASochem03_rc[IDochem$FASochem03 == 2] <- 3
IDochem$FASochem03_rc[IDochem$FASochem03 == 3] <- 2
IDochem$FASochem03_rc[IDochem$FASochem03 == 4] <- 1
IDochem$FASochem03 <- IDochem$FASochem03_rc
IDochem <- subset(IDochem, select=-c(FASochem03_rc))

Disciplinary Mindset (OC-Alt)

d <- subset(MSochem, scale == "alt", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## MSochem01 MSochem02 MSochem03 MSochem04 MSochem05 MSochem06 MSochem07 
##     0.217     0.228     0.249     0.207     0.724     0.488     0.630 
## 
## Loadings:
## [1]  0.885  0.878  0.866  0.891 -0.525 -0.715 -0.609
## 
##                Factor1
## SS loadings      4.256
## Proportion Var   0.608
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 102.43 on 14 degrees of freedom.
## The p-value is 1.62e-15
EFA <- factanal(d, factors = 2, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
## MSochem01 MSochem02 MSochem03 MSochem04 MSochem05 MSochem06 MSochem07 
##     0.244     0.247     0.178     0.175     0.479     0.249     0.267 
## 
## Loadings:
##           Factor1 Factor2
## MSochem01  0.789         
## MSochem02  0.769         
## MSochem03  0.963         
## MSochem04  0.898         
## MSochem05          0.752 
## MSochem06          0.754 
## MSochem07          0.899 
## 
##                Factor1 Factor2
## SS loadings      2.979   1.983
## Proportion Var   0.426   0.283
## Cumulative Var   0.426   0.709
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1   1.000  -0.665
## Factor2  -0.665   1.000
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 33 on 8 degrees of freedom.
## The p-value is 6.15e-05

Disciplinary Mindset (OC-Orig)

d <- subset(MSochem, scale == "orig", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## MSochem01 MSochem02 MSochem03 MSochem04 MSochem05 MSochem06 MSochem07 
##     0.359     0.284     0.225     0.152     0.335     0.221     0.440 
## 
## Loadings:
## [1]  0.801  0.846  0.880  0.921 -0.815 -0.882 -0.748
## 
##                Factor1
## SS loadings      4.982
## Proportion Var   0.712
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 54.14 on 14 degrees of freedom.
## The p-value is 1.22e-06
EFA <- factanal(d, factors = 2, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
## MSochem01 MSochem02 MSochem03 MSochem04 MSochem05 MSochem06 MSochem07 
##     0.295     0.278     0.166     0.109     0.333     0.237     0.086 
## 
## Loadings:
##           Factor1 Factor2
## MSochem02  0.792         
## MSochem03  1.031         
## MSochem04  0.986         
## MSochem06 -0.620         
## MSochem01  0.316  -0.565 
## MSochem07          1.099 
## MSochem05 -0.460   0.400 
## 
##                Factor1 Factor2
## SS loadings      3.393   1.806
## Proportion Var   0.485   0.258
## Cumulative Var   0.485   0.743
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1     1.0    -0.8
## Factor2    -0.8     1.0
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 20.19 on 8 degrees of freedom.
## The p-value is 0.00963

Instructor Mindset (OC-Alt)

d <- subset(IPochem, scale == "alt", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## IPochem02 IPochem03 IPochem04 IPochem05 
##     0.529     0.444     0.690     0.996 
## 
## Loadings:
## [1]  0.686  0.745 -0.557       
## 
##                Factor1
## SS loadings      1.340
## Proportion Var   0.335
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 1.37 on 2 degrees of freedom.
## The p-value is 0.505

Instructor Mindset (OC-Orig)

d <- subset(IPochem, scale == "orig", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## IPochem02 IPochem03 IPochem04 IPochem05 
##     0.005     0.766     0.953     0.996 
## 
## Loadings:
## [1]  0.997  0.484              
## 
##                Factor1
## SS loadings       1.28
## Proportion Var    0.32
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 5.01 on 2 degrees of freedom.
## The p-value is 0.0815

Self-Efficacy (OC-Alt)

d <- subset(SEochem, scale == "alt", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## SEochem01 SEochem02 SEochem03 SEochem04 SEochem05 
##     0.540     0.492     0.638     0.569     0.597 
## 
## Loadings:
## [1]  0.679  0.713 -0.602  0.656 -0.634
## 
##                Factor1
## SS loadings      2.164
## Proportion Var   0.433
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 3.31 on 5 degrees of freedom.
## The p-value is 0.653

Self-Efficacy (OC-Orig)

d <- subset(SEochem, scale == "orig", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## SEochem01 SEochem02 SEochem03 SEochem04 SEochem05 
##     0.376     0.386     0.623     0.795     0.797 
## 
## Loadings:
## [1]  0.790  0.783 -0.614  0.453 -0.450
## 
##                Factor1
## SS loadings      2.022
## Proportion Var   0.404
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 1.85 on 5 degrees of freedom.
## The p-value is 0.869

Identity (OC-Alt)

d <- subset(IDochem, scale == "alt", select=-c(1,2))

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

EFA <- factanal(d, factors = 3, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 3, rotation = "promax")
## 
## Uniquenesses:
##  IDochem02  IDochem03  IDochem04  IDochem05  IDochem06  IDochem10  IDochem07 
##      0.178      0.370      0.092      0.104      0.498      0.552      0.553 
##  IDochem08  IDochem09 FASochem02 FASochem03 FASochem05 
##      0.440      0.346      0.203      0.362      0.315 
## 
## Loadings:
##            Factor1 Factor2 Factor3
## IDochem02   0.916                 
## IDochem03   0.654                 
## IDochem04   0.927                 
## IDochem05   0.910                 
## IDochem06   0.753                 
## IDochem10           0.625         
## FASochem02          0.917         
## FASochem03          0.825         
## FASochem05          0.702         
## IDochem07                   0.737 
## IDochem08                   0.756 
## IDochem09                   0.665 
## 
##                Factor1 Factor2 Factor3
## SS loadings      3.563   2.502   1.626
## Proportion Var   0.297   0.208   0.135
## Cumulative Var   0.297   0.505   0.641
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3
## Factor1   1.000  -0.658   0.402
## Factor2  -0.658   1.000  -0.551
## Factor3   0.402  -0.551   1.000
## 
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 23.89 on 33 degrees of freedom.
## The p-value is 0.877

Identity (OC-Orig)

d <- subset(IDochem, scale == "orig", select=-c(1,2))

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

EFA <- factanal(d, factors = 3, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 3, rotation = "promax")
## 
## Uniquenesses:
##  IDochem02  IDochem03  IDochem04  IDochem05  IDochem06  IDochem10  IDochem07 
##      0.458      0.585      0.194      0.120      0.558      0.493      0.888 
##  IDochem08  IDochem09 FASochem02 FASochem03 FASochem05 
##      0.618      0.585      0.446      0.498      0.005 
## 
## Loadings:
##            Factor1 Factor2 Factor3
## IDochem02   0.768                 
## IDochem04   0.885                 
## IDochem05   0.942                 
## IDochem06   0.639                 
## FASochem03          0.545         
## FASochem05          1.123         
## IDochem10          -0.404   0.904 
## IDochem08  -0.337           0.621 
## IDochem03   0.399           0.323 
## IDochem07                   0.378 
## IDochem09           0.352   0.351 
## FASochem02          0.406         
## 
##                Factor1 Factor2 Factor3
## SS loadings      3.044   2.048   1.715
## Proportion Var   0.254   0.171   0.143
## Cumulative Var   0.254   0.424   0.567
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3
## Factor1   1.000   0.553   0.734
## Factor2   0.553   1.000   0.447
## Factor3   0.734   0.447   1.000
## 
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 39.06 on 33 degrees of freedom.
## The p-value is 0.216

Disciplinary Mindset (C-Alt)

d <- subset(MSchem, scale == "alt", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## MSchem01 MSchem02 MSchem03 MSchem04 MSchem05 MSchem06 MSchem07 
##    0.582    0.420    0.410    0.295    0.658    0.351    0.411 
## 
## Loadings:
## [1]  0.646  0.762  0.768  0.840 -0.585 -0.805 -0.768
## 
##                Factor1
## SS loadings      3.872
## Proportion Var   0.553
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 87.64 on 14 degrees of freedom.
## The p-value is 1.06e-12
EFA <- factanal(d, factors = 2, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
## MSchem01 MSchem02 MSchem03 MSchem04 MSchem05 MSchem06 MSchem07 
##    0.630    0.465    0.316    0.005    0.580    0.234    0.249 
## 
## Loadings:
##          Factor1 Factor2
## MSchem05  0.756         
## MSchem06  0.867         
## MSchem07  0.899         
## MSchem03          0.802 
## MSchem04          1.058 
## MSchem01 -0.323   0.329 
## MSchem02 -0.441   0.342 
## 
##                Factor1 Factor2
## SS loadings      2.440   2.016
## Proportion Var   0.349   0.288
## Cumulative Var   0.349   0.637
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1    1.00   -0.74
## Factor2   -0.74    1.00
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 28.43 on 8 degrees of freedom.
## The p-value is 0.000399

Disciplinary Mindset (C-Orig)

d <- subset(MSchem, scale == "orig", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## MSchem01 MSchem02 MSchem03 MSchem04 MSchem05 MSchem06 MSchem07 
##    0.436    0.281    0.154    0.112    0.706    0.528    0.642 
## 
## Loadings:
## [1]  0.751  0.848  0.920  0.942 -0.543 -0.687 -0.598
## 
##                Factor1
## SS loadings      4.141
## Proportion Var   0.592
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 158.34 on 14 degrees of freedom.
## The p-value is 1.53e-26
EFA <- factanal(d, factors = 2, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 2, rotation = "promax")
## 
## Uniquenesses:
## MSchem01 MSchem02 MSchem03 MSchem04 MSchem05 MSchem06 MSchem07 
##    0.446    0.250    0.130    0.111    0.181    0.148    0.370 
## 
## Loadings:
##          Factor1 Factor2
## MSchem01  0.708         
## MSchem02  0.918         
## MSchem03  0.936         
## MSchem04  0.894         
## MSchem05          0.974 
## MSchem06          0.849 
## MSchem07          0.737 
## 
##                Factor1 Factor2
## SS loadings      3.056   2.229
## Proportion Var   0.437   0.318
## Cumulative Var   0.437   0.755
## 
## Factor Correlations:
##         Factor1 Factor2
## Factor1    1.00   -0.61
## Factor2   -0.61    1.00
## 
## Test of the hypothesis that 2 factors are sufficient.
## The chi square statistic is 58.7 on 8 degrees of freedom.
## The p-value is 8.36e-10

Instructor Mindset (C-Alt)

d <- subset(IPchem, scale == "alt", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## IPchem02 IPchem03 IPchem04 IPchem05 
##    0.547    0.339    0.798    0.992 
## 
## Loadings:
## [1]  0.673  0.813 -0.449       
## 
##                Factor1
## SS loadings      1.324
## Proportion Var   0.331
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 3.3 on 2 degrees of freedom.
## The p-value is 0.192

Instructor Mindset (C-Orig)

d <- subset(IPochem, scale == "orig", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## IPochem02 IPochem03 IPochem04 IPochem05 
##     0.005     0.766     0.953     0.996 
## 
## Loadings:
## [1]  0.997  0.484              
## 
##                Factor1
## SS loadings       1.28
## Proportion Var    0.32
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 5.01 on 2 degrees of freedom.
## The p-value is 0.0815

Faculty Caring (C-Alt)

d <- subset(FCochem, scale == "alt", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## FCochem01 FCochem02 FCochem03 FCochem04 
##     0.412     0.225     0.135     0.143 
## 
## Loadings:
## [1] 0.767 0.880 0.930 0.926
## 
##                Factor1
## SS loadings      3.084
## Proportion Var   0.771
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 5.72 on 2 degrees of freedom.
## The p-value is 0.0572

Faculty Caring (C-Orig)

d <- subset(FCochem, scale == "orig", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## FCochem01 FCochem02 FCochem03 FCochem04 
##     0.229     0.307     0.189     0.197 
## 
## Loadings:
## [1] 0.878 0.832 0.900 0.896
## 
##                Factor1
## SS loadings      3.077
## Proportion Var   0.769
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 8.92 on 2 degrees of freedom.
## The p-value is 0.0116

Classroom Climate (C-Alt)

d <- subset(CCdisc, scale == "alt", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## CCdisc01 CCdisc02 CCdisc03 CCdisc04 
##    0.934    0.005    0.991    0.999 
## 
## Loadings:
## [1]  0.997                     
## 
##                Factor1
## SS loadings      1.071
## Proportion Var   0.268
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 2.96 on 2 degrees of freedom.
## The p-value is 0.228

Classroom Climate (C-Orig)

d <- subset(CCdisc, scale == "orig", select=-c(1))

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

EFA <- factanal(d, factors = 1, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 1, rotation = "promax")
## 
## Uniquenesses:
## CCdisc01 CCdisc02 CCdisc03 CCdisc04 
##    0.966    0.964    0.586    0.005 
## 
## Loadings:
## [1] 0.643 0.997            
## 
##                Factor1
## SS loadings      1.479
## Proportion Var   0.370
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 2.47 on 2 degrees of freedom.
## The p-value is 0.29

Classroom Norms (C-Alt)

# CNEBochem_class CNHSochem_others CNSWochem
CN_cno <- cbind.data.frame(CNEBochem_class, CNHSochem_others,subset(CNSWochem, select=c(1:4)))
d <- subset(CN_cno, scale == "alt", select=-c(scale))

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

EFA <- factanal(d, factors = 3, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 3, rotation = "promax")
## 
## Uniquenesses:
## CNEBochem01 CNEBochem02 CNEBochem03 CNHSochem01 CNHSochem02 CNHSochem03 
##       0.608       0.759       0.881       0.631       0.327       0.172 
## CNSWochem01 CNSWochem02 CNSWochem03 
##       0.306       0.428       0.636 
## 
## Loadings:
##             Factor1 Factor2 Factor3
## CNHSochem01  0.538                 
## CNHSochem02  0.617   0.396         
## CNHSochem03  0.913                 
## CNSWochem01          0.769         
## CNEBochem01                  0.657 
## CNSWochem02          0.463  -0.503 
## CNEBochem02                  0.473 
## CNEBochem03          0.353         
## CNSWochem03          0.369  -0.401 
## 
##                Factor1 Factor2 Factor3
## SS loadings      1.643   1.267   1.135
## Proportion Var   0.183   0.141   0.126
## Cumulative Var   0.183   0.323   0.449
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3
## Factor1  1.0000  -0.325  0.0976
## Factor2 -0.3249   1.000 -0.3079
## Factor3  0.0976  -0.308  1.0000
## 
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 26.94 on 12 degrees of freedom.
## The p-value is 0.00788

Classroom Norms (C-Orig)

# CNEBochem_class CNHSochem_others CNSWochem
CN_cno <- cbind.data.frame(CNEBochem_class, CNHSochem_others,subset(CNSWochem, select=c(1:4)))
d <- subset(CN_cno, scale == "orig", select=-c(scale))

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

EFA <- factanal(d, factors = 3, rotation = "promax")
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 3, rotation = "promax")
## 
## Uniquenesses:
## CNEBochem01 CNEBochem02 CNEBochem03 CNHSochem01 CNHSochem02 CNHSochem03 
##       0.838       0.658       0.478       0.672       0.549       0.191 
## CNSWochem01 CNSWochem02 CNSWochem03 
##       0.578       0.141       0.395 
## 
## Loadings:
##             Factor1 Factor2 Factor3
## CNSWochem01  0.541                 
## CNSWochem02  0.967                 
## CNSWochem03  0.804                 
## CNHSochem02          0.711         
## CNHSochem03          0.942         
## CNEBochem02                  0.578 
## CNEBochem03                 -0.739 
## CNEBochem01                        
## CNHSochem01  0.347   0.328         
## 
##                Factor1 Factor2 Factor3
## SS loadings      2.081   1.518   1.069
## Proportion Var   0.231   0.169   0.119
## Cumulative Var   0.231   0.400   0.519
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3
## Factor1   1.000  -0.504  -0.189
## Factor2  -0.504   1.000   0.192
## Factor3  -0.189   0.192   1.000
## 
## Test of the hypothesis that 3 factors are sufficient.
## The chi square statistic is 12.42 on 12 degrees of freedom.
## The p-value is 0.413