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=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=grep("IPchem", colnames(df))) # instructor growth mindset (chemistry)
SEchem <- subset(df, select=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=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=grep("CNSWochem", colnames(df))) # help seeking
FCochem <- subset(df, select=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))

Instructor Growth Mindset (IPchem)

Items

  1. Instructors in chemistry believe that most students are capable of meeting the course expectations.
  2. Instructors in chemistry believe that most students are capable of getting an ‘A’ if they put in the effort.
  3. Instructors in chemistry see this course as a “weed out” course to fail weaker students.
  4. The instructor expects the course to take a lot of effort.

Classroom Climate (CCdisc)

Items

  1. Students in this class were competitive with each other
  2. I didn’t feel comfortable studying with others in this class
  3. Other students in this class treated me disrespectfully (1=never; 2=once; 3=several times; 4=frequently)
  4. I had bad experiences in studying with others for this class (1=never; 2=once; 3=several times; 4=frequently)

Faculty Caring (FCochem)

Items

  1. I feel that my instructor would take the time to talk to me if I needed help.
  2. I feel that my instructor would be sensitive to my difficulties if I shared them
  3. I feel that my instructor would be sympathetic if I was upset.
  4. I feel that my instructor really tried to understand my problem when I talked about it.

Classroom Norms

Items

Entity Beliefs (CNEB)

Imagine students who scored low on the first exam in this class. What did most students in this class think about the low scoring students?

  1. …low scoring students were not smart enough to truly understand [organic chemistry]
  2. …not everyone has the natural ability to get an ‘A’ in [organic chemistry]
  3. …with enough hard work, low scoring students could have been getting an ‘A’ in [organic chemistry]

What did you think about the low scoring students? I thought…

  1. …low scoring students were not smart enough to truly understand [organic chemistry]
  2. …not everyone has the natural ability to get an ‘A’ in [organic chemistry]
  3. …with enough hard work, low scoring students could have been getting an ‘A’ in [organic chemistry]

Help Seeking (CNHS)

When students struggle in this course, how comfortable will they feel seeking help from…

  1. …their classmates
  2. …the instructor
  3. …the TA(s)

How comfortable will you feel in seeking help from…

  1. …your classmates
  2. …the instructor
  3. …the TA(s)

Safe to be Wrong (CNSW)

In thinking about this course, I expect that…

  1. Students will feel safe to be wrong.
  2. Students will feel comfortable admitting to their classmates when they are struggling with course concepts.
  3. Students will be happy to help each other learn.
  4. I will feel comfortable admitting to my classmates when I am struggling.
  5. I will be too embarrassed to admit when I am struggling.

Stats - Original

Univariate Stats

df2 <- subset(df, select=c(scale, grep("IPochem", colnames(df)),
                         grep("CCdisc", colnames(df)),
                         grep("FCochem", colnames(df)),
                         grep("CNEBochem", colnames(df)),
                         grep("CNHSochem", colnames(df)),
                         grep("CNSWochem", colnames(df))))

d <- subset(df2, scale == "orig", select=-c(scale))
desc <- data.frame(describe(d))
datatable(subset(desc, select=-c(n, trimmed, mad))) %>%
  formatRound(1:10) %>%
  formatStyle(8:9, color = styleInterval(c(-2, 2), c('red', 'black', 'red')))

Missingness

vis_miss(d)

Warning gather_() was deprecated in tidyr 1.2.0.

Please use gather() instead.

This warning is displayed once every 8 hours.

Call lifecycle::last_lifecycle_warnings() to see where this warning was generated.

# gg_miss_upset(EEochem)

Histograms

ggplot(gather(d), aes(value)) +
  geom_histogram(bins = 4) +
  facet_wrap(~key)

Warning Removed 16 rows containing non-finite values (stat_bin).

Item Correlations

corr <- corr.test(d, adjust = "holm")

rval <- corr$r
rval[lower.tri(corr$r, diag = T)] <- NA

datatable(rval) %>%
  formatRound(1:ncol(rval)) %>%
  formatStyle(1:ncol(rval), color = styleInterval(c(-.7, .7), c('red', 'black', 'red')))
corrplot(corr$r)

EFAs

