#Loading packages

library(lme4)
library(lmerTest)
library(lavaan)
library(asherR)
library(reshape2)

Loading data

source("../Scripts/F24_Stats_Data_Combination.R", chdir = T)

#Joining Data

stats_fb <- left_join(stats_final, stats_baseline, by = c("stud_id"))

#Descriptives Total Students in this Sample is 51 from Stats 2001 and 2002

table(stats_fb$urm, exclude = T) #14 racially marginalized students, 37 racial majority (white and Asian)
## 
##  0  1 
## 37 14
table(stats_fb$gender_resolved, exclude = T) #41 women, 9 men, 1 nonbinary
## 
##  1  2  3 
##  9 41  1
table(stats_fb$fg, exclude = T) #11 FG, 38 CG, 2 missing
## 
##    0    1 <NA> 
##   38   11    2
#Correlation table a couple interesting things to present here like those who mentioned interest value also mentioned emotional cost
stats_fb %>% 
  select(weighing_comp_code_f, weighing_iv_code_f, weighing_uv_code_f, weighing_av_code_f, weighing_prosocial_code_f, weighing_te_code_f, 
         weighing_lv_code_f, weighing_em_code_f, weighing_sunk_code_f, weighing_finance_code_f, urm, female, fg) %>%
  corAPA()
measure weighing_comp_code_f weighing_iv_code_f weighing_uv_code_f weighing_av_code_f weighing_prosocial_code_f weighing_te_code_f weighing_lv_code_f weighing_em_code_f weighing_sunk_code_f weighing_finance_code_f urm female fg
  1. weighing_comp_code_f
  1. weighing_iv_code_f
0.06
  1. weighing_uv_code_f
-0.19 0.22
  1. weighing_av_code_f
0.06 -0.03 -0.18
  1. weighing_prosocial_code_f
-0.10 -0.04 -0.10 0.28
  1. weighing_te_code_f
0.01 0.17 -0.02 0.08 -0.01
  1. weighing_lv_code_f
0.04 0.27 0.15 -0.02 0.28 0.28
  1. weighing_em_code_f
0.13 0.33* 0.19 0.19 0.23 0.42** 0.57***
  1. weighing_sunk_code_f
-0.11 -0.10 -0.13 -0.13 -0.23 -0.15 -0.07 -0.08
  1. weighing_finance_code_f
0.00 -0.16 0.09 0.25 0.04 0.20 0.14 0.28 0.27
  1. urm
-0.15 -0.12 0.10 -0.24 -0.10 -0.17 0.01 -0.07 0.13 0.13
  1. female
-0.12 0.04 0.00 -0.13 -0.16 0.04 0.13 -0.19 0.09 -0.04 0.29*
  1. fg
0.05 -0.07 0.00 -0.16 -0.16 0.28 0.06 -0.02 0.18 0.20 0.34* 0.13
mean 0.2 0.17 0.28 0.28 0.54 0.33 0.09 0.13 0.04 0.11 0.27 0.82 0.22
sd 0.4 0.38 0.46 0.46 0.5 0.47 0.28 0.34 0.21 0.31 0.45 0.39 0.42
prop.table(table(stats_fb$weighing_comp_code_f)) #Competence - 20% of students mentioned competence
## 
##         0         1 
## 0.8043478 0.1956522
prop.table(table(stats_fb$weighing_iv_code_f)) #Interest Value
## 
##        0        1 
## 0.826087 0.173913
prop.table(table(stats_fb$weighing_uv_code_f)) #Utility Value
## 
##         0         1 
## 0.7173913 0.2826087
prop.table(table(stats_fb$weighing_av_code_f)) #Attainment Value
## 
##         0         1 
## 0.7173913 0.2826087
prop.table(table(stats_fb$weighing_prosocial_code_f)) #Prosocial Value
## 
##         0         1 
## 0.4565217 0.5434783
prop.table(table(stats_fb$weighing_te_code_f)) #Task Effort Cost
## 
##        0        1 
## 0.673913 0.326087
prop.table(table(stats_fb$weighing_lv_code_f)) #Loss of Valued Alternatives Cost
## 
##          0          1 
## 0.91304348 0.08695652
prop.table(table(stats_fb$weighing_em_code_f)) #Emotional Cost
## 
##         0         1 
## 0.8695652 0.1304348
prop.table(table(stats_fb$weighing_sunk_code_f)) #Sunk Cost 
## 
##          0          1 
## 0.95652174 0.04347826
prop.table(table(stats_fb$weighing_finance_code_f)) #Financial Cost
## 
##         0         1 
## 0.8913043 0.1086957