EFA 6

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 = 6, rotation = "promax", cutoff = 0.3)
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 6, rotation = "promax", cutoff = 0.3)
## 
## Uniquenesses:
##   IPochem02   IPochem03   IPochem04   IPochem05    CCdisc01    CCdisc02 
##       0.738       0.626       0.915       0.932       0.836       0.570 
##    CCdisc03    CCdisc04   FCochem01   FCochem02   FCochem03   FCochem04 
##       0.005       0.503       0.177       0.287       0.154       0.198 
## CNEBochem01 CNEBochem02 CNEBochem03 CNEBochem04 CNEBochem05 CNEBochem06 
##       0.741       0.376       0.549       0.717       0.293       0.634 
## CNHSochem01 CNHSochem02 CNHSochem03 CNHSochem04 CNHSochem05 CNHSochem06 
##       0.703       0.177       0.432       0.463       0.282       0.496 
## CNSWochem01 CNSWochem02 CNSWochem03 CNSWochem04 CNSWochem05 
##       0.636       0.212       0.361       0.264       0.473 
## 
## Loadings:
##             Factor1 Factor2 Factor3 Factor4 Factor5 Factor6
## FCochem01    0.916                                         
## FCochem02    0.858                                         
## FCochem03    0.911                                         
## FCochem04    0.896                                         
## CCdisc02            -0.726                                 
## CNHSochem04          0.756                                 
## CNSWochem04          0.697                                 
## CNSWochem05         -0.759                                 
## CNEBochem02                  0.823                         
## CNEBochem03                 -0.633                         
## CNEBochem05                  0.910                         
## CNEBochem06                 -0.624                         
## CNSWochem02                          0.898                 
## CNSWochem03                          0.762                 
## CNHSochem02                                  0.925         
## CNHSochem03          0.433                   0.502         
## CNHSochem05                                  0.735         
## CCdisc03                                             1.061 
## CCdisc04                                             0.630 
## IPochem02            0.375                                 
## IPochem03                   -0.352                         
## IPochem04                                                  
## IPochem05                                                  
## CCdisc01                                                   
## CNEBochem01                                                
## CNEBochem04                  0.387                         
## CNHSochem01                                                
## CNHSochem06          0.413                   0.396         
## CNSWochem01                          0.473                 
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5 Factor6
## SS loadings      3.427   3.028   2.952   2.194   2.134   1.773
## Proportion Var   0.118   0.104   0.102   0.076   0.074   0.061
## Cumulative Var   0.118   0.223   0.324   0.400   0.474   0.535
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3 Factor4 Factor5 Factor6
## Factor1  1.0000  0.1493  0.2073  0.3480  0.0283   0.245
## Factor2  0.1493  1.0000  0.0935  0.2606  0.2481   0.361
## Factor3  0.2073  0.0935  1.0000  0.0443  0.3913   0.437
## Factor4  0.3480  0.2606  0.0443  1.0000  0.0371   0.344
## Factor5  0.0283  0.2481  0.3913  0.0371  1.0000   0.385
## Factor6  0.2448  0.3608  0.4374  0.3444  0.3855   1.000
## 
## Test of the hypothesis that 6 factors are sufficient.
## The chi square statistic is 325.17 on 247 degrees of freedom.
## The p-value is 0.000616

EFA 7

EFA <- factanal(d, factors = 7, rotation = "promax", cutoff = 0.3)
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 7, rotation = "promax", cutoff = 0.3)
## 
## Uniquenesses:
##   IPochem02   IPochem03   IPochem04   IPochem05    CCdisc01    CCdisc02 
##       0.707       0.506       0.886       0.861       0.788       0.484 
##    CCdisc03    CCdisc04   FCochem01   FCochem02   FCochem03   FCochem04 
##       0.398       0.166       0.150       0.274       0.163       0.214 
## CNEBochem01 CNEBochem02 CNEBochem03 CNEBochem04 CNEBochem05 CNEBochem06 
##       0.623       0.340       0.515       0.570       0.312       0.572 
## CNHSochem01 CNHSochem02 CNHSochem03 CNHSochem04 CNHSochem05 CNHSochem06 
##       0.691       0.005       0.406       0.448       0.324       0.452 
## CNSWochem01 CNSWochem02 CNSWochem03 CNSWochem04 CNSWochem05 
##       0.601       0.190       0.377       0.279       0.511 
## 
## Loadings:
##             Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7
## FCochem01    0.921                                                 
## FCochem02    0.859                                                 
## FCochem03    0.895                                                 
## FCochem04    0.870                                                 
## CCdisc02            -0.822                                         
## CNHSochem04          0.761                                         
## CNHSochem06          0.557                                         
## CNSWochem04          0.683                                         
## CNSWochem05         -0.709                                         
## IPochem03                    0.564                                 
## CNEBochem03                  0.667                                 
## CNEBochem05                 -0.669                   0.606         
## CNEBochem06                  0.639                                 
## CNSWochem01                          0.503                         
## CNSWochem02                          0.887                         
## CNSWochem03                          0.677                         
## CNHSochem02                                  1.052                 
## CNHSochem05                                  0.611                 
## CNEBochem01                                          0.550         
## CNEBochem02                 -0.564                   0.637         
## CNEBochem04                                          0.580         
## CCdisc03                                                     0.721 
## CCdisc04                                                     0.908 
## IPochem02                    0.394                                 
## IPochem04                                                          
## IPochem05                                                          
## CCdisc01                                                           
## CNHSochem01                                                        
## CNHSochem03          0.477                   0.422                 
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7
## SS loadings      3.353   3.168   2.416   2.033   1.979   1.768   1.555
## Proportion Var   0.116   0.109   0.083   0.070   0.068   0.061   0.054
## Cumulative Var   0.116   0.225   0.308   0.378   0.447   0.507   0.561
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7
## Factor1  1.0000  0.3128 -0.2940  0.0272 -0.0159   0.480  0.2748
## Factor2  0.3128  1.0000 -0.1102  0.1588  0.1258   0.336  0.0834
## Factor3 -0.2940 -0.1102  1.0000 -0.0294 -0.1305  -0.473 -0.1366
## Factor4  0.0272  0.1588 -0.0294  1.0000  0.1020   0.111 -0.0818
## Factor5 -0.0159  0.1258 -0.1305  0.1020  1.0000   0.183  0.3009
## Factor6  0.4799  0.3360 -0.4733  0.1112  0.1828   1.000  0.1993
## Factor7  0.2748  0.0834 -0.1366 -0.0818  0.3009   0.199  1.0000
## 
## Test of the hypothesis that 7 factors are sufficient.
## The chi square statistic is 286.13 on 224 degrees of freedom.
## The p-value is 0.00315

EFA 8

EFA <- factanal(d, factors = 8, rotation = "promax", cutoff = 0.3)
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 8, rotation = "promax", cutoff = 0.3)
## 
## Uniquenesses:
##   IPochem02   IPochem03   IPochem04   IPochem05    CCdisc01    CCdisc02 
##       0.738       0.545       0.837       0.837       0.780       0.483 
##    CCdisc03    CCdisc04   FCochem01   FCochem02   FCochem03   FCochem04 
##       0.486       0.033       0.135       0.253       0.171       0.225 
## CNEBochem01 CNEBochem02 CNEBochem03 CNEBochem04 CNEBochem05 CNEBochem06 
##       0.609       0.344       0.499       0.563       0.306       0.564 
## CNHSochem01 CNHSochem02 CNHSochem03 CNHSochem04 CNHSochem05 CNHSochem06 
##       0.537       0.005       0.410       0.033       0.259       0.360 
## CNSWochem01 CNSWochem02 CNSWochem03 CNSWochem04 CNSWochem05 
##       0.594       0.209       0.382       0.283       0.513 
## 
## Loadings:
##             Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## FCochem01    0.927                                                         
## FCochem02    0.860                                                         
## FCochem03    0.887                                                         
## FCochem04    0.866                                                         
## CCdisc02            -0.792                                                 
## CNHSochem06          0.632                                                 
## CNSWochem04          0.620           0.302                                 
## CNSWochem05         -0.666                                                 
## IPochem03                    0.517                                         
## CNEBochem02                 -0.624                   0.553                 
## CNEBochem03                  0.689                                         
## CNEBochem05                 -0.719                   0.555                 
## CNEBochem06                  0.657                                         
## CNSWochem01                          0.510                                 
## CNSWochem02                          0.905                                 
## CNSWochem03                          0.716                                 
## CNHSochem02                                  1.080                         
## CNHSochem05                                  0.619                         
## CNEBochem01                                          0.577                 
## CNEBochem04                                          0.596                 
## CCdisc03                                                     0.634         
## CCdisc04                                                     0.983         
## CNHSochem04          0.680                                           0.801 
## IPochem02                    0.345                                         
## IPochem04                                                                  
## IPochem05                                                                  
## CCdisc01                                                                   
## CNHSochem01                                                          0.418 
## CNHSochem03          0.406                   0.443                         
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## SS loadings      3.346   2.826   2.551   2.200   2.071   1.640   1.561   1.053
## Proportion Var   0.115   0.097   0.088   0.076   0.071   0.057   0.054   0.036
## Cumulative Var   0.115   0.213   0.301   0.377   0.448   0.505   0.558   0.595
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3  Factor4 Factor5 Factor6  Factor7 Factor8
## Factor1  1.0000 -0.4995 -0.0086  0.29830 -0.0378  0.3286  0.04703 -0.2661
## Factor2 -0.4995  1.0000 -0.1792 -0.33835  0.1725 -0.4029  0.03462  0.1688
## Factor3 -0.0086 -0.1792  1.0000  0.11013 -0.1273  0.1613 -0.02303 -0.2852
## Factor4  0.2983 -0.3384  0.1101  1.00000 -0.1851  0.1099 -0.00701 -0.0491
## Factor5 -0.0378  0.1725 -0.1273 -0.18505  1.0000 -0.0273  0.04894 -0.0834
## Factor6  0.3286 -0.4029  0.1613  0.10991 -0.0273  1.0000  0.28049 -0.1577
## Factor7  0.0470  0.0346 -0.0230 -0.00701  0.0489  0.2805  1.00000  0.0298
## Factor8 -0.2661  0.1688 -0.2852 -0.04907 -0.0834 -0.1577  0.02976  1.0000
## 
## Test of the hypothesis that 8 factors are sufficient.
## The chi square statistic is 252.71 on 202 degrees of freedom.
## The p-value is 0.00887