#Differences in codes by race

t.test(stats_fb$weighing_comp_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_comp_code_f by stats_fb$urm
## t = 1.187, df = 23.739, p-value = 0.247
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.1018408  0.3771655
## sample estimates:
## mean in group 0 mean in group 1 
##      0.22857143      0.09090909
t.test(stats_fb$weighing_iv_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_iv_code_f by stats_fb$urm
## t = 0.95788, df = 22.486, p-value = 0.3483
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.1268014  0.3449832
## sample estimates:
## mean in group 0 mean in group 1 
##      0.20000000      0.09090909
t.test(stats_fb$weighing_uv_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_uv_code_f by stats_fb$urm
## t = -0.62797, df = 15.182, p-value = 0.5394
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.4675762  0.2545892
## sample estimates:
## mean in group 0 mean in group 1 
##       0.2571429       0.3636364
t.test(stats_fb$weighing_av_code_f ~ stats_fb$urm) #p = 0.04857 (significant difference) white and Asian students mentioned attainment more than racially marginalized
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_av_code_f by stats_fb$urm
## t = 2.0647, df = 27.303, p-value = 0.04857
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  0.001694822 0.502201282
## sample estimates:
## mean in group 0 mean in group 1 
##      0.34285714      0.09090909
t.test(stats_fb$weighing_prosocial_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_prosocial_code_f by stats_fb$urm
## t = 0.65343, df = 16.251, p-value = 0.5226
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.2618397  0.4956059
## sample estimates:
## mean in group 0 mean in group 1 
##       0.5714286       0.4545455
t.test(stats_fb$weighing_te_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_te_code_f by stats_fb$urm
## t = 1.2859, df = 20.103, p-value = 0.2131
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.1178731  0.4970939
## sample estimates:
## mean in group 0 mean in group 1 
##       0.3714286       0.1818182
t.test(stats_fb$weighing_lv_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_lv_code_f by stats_fb$urm
## t = -0.050529, df = 15.99, p-value = 0.9603
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.2231482  0.2127585
## sample estimates:
## mean in group 0 mean in group 1 
##      0.08571429      0.09090909
t.test(stats_fb$weighing_em_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_em_code_f by stats_fb$urm
## t = 0.47689, df = 19.524, p-value = 0.6387
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.1756331  0.2795292
## sample estimates:
## mean in group 0 mean in group 1 
##      0.14285714      0.09090909
t.test(stats_fb$weighing_sunk_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_sunk_code_f by stats_fb$urm
## t = -0.65417, df = 12.039, p-value = 0.5253
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.2698900  0.1452147
## sample estimates:
## mean in group 0 mean in group 1 
##      0.02857143      0.09090909
t.test(stats_fb$weighing_finance_code_f ~ stats_fb$urm)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_finance_code_f by stats_fb$urm
## t = -0.73319, df = 13.245, p-value = 0.4762
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3787443  0.1865365
## sample estimates:
## mean in group 0 mean in group 1 
##      0.08571429      0.18181818

#Differences in codes by gender

t.test(stats_fb$weighing_comp_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_comp_code_f by stats_fb$female
## t = 0.65912, df = 7.3216, p-value = 0.53
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3266910  0.5823301
## sample estimates:
## mean in group 0 mean in group 1 
##       0.2857143       0.1578947
t.test(stats_fb$weighing_iv_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_iv_code_f by stats_fb$female
## t = -0.26436, df = 8.5708, p-value = 0.7977
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3979379  0.3152311
## sample estimates:
## mean in group 0 mean in group 1 
##       0.1428571       0.1842105
t.test(stats_fb$weighing_uv_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_uv_code_f by stats_fb$female
## t = -0.018898, df = 8.0864, p-value = 0.9854
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.4616372  0.4541184
## sample estimates:
## mean in group 0 mean in group 1 
##       0.2857143       0.2894737
t.test(stats_fb$weighing_av_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_av_code_f by stats_fb$female
## t = 0.77077, df = 7.6193, p-value = 0.4641
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3338129  0.6646400
## sample estimates:
## mean in group 0 mean in group 1 
##       0.4285714       0.2631579
t.test(stats_fb$weighing_prosocial_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_prosocial_code_f by stats_fb$female
## t = 1.0613, df = 8.5657, p-value = 0.3176
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.2460361  0.6746075
## sample estimates:
## mean in group 0 mean in group 1 
##       0.7142857       0.5000000
t.test(stats_fb$weighing_te_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_te_code_f by stats_fb$female
## t = -0.28162, df = 8.2949, p-value = 0.7851
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.5153058  0.4025238
## sample estimates:
## mean in group 0 mean in group 1 
##       0.2857143       0.3421053
t.test(stats_fb$weighing_lv_code_f ~ stats_fb$female)# p = 0.04389 (significant difference) women mentioned lova more than men
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_lv_code_f by stats_fb$female
## t = -2.0864, df = 37, p-value = 0.04389
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.20749018 -0.00303614
## sample estimates:
## mean in group 0 mean in group 1 
##       0.0000000       0.1052632
t.test(stats_fb$weighing_em_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_em_code_f by stats_fb$female
## t = 0.94376, df = 6.9254, p-value = 0.377
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.2726649  0.6335672
## sample estimates:
## mean in group 0 mean in group 1 
##       0.2857143       0.1052632
t.test(stats_fb$weighing_sunk_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_sunk_code_f by stats_fb$female
## t = -1.4337, df = 37, p-value = 0.16
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.1270127  0.0217495
## sample estimates:
## mean in group 0 mean in group 1 
##      0.00000000      0.05263158
t.test(stats_fb$weighing_finance_code_f ~ stats_fb$female)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_finance_code_f by stats_fb$female
## t = 0.24814, df = 7.571, p-value = 0.8106
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3152524  0.3904404
## sample estimates:
## mean in group 0 mean in group 1 
##       0.1428571       0.1052632

#Differences in codes by FG status (no significant differences here)

t.test(stats_fb$weighing_comp_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_comp_code_f by stats_fb$fg
## t = -0.31421, df = 9.4816, p-value = 0.7602
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.4524475  0.3413363
## sample estimates:
## mean in group 0 mean in group 1 
##       0.1944444       0.2500000
t.test(stats_fb$weighing_iv_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_iv_code_f by stats_fb$fg
## t = 0.48982, df = 11.397, p-value = 0.6336
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.2412800  0.3801688
## sample estimates:
## mean in group 0 mean in group 1 
##       0.1944444       0.1250000
t.test(stats_fb$weighing_uv_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_uv_code_f by stats_fb$fg
## t = 0, df = 10, p-value = 1
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3994703  0.3994703
## sample estimates:
## mean in group 0 mean in group 1 
##            0.25            0.25
t.test(stats_fb$weighing_av_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_av_code_f by stats_fb$fg
## t = 1.226, df = 13.092, p-value = 0.2418
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.1373692  0.4984804
## sample estimates:
## mean in group 0 mean in group 1 
##       0.3055556       0.1250000
t.test(stats_fb$weighing_prosocial_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_prosocial_code_f by stats_fb$fg
## t = 1.0362, df = 10.118, p-value = 0.3243
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.2389585  0.6556252
## sample estimates:
## mean in group 0 mean in group 1 
##       0.5833333       0.3750000
t.test(stats_fb$weighing_te_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_te_code_f by stats_fb$fg
## t = -1.7534, df = 9.5459, p-value = 0.1115
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.79131199  0.09686755
## sample estimates:
## mean in group 0 mean in group 1 
##       0.2777778       0.6250000
t.test(stats_fb$weighing_lv_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_lv_code_f by stats_fb$fg
## t = -0.31224, df = 9.0568, p-value = 0.7619
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3432517  0.2599183
## sample estimates:
## mean in group 0 mean in group 1 
##      0.08333333      0.12500000
t.test(stats_fb$weighing_em_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_em_code_f by stats_fb$fg
## t = 0.10065, df = 10.298, p-value = 0.9218
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.2923772  0.3201549
## sample estimates:
## mean in group 0 mean in group 1 
##       0.1388889       0.1250000
t.test(stats_fb$weighing_sunk_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_sunk_code_f by stats_fb$fg
## t = -0.75926, df = 7.7047, p-value = 0.4703
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3944861  0.2000416
## sample estimates:
## mean in group 0 mean in group 1 
##      0.02777778      0.12500000
t.test(stats_fb$weighing_finance_code_f ~ stats_fb$fg)
## 
##  Welch Two Sample t-test
## 
## data:  stats_fb$weighing_finance_code_f by stats_fb$fg
## t = -0.97924, df = 8.1764, p-value = 0.3555
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.5576813  0.2243480
## sample estimates:
## mean in group 0 mean in group 1 
##      0.08333333      0.25000000