EFA 9

EFA <- factanal(d, factors = 9, rotation = "promax", cutoff = 0.3)
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 9, rotation = "promax", cutoff = 0.3)
## 
## Uniquenesses:
##   IPochem02   IPochem03   IPochem04   IPochem05    CCdisc01    CCdisc02 
##       0.719       0.521       0.827       0.823       0.790       0.005 
##    CCdisc03    CCdisc04   FCochem01   FCochem02   FCochem03   FCochem04 
##       0.403       0.207       0.151       0.258       0.156       0.204 
## CNEBochem01 CNEBochem02 CNEBochem03 CNEBochem04 CNEBochem05 CNEBochem06 
##       0.673       0.224       0.519       0.005       0.295       0.576 
## CNHSochem01 CNHSochem02 CNHSochem03 CNHSochem04 CNHSochem05 CNHSochem06 
##       0.397       0.202       0.410       0.193       0.201       0.442 
## CNSWochem01 CNSWochem02 CNSWochem03 CNSWochem04 CNSWochem05 
##       0.615       0.220       0.325       0.179       0.474 
## 
## Loadings:
##             Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## FCochem01    0.923                                                         
## FCochem02    0.859                                                         
## FCochem03    0.907                                                         
## FCochem04    0.884                                                         
## CNEBochem02          0.999                                                 
## CNEBochem03         -0.613                                                 
## CNEBochem05          0.806                                                 
## CNEBochem06         -0.598                                                 
## CNHSochem02                  0.941                                         
## CNHSochem03                  0.540                                         
## CNHSochem05                  0.871                                         
## CNSWochem02                          0.929                                 
## CNSWochem03                          0.841                                 
## CNSWochem04                          0.412   0.763                         
## CNSWochem05                                 -0.669                         
## CCdisc03                                             0.787                 
## CCdisc04                                             0.914                 
## CCdisc02                                                     0.951         
## CNHSochem01                                                          0.679 
## CNHSochem04                                  0.498                   0.708 
## CNEBochem04                                                                
## IPochem02                                                                  
## IPochem03                                                                  
## IPochem04                                                                  
## IPochem05                                                                  
## CCdisc01                                                                   
## CNEBochem01                                                                
## CNHSochem06                  0.500                                         
## CNSWochem01                          0.422                                 
##             Factor9
## FCochem01          
## FCochem02          
## FCochem03          
## FCochem04          
## CNEBochem02        
## CNEBochem03        
## CNEBochem05        
## CNEBochem06        
## CNHSochem02        
## CNHSochem03        
## CNHSochem05        
## CNSWochem02        
## CNSWochem03        
## CNSWochem04        
## CNSWochem05        
## CCdisc03           
## CCdisc04           
## CCdisc02           
## CNHSochem01        
## CNHSochem04        
## CNEBochem04  0.952 
## IPochem02          
## IPochem03          
## IPochem04          
## IPochem05          
## CCdisc01           
## CNEBochem01        
## CNHSochem06        
## CNSWochem01        
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## SS loadings      3.407   2.810   2.495   2.401   1.887   1.706   1.281   1.254
## Proportion Var   0.117   0.097   0.086   0.083   0.065   0.059   0.044   0.043
## Cumulative Var   0.117   0.214   0.300   0.383   0.448   0.507   0.551   0.595
##                Factor9
## SS loadings      1.236
## Proportion Var   0.043
## Cumulative Var   0.637
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8 Factor9
## Factor1  1.0000 -0.0748  0.0692 -0.3275 -0.3162  0.0748  0.0556  -0.220  0.1782
## Factor2 -0.0748  1.0000  0.0228  0.0400  0.0980  0.1421 -0.1390  -0.136 -0.0063
## Factor3  0.0692  0.0228  1.0000 -0.0208 -0.2289 -0.2497  0.1836  -0.345  0.1403
## Factor4 -0.3275  0.0400 -0.0208  1.0000  0.4582  0.0438 -0.1873  -0.016 -0.4838
## Factor5 -0.3162  0.0980 -0.2289  0.4582  1.0000  0.0811 -0.0606   0.103 -0.4304
## Factor6  0.0748  0.1421 -0.2497  0.0438  0.0811  1.0000 -0.4125   0.414 -0.1362
## Factor7  0.0556 -0.1390  0.1836 -0.1873 -0.0606 -0.4125  1.0000  -0.224  0.1565
## Factor8 -0.2196 -0.1357 -0.3449 -0.0160  0.1033  0.4141 -0.2235   1.000 -0.1796
## Factor9  0.1782 -0.0063  0.1403 -0.4838 -0.4304 -0.1362  0.1565  -0.180  1.0000
## 
## Test of the hypothesis that 9 factors are sufficient.
## The chi square statistic is 215.13 on 181 degrees of freedom.
## The p-value is 0.0421

Stats - Alt

Univariate Stats

df2 <- subset(df, select=c(scale, grep("IPochem", colnames(df)),
                         grep("CCdisc", colnames(df)),
                         grep("FCochem", colnames(df)),
                         grep("CNEBochem", colnames(df)),
                         grep("CNHSochem", colnames(df)),
                         grep("CNSWochem", colnames(df))))

d <- subset(df2, scale == "alt", select=-c(scale))
desc <- data.frame(describe(d))
datatable(subset(desc, select=-c(n, trimmed, mad))) %>%
  formatRound(1:10) %>%
  formatStyle(8:9, color = styleInterval(c(-2, 2), c('red', 'black', 'red')))

Missingness

vis_miss(d)

# gg_miss_upset(EEochem)

Histograms

ggplot(gather(d), aes(value)) +
  geom_histogram(bins = 4) +
  facet_wrap(~key)

Warning Removed 46 rows containing non-finite values (stat_bin).

Item Correlations

corr <- corr.test(d, adjust = "holm")

rval <- corr$r
rval[lower.tri(corr$r, diag = T)] <- NA

datatable(rval) %>%
  formatRound(1:ncol(rval)) %>%
  formatStyle(1:ncol(rval), color = styleInterval(c(-.7, .7), c('red', 'black', 'red')))
corrplot(corr$r)

EFAs

EFA 6

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 = 6, rotation = "promax", cutoff = 0.3)
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 6, rotation = "promax", cutoff = 0.3)
## 
## Uniquenesses:
##   IPochem02   IPochem03   IPochem04   IPochem05    CCdisc01    CCdisc02 
##       0.627       0.596       0.528       0.766       0.720       0.516 
##    CCdisc03    CCdisc04   FCochem01   FCochem02   FCochem03   FCochem04 
##       0.960       0.858       0.332       0.207       0.137       0.141 
## CNEBochem01 CNEBochem02 CNEBochem03 CNEBochem04 CNEBochem05 CNEBochem06 
##       0.584       0.333       0.541       0.380       0.365       0.646 
## CNHSochem01 CNHSochem02 CNHSochem03 CNHSochem04 CNHSochem05 CNHSochem06 
##       0.467       0.227       0.353       0.392       0.275       0.398 
## CNSWochem01 CNSWochem02 CNSWochem03 CNSWochem04 CNSWochem05 
##       0.473       0.510       0.360       0.306       0.366 
## 
## Loadings:
##             Factor1 Factor2 Factor3 Factor4 Factor5 Factor6
## CNHSochem01  0.618                                  -0.369 
## CNHSochem02  0.819                                         
## CNHSochem03  0.830                                         
## CNHSochem04  0.506                                  -0.362 
## CNHSochem05  0.700                                         
## CNHSochem06  0.752                                         
## FCochem01            0.819                                 
## FCochem02            0.912                                 
## FCochem03            0.893                                 
## FCochem04            0.866                                 
## CCdisc02                    -0.530   0.303                 
## CNSWochem02                  0.662                         
## CNSWochem03                  0.605                         
## CNSWochem04                  0.897                         
## CNSWochem05                 -0.555   0.381   0.349         
## IPochem02                            0.542                 
## IPochem03                            0.632                 
## CNEBochem03                          0.654                 
## CNEBochem02                         -0.328   0.715         
## CNEBochem05                         -0.442   0.696         
## CNEBochem04                                          0.802 
## IPochem04                           -0.449           0.314 
## IPochem05                                           -0.322 
## CCdisc01                    -0.404           0.311         
## CCdisc03                                                   
## CCdisc04                                                   
## CNEBochem01                                          0.421 
## CNEBochem06                          0.464                 
## CNSWochem01  0.411                   0.381                 
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5 Factor6
## SS loadings      3.484   3.421   2.684   2.580   1.742   1.596
## Proportion Var   0.120   0.118   0.093   0.089   0.060   0.055
## Cumulative Var   0.120   0.238   0.331   0.420   0.480   0.535
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3 Factor4 Factor5 Factor6
## Factor1   1.000  0.4560 -0.4983 -0.3432  0.1258  0.2196
## Factor2   0.456  1.0000 -0.2701 -0.1187  0.0639  0.2421
## Factor3  -0.498 -0.2701  1.0000  0.1258 -0.0326 -0.4608
## Factor4  -0.343 -0.1187  0.1258  1.0000  0.0949 -0.0148
## Factor5   0.126  0.0639 -0.0326  0.0949  1.0000  0.0695
## Factor6   0.220  0.2421 -0.4608 -0.0148  0.0695  1.0000
## 
## Test of the hypothesis that 6 factors are sufficient.
## The chi square statistic is 349.96 on 247 degrees of freedom.
## The p-value is 1.74e-05

EFA 7

EFA <- factanal(d, factors = 7, rotation = "promax", cutoff = 0.3)
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 7, rotation = "promax", cutoff = 0.3)
## 
## Uniquenesses:
##   IPochem02   IPochem03   IPochem04   IPochem05    CCdisc01    CCdisc02 
##       0.517       0.541       0.467       0.767       0.602       0.544 
##    CCdisc03    CCdisc04   FCochem01   FCochem02   FCochem03   FCochem04 
##       0.970       0.797       0.334       0.201       0.139       0.141 
## CNEBochem01 CNEBochem02 CNEBochem03 CNEBochem04 CNEBochem05 CNEBochem06 
##       0.508       0.299       0.310       0.431       0.340       0.523 
## CNHSochem01 CNHSochem02 CNHSochem03 CNHSochem04 CNHSochem05 CNHSochem06 
##       0.451       0.221       0.354       0.383       0.272       0.398 
## CNSWochem01 CNSWochem02 CNSWochem03 CNSWochem04 CNSWochem05 
##       0.453       0.518       0.385       0.168       0.425 
## 
## Loadings:
##             Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7
## FCochem01    0.827                                                 
## FCochem02    0.940                                                 
## FCochem03    0.921                                                 
## FCochem04    0.892                                                 
## CNHSochem01          0.601                          -0.443         
## CNHSochem02          0.852                                         
## CNHSochem03          0.848                                         
## CNHSochem05          0.729                                         
## CNHSochem06          0.750                                         
## CNSWochem03                  0.584           0.316                 
## CNSWochem04                  1.034                                 
## CNEBochem03                          0.826                         
## CNEBochem05                         -0.567                   0.524 
## CNEBochem06                          0.636                         
## IPochem02                                    0.680                 
## IPochem03                                    0.596                 
## CNEBochem04                                          0.773         
## CNEBochem02                                                  0.718 
## IPochem04                                   -0.402   0.367         
## IPochem05                                           -0.312         
## CCdisc01                                                     0.497 
## CCdisc02                    -0.454                                 
## CCdisc03                                                           
## CCdisc04                                     0.347                 
## CNEBochem01                                          0.442   0.399 
## CNHSochem04          0.461                          -0.440         
## CNSWochem01          0.383                                         
## CNSWochem02                  0.487           0.353                 
## CNSWochem05                 -0.456           0.326           0.380 
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7
## SS loadings      3.630   3.536   2.394   1.821   1.763   1.701   1.619
## Proportion Var   0.125   0.122   0.083   0.063   0.061   0.059   0.056
## Cumulative Var   0.125   0.247   0.330   0.392   0.453   0.512   0.568
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7
## Factor1   1.000  -0.479  0.4680 -0.1806 -0.3927 -0.2926 -0.1593
## Factor2  -0.479   1.000 -0.2701 -0.2423  0.1983  0.4960  0.1258
## Factor3   0.468  -0.270  1.0000 -0.1878 -0.0696 -0.2721 -0.0868
## Factor4  -0.181  -0.242 -0.1878  1.0000  0.3324 -0.0794  0.0707
## Factor5  -0.393   0.198 -0.0696  0.3324  1.0000  0.1287 -0.0137
## Factor6  -0.293   0.496 -0.2721 -0.0794  0.1287  1.0000  0.1477
## Factor7  -0.159   0.126 -0.0868  0.0707 -0.0137  0.1477  1.0000
## 
## Test of the hypothesis that 7 factors are sufficient.
## The chi square statistic is 303.7 on 224 degrees of freedom.
## The p-value is 0.000308

EFA 8

EFA <- factanal(d, factors = 8, rotation = "promax", cutoff = 0.3)
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 8, rotation = "promax", cutoff = 0.3)
## 
## Uniquenesses:
##   IPochem02   IPochem03   IPochem04   IPochem05    CCdisc01    CCdisc02 
##       0.528       0.550       0.480       0.797       0.616       0.527 
##    CCdisc03    CCdisc04   FCochem01   FCochem02   FCochem03   FCochem04 
##       0.823       0.801       0.340       0.204       0.136       0.134 
## CNEBochem01 CNEBochem02 CNEBochem03 CNEBochem04 CNEBochem05 CNEBochem06 
##       0.536       0.282       0.287       0.511       0.357       0.516 
## CNHSochem01 CNHSochem02 CNHSochem03 CNHSochem04 CNHSochem05 CNHSochem06 
##       0.382       0.109       0.338       0.357       0.261       0.005 
## CNSWochem01 CNSWochem02 CNSWochem03 CNSWochem04 CNSWochem05 
##       0.457       0.533       0.300       0.167       0.414 
## 
## Loadings:
##             Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## FCochem01    0.835                                                         
## FCochem02    0.957                                                         
## FCochem03    0.938                                                         
## FCochem04    0.924                                                         
## CNHSochem02          0.915                                                 
## CNHSochem03          0.775                                                 
## CNHSochem05          0.698                                                 
## CNSWochem03                  0.590                           0.389         
## CNSWochem04                  1.018                                         
## CNEBochem04                         -0.649                                 
## CNHSochem01          0.459           0.664                                 
## CNHSochem04                          0.593                                 
## CNEBochem03                                  0.841                         
## CNEBochem06                                  0.644                         
## CNEBochem02                                          0.752                 
## CNEBochem05                                 -0.520   0.528                 
## IPochem02                                                    0.648         
## IPochem03                                                    0.571         
## CNHSochem06          0.661                                           0.705 
## IPochem04                           -0.368                  -0.374         
## IPochem05                                                                  
## CCdisc01                                             0.499                 
## CCdisc02                    -0.440                                         
## CCdisc03                                                            -0.378 
## CCdisc04                                                     0.328         
## CNEBochem01                         -0.347           0.432                 
## CNSWochem01          0.401                                                 
## CNSWochem02                  0.470                           0.321         
## CNSWochem05                 -0.443                   0.364   0.387         
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## SS loadings      3.775   3.090   2.320   1.769   1.760   1.718   1.690   0.831
## Proportion Var   0.130   0.107   0.080   0.061   0.061   0.059   0.058   0.029
## Cumulative Var   0.130   0.237   0.317   0.378   0.438   0.498   0.556   0.585
## 
## Factor Correlations:
##         Factor1 Factor2 Factor3  Factor4 Factor5  Factor6 Factor7 Factor8
## Factor1  1.0000  -0.432  -0.147  0.22844  0.0835  0.02534  0.2371  0.0245
## Factor2 -0.4319   1.000   0.494 -0.19480 -0.2267 -0.12531 -0.3704 -0.3651
## Factor3 -0.1468   0.494   1.000  0.21354 -0.1668 -0.10491 -0.4796 -0.2068
## Factor4  0.2284  -0.195   0.214  1.00000  0.1582  0.00101 -0.0116  0.3186
## Factor5  0.0835  -0.227  -0.167  0.15815  1.0000  0.02775  0.2055  0.0492
## Factor6  0.0253  -0.125  -0.105  0.00101  0.0278  1.00000  0.1116 -0.0206
## Factor7  0.2371  -0.370  -0.480 -0.01162  0.2055  0.11155  1.0000  0.1266
## Factor8  0.0245  -0.365  -0.207  0.31863  0.0492 -0.02060  0.1266  1.0000
## 
## Test of the hypothesis that 8 factors are sufficient.
## The chi square statistic is 256.16 on 202 degrees of freedom.
## The p-value is 0.0059

EFA 9

EFA <- factanal(d, factors = 9, rotation = "promax", cutoff = 0.3)
print(EFA, digits=3, cutoff=.3, sort=TRUE)
## 
## Call:
## factanal(x = d, factors = 9, rotation = "promax", cutoff = 0.3)
## 
## Uniquenesses:
##   IPochem02   IPochem03   IPochem04   IPochem05    CCdisc01    CCdisc02 
##       0.507       0.542       0.472       0.785       0.599       0.523 
##    CCdisc03    CCdisc04   FCochem01   FCochem02   FCochem03   FCochem04 
##       0.819       0.785       0.338       0.206       0.130       0.124 
## CNEBochem01 CNEBochem02 CNEBochem03 CNEBochem04 CNEBochem05 CNEBochem06 
##       0.531       0.284       0.310       0.524       0.336       0.509 
## CNHSochem01 CNHSochem02 CNHSochem03 CNHSochem04 CNHSochem05 CNHSochem06 
##       0.368       0.188       0.146       0.324       0.005       0.005 
## CNSWochem01 CNSWochem02 CNSWochem03 CNSWochem04 CNSWochem05 
##       0.429       0.506       0.325       0.164       0.410 
## 
## Loadings:
##             Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## FCochem01    0.805                                                         
## FCochem02    0.920                                                         
## FCochem03    0.944                                                         
## FCochem04    0.930                                                         
## CNHSochem02          0.688                                                 
## CNHSochem03          0.957                                                 
## CNSWochem03                  0.579                   0.340                 
## CNSWochem04                  1.020                                         
## CNEBochem03                          0.828                                 
## CNEBochem05                         -0.582                   0.544         
## CNEBochem06                          0.652                                 
## CNEBochem04                                 -0.623                         
## CNHSochem01          0.472                   0.656                         
## CNHSochem04                                  0.649                         
## IPochem02                                            0.690                 
## IPochem03                                            0.587                 
## CCdisc01                                                     0.519         
## CNEBochem02                                                  0.746         
## CNHSochem05                                                          0.793 
## CNHSochem06          0.473                                                 
## IPochem04                                   -0.338  -0.407                 
## IPochem05                                    0.308                         
## CCdisc02                    -0.444                                         
## CCdisc03                                                                   
## CCdisc04                                                                   
## CNEBochem01                                 -0.321           0.413         
## CNSWochem01          0.379                                                 
## CNSWochem02                  0.472                                         
## CNSWochem05                 -0.428                   0.396   0.395         
##             Factor9
## FCochem01          
## FCochem02          
## FCochem03          
## FCochem04          
## CNHSochem02        
## CNHSochem03        
## CNSWochem03        
## CNSWochem04        
## CNEBochem03        
## CNEBochem05        
## CNEBochem06        
## CNEBochem04        
## CNHSochem01        
## CNHSochem04        
## IPochem02          
## IPochem03          
## CCdisc01           
## CNEBochem02        
## CNHSochem05        
## CNHSochem06  0.713 
## IPochem04          
## IPochem05          
## CCdisc02           
## CCdisc03    -0.373 
## CCdisc04           
## CNEBochem01        
## CNSWochem01        
## CNSWochem02        
## CNSWochem05        
## 
##                Factor1 Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## SS loadings      3.613   2.337   2.312   1.819   1.781   1.737   1.710   0.998
## Proportion Var   0.125   0.081   0.080   0.063   0.061   0.060   0.059   0.034
## Cumulative Var   0.125   0.205   0.285   0.348   0.409   0.469   0.528   0.562
##                Factor9
## SS loadings      0.812
## Proportion Var   0.028
## Cumulative Var   0.590
## 
## Factor Correlations:
##         Factor1   Factor2 Factor3 Factor4 Factor5 Factor6 Factor7 Factor8
## Factor1  1.0000 -0.100059   0.316  0.0837  0.2683  0.4172  0.0879 -0.1842
## Factor2 -0.1001  1.000000  -0.164 -0.1249 -0.0439 -0.0677 -0.0321  0.0939
## Factor3  0.3161 -0.163521   1.000  0.5032  0.2306  0.4569  0.2372 -0.3793
## Factor4  0.0837 -0.124855   0.503  1.0000 -0.1659  0.2847  0.1855 -0.4872
## Factor5  0.2683 -0.043937   0.231 -0.1659  1.0000  0.1016  0.1026  0.0136
## Factor6  0.4172 -0.067738   0.457  0.2847  0.1016  1.0000 -0.0876 -0.1886
## Factor7  0.0879 -0.032087   0.237  0.1855  0.1026 -0.0876  1.0000 -0.2112
## Factor8 -0.1842  0.093878  -0.379 -0.4872  0.0136 -0.1886 -0.2112  1.0000
## Factor9 -0.0325 -0.000811   0.362  0.2285  0.3472  0.2454  0.0625 -0.1572
##           Factor9
## Factor1 -0.032537
## Factor2 -0.000811
## Factor3  0.362369
## Factor4  0.228463
## Factor5  0.347217
## Factor6  0.245352
## Factor7  0.062482
## Factor8 -0.157177
## Factor9  1.000000
## 
## Test of the hypothesis that 9 factors are sufficient.
## The chi square statistic is 213.2 on 181 degrees of freedom.
## The p-value is 0.0509