Descriptives NEW

descriptives_table <- function(data, category) {
  count_table <- table(data[[category]])
  prop_table <- prop.table(count_table)
  combined_table <- data.frame(
    Category = names(count_table),
    Count = as.numeric(count_table),
    Proportion = as.numeric(prop_table))

  return(combined_table)
}
descriptives_table(df, "T1_C1_race")
##                    Category Count Proportion
## 1 Black or African American    90 0.88235294
## 2         Hispanic / Latino     4 0.03921569
## 3         Two or more races     6 0.05882353
## 4                     White     2 0.01960784
descriptives_table(df, "T1_Q2_gender")
##     Category Count Proportion
## 1     Female    45 0.43689320
## 2       Male    55 0.53398058
## 3 Non-binary     3 0.02912621
descriptives_table(df, "T1_C1_Class_Level")
##   Category Count Proportion
## 1   Junior    66  0.6407767
## 2   Senior    37  0.3592233
descriptives_table(df_juniors, "T1_C1_race")
##                    Category Count Proportion
## 1 Black or African American    56 0.86153846
## 2         Hispanic / Latino     2 0.03076923
## 3         Two or more races     6 0.09230769
## 4                     White     1 0.01538462
descriptives_table(df_juniors, "T1_C1_gender")
## [1] Count      Proportion
## <0 rows> (or 0-length row.names)
descriptives_table(df_seniors, "T1_C1_race")
##                    Category Count Proportion
## 1 Black or African American    34 0.91891892
## 2         Hispanic / Latino     2 0.05405405
## 3                     White     1 0.02702703
descriptives_table(df_seniors, "T1_C1_gender")
## [1] Count      Proportion
## <0 rows> (or 0-length row.names)

Summary Stats NEW

#function to do it all at once

calculate_summary_stats_with_category <- function(data, category_var, vars) {
  # Create an empty data frame for the results
  summary_df <- data.frame()
  
  # Loop through unique values of the categorical variable
  for (category in unique(data[[category_var]])) {
    # Subset the data for the current category
    subset_data <- data[data[[category_var]] == category, vars, drop = FALSE]
    
    # Calculate mean and standard deviation for each variable, ignoring NA values
    means <- apply(subset_data, 2, function(x) mean(x, na.rm = TRUE))
    sds <- apply(subset_data, 2, function(x) sd(x, na.rm = TRUE))
    
    # Create a summary dataframe for the current category
    category_summary <- data.frame(
      Category = category,
      Variable = names(means),
      Mean = means,
      SD = sds
    )
    
    # Combine with the overall summary dataframe
    summary_df <- rbind(summary_df, category_summary)
  }
  
  # Return the summary dataframe
  return(summary_df)
}

calculate_summary_stats_with_category(data = df, category_var = "T1_Condition" , vars = c("T1_C_ACB", "T1_C_AD", "T2_C_ACB", "T2_C_AD"))
##               Category Variable     Mean        SD
## T1_C_ACB  Intervention T1_C_ACB 5.119048 1.3740164
## T1_C_AD   Intervention  T1_C_AD 5.793651 0.6785621
## T2_C_ACB  Intervention T2_C_ACB 5.265625 1.1638671
## T2_C_AD   Intervention  T2_C_AD 5.750000 1.0608714
## T1_C_ACB1      Control T1_C_ACB 4.755814 1.3200473
## T1_C_AD1       Control  T1_C_AD 5.457364 1.1103726
## T2_C_ACB1      Control T2_C_ACB 5.025000 1.6249260
## T2_C_AD1       Control  T2_C_AD 5.483333 0.9396308

Summary Stats Juniors NEW

calculate_summary_stats_with_category(data = df_juniors, category_var = "T1_Condition" , vars = c("T1_C_ACB", "T1_C_AD", "T2_C_ACB", "T2_C_AD"))
##               Category Variable     Mean        SD
## T1_C_ACB  Intervention T1_C_ACB 5.220000 1.4367208
## T1_C_AD   Intervention  T1_C_AD 5.826667 0.6812298
## T2_C_ACB  Intervention T2_C_ACB 5.526316 1.1603841
## T2_C_AD   Intervention  T2_C_AD 5.964912 0.5199090
## T1_C_ACB1      Control T1_C_ACB 4.592593 1.3376000
## T1_C_AD1       Control  T1_C_AD 5.435897 1.1576575
## T2_C_ACB1      Control T2_C_ACB 5.134615 1.6465582
## T2_C_AD1       Control  T2_C_AD 5.589744 0.8289629

Summary Stats Seniors NEW

calculate_summary_stats_with_category(data = df_seniors, category_var = "T1_Condition" , vars = c("T1_C_ACB", "T1_C_AD", "T2_C_ACB", "T2_C_AD"))
##               Category Variable     Mean        SD
## T1_C_ACB  Intervention T1_C_ACB 4.970588 1.3046861
## T1_C_AD   Intervention  T1_C_AD 5.745098 0.6925137
## T2_C_ACB  Intervention T2_C_ACB 4.884615 1.1021541
## T2_C_AD   Intervention  T2_C_AD 5.435897 1.5237904
## T1_C_ACB1      Control T1_C_ACB 5.031250 1.2841177
## T1_C_AD1       Control  T1_C_AD 5.490196 1.0679527
## T2_C_ACB1      Control T2_C_ACB 4.821429 1.6244187
## T2_C_AD1       Control  T2_C_AD 5.285714 1.1236170

T-test NEW

ttest <- nice_t_test(data = df, response = names(df)[c(287,291,296,300)] , group = "T1_Condition")
## Using Welch t-test (base R's default; cf. https://doi.org/10.5334/irsp.82).
## For the Student t-test, use `var.equal = TRUE`. 
## 
ttesta <- nice_t_test(data = df, response = names(df)[c(287,291,296,300)] , group = "T1_Condition", var.equal=TRUE)
## Using Student t-test. 
## 
ttest_a <- merge(ttest, ttesta, by = "Dependent Variable")
knitr::kable(ttest_a)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB 1.2424194 82.66308 0.2175949 0.2696658 -0.1583116 0.6960355 1.2430120 83 0.2173634 0.2696658 -0.1583116 0.6960355
T1_C_AD 1.6891409 69.80381 0.0956549 0.3644666 -0.0654060 0.7921818 1.6799918 83 0.0967193 0.3644666 -0.0654060 0.7921818
T2_C_ACB 0.7310472 69.23723 0.4672172 0.1672072 -0.2990546 0.6322809 0.7050074 70 0.4831450 0.1672072 -0.2990546 0.6322809
T2_C_AD 1.1145715 62.54072 0.2692990 0.2679671 -0.1999331 0.7339732 1.1298486 70 0.2623968 0.2679671 -0.1999331 0.7339732

T-test Juniors NEW

ttestj <- nice_t_test(data = df_juniors, response = names(df_juniors)[c(287,291,296,300)] , group = "T1_Condition")
## Using Welch t-test (base R's default; cf. https://doi.org/10.5334/irsp.82).
## For the Student t-test, use `var.equal = TRUE`. 
## 
ttestja <- nice_t_test(data = df_juniors, response = names(df_juniors)[c(287,291,296,300)] , group = "T1_Condition", var.equal=TRUE)
## Using Student t-test. 
## 
ttest_ja <- merge(ttestj, ttestja, by = "Dependent Variable")
knitr::kable(ttest_ja)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB 1.6263011 48.90484 0.1103130 0.4526544 -0.1006968 1.0016023 1.6308609 50 0.1092036 0.4526544 -0.1006968 1.0016023
T1_C_AD 1.4758308 40.74441 0.1476763 0.4093986 -0.1475684 0.9622837 1.4615643 49 0.1502445 0.4093986 -0.1475684 0.9622837
T2_C_ACB 0.9359604 42.96552 0.3545247 0.2677672 -0.3280057 0.8604628 0.8871857 43 0.3799144 0.2677672 -0.3280057 0.8604628
T2_C_AD 1.8606349 42.18237 0.0697761 0.5239694 -0.0807351 1.1227960 1.7360536 43 0.0897156 0.5239694 -0.0807351 1.1227960

T-test Seniors NEW

ttests <- nice_t_test(data = df_seniors, response = names(df_seniors)[c(287,291,296,300)] , group = "T1_Condition")
## Using Welch t-test (base R's default; cf. https://doi.org/10.5334/irsp.82).
## For the Student t-test, use `var.equal = TRUE`. 
## 
ttestsa <- nice_t_test(data = df_seniors, response = names(df_seniors)[c(287,291,296,300)] , group = "T1_Condition", var.equal=TRUE)
## Using Student t-test. 
## 
ttest_sa <- merge(ttests, ttestsa, by = "Dependent Variable")
knitr::kable(ttest_sa)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB -0.1345750 30.93253 0.8938198 -0.0468512 -0.7292594 0.6363091 -0.1345081 31 0.8938703 -0.0468512 -0.7292594 0.6363091
T1_C_AD 0.8257089 27.43396 0.4160923 0.2832158 -0.3947708 0.9568397 0.8257089 32 0.4150830 0.2832158 -0.3947708 0.9568397
T2_C_ACB 0.1190039 22.96915 0.9063069 0.0451886 -0.7102722 0.7997505 0.1173228 25 0.9075417 0.0451886 -0.7102722 0.7997505
T2_C_AD 0.2896773 21.99976 0.7747757 0.1128515 -0.6438189 0.8672806 0.2929956 25 0.7719438 0.1128515 -0.6438189 0.8672806

Summary NEW

# New results from Danika's analysis
knitr::include_graphics("All_NEW.png")

knitr::include_graphics("Juniors_NEW.png")

knitr::include_graphics("Seniors_NEW.png")

Descriptives ORIGINAL

descriptives_table <- function(data, category) {
  count_table <- table(data[[category]])
  prop_table <- prop.table(count_table)
  combined_table <- data.frame(
    Category = names(count_table),
    Count = as.numeric(count_table),
    Proportion = as.numeric(prop_table))

  return(combined_table)
}
descriptives_table(df1, "T1_C1_race")
##                    Category Count Proportion
## 1 Black or African American   108 0.89256198
## 2         Hispanic / Latino     4 0.03305785
## 3         Two or more races     7 0.05785124
## 4                     White     2 0.01652893
descriptives_table(df1, "T1_Q2_gender")
##     Category Count Proportion
## 1     Female    55 0.45081967
## 2       Male    64 0.52459016
## 3 Non-binary     3 0.02459016
descriptives_table(df1, "T1_C1_Class_Level")
##   Category Count Proportion
## 1   Junior    76  0.6229508
## 2   Senior    46  0.3770492
descriptives_table(df1_juniors, "T1_C1_race")
##                    Category Count Proportion
## 1 Black or African American    65 0.86666667
## 2         Hispanic / Latino     2 0.02666667
## 3         Two or more races     7 0.09333333
## 4                     White     1 0.01333333
descriptives_table(df1_juniors, "T1_C1_gender")
## [1] Count      Proportion
## <0 rows> (or 0-length row.names)
descriptives_table(df1_seniors, "T1_C1_race")
##                    Category Count Proportion
## 1 Black or African American    43 0.93478261
## 2         Hispanic / Latino     2 0.04347826
## 3                     White     1 0.02173913
descriptives_table(df1_seniors, "T1_C1_gender")
## [1] Count      Proportion
## <0 rows> (or 0-length row.names)

Summary Stats OLD

calculate_summary_stats_with_category(data = df1, category_var = "T1_C1_Condition" , vars = c("T1_C_ACB", "T1_C_AD", "T2_C_ACB", "T2_C_AD"))
##               Category Variable     Mean        SD
## T1_C_ACB  Intervention T1_C_ACB 5.068627 1.3528474
## T1_C_AD   Intervention  T1_C_AD 5.633987 0.8413082
## T2_C_ACB  Intervention T2_C_ACB 5.236111 1.1740413
## T2_C_AD   Intervention  T2_C_AD 5.685185 1.0171371
## T1_C_ACB1      Control T1_C_ACB 4.744898 1.2752551
## T1_C_AD1       Control  T1_C_AD 5.530612 1.0734989
## T2_C_ACB1      Control T2_C_ACB 4.975610 1.6353563
## T2_C_AD1       Control  T2_C_AD 5.495935 0.9313131

Summary Stats Juniors OLD

calculate_summary_stats_with_category(data = df1_juniors, category_var = "T1_C1_Condition" , vars = c("T1_C_ACB", "T1_C_AD", "T2_C_ACB", "T2_C_AD"))
##               Category Variable     Mean        SD
## T1_C_ACB  Intervention T1_C_ACB 5.225806 1.4132628
## T1_C_AD   Intervention  T1_C_AD 5.731183 0.8000896
## T2_C_ACB  Intervention T2_C_ACB 5.571429 1.1541849
## T2_C_AD   Intervention  T2_C_AD 5.888889 0.5510932
## T1_C_ACB1      Control T1_C_ACB 4.603448 1.2913124
## T1_C_AD1       Control  T1_C_AD 5.464286 1.1270680
## T2_C_ACB1      Control T2_C_ACB 5.134615 1.6465582
## T2_C_AD1       Control  T2_C_AD 5.589744 0.8289629

Summary Stats Seniors OLD

calculate_summary_stats_with_category(data = df1_seniors, category_var = "T1_C1_Condition" , vars = c("T1_C_ACB", "T1_C_AD", "T2_C_ACB", "T2_C_AD"))
##               Category Variable     Mean        SD
## T1_C_ACB  Intervention T1_C_ACB 4.825000 1.2489469
## T1_C_AD   Intervention  T1_C_AD 5.483333 0.9014284
## T2_C_ACB  Intervention T2_C_ACB 4.766667 1.0668155
## T2_C_AD   Intervention  T2_C_AD 5.400000 1.4153355
## T1_C_ACB1      Control T1_C_ACB 4.950000 1.2555142
## T1_C_AD1       Control  T1_C_AD 5.619048 1.0180903
## T2_C_ACB1      Control T2_C_ACB 4.700000 1.6344505
## T2_C_AD1       Control  T2_C_AD 5.333333 1.0983393

T-test ORIGINAL

ttest1 <- nice_t_test(data = df1, response = names(df1)[c(381,385,390,394)] , group = "T1_C1_Condition")
## Using Welch t-test (base R's default; cf. https://doi.org/10.5334/irsp.82).
## For the Student t-test, use `var.equal = TRUE`. 
## 
ttest1a <- nice_t_test(data = df1, response = names(df1)[c(381,385,390,394)] , group = "T1_C1_Condition", var.equal = TRUE)
## Using Student t-test. 
## 
ttest1_1a <- merge(ttest1, ttest1a, by = "Dependent Variable")
knitr::kable(ttest1_1a)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB 1.2317435 97.96597 0.2209934 0.2461045 -0.1480963 0.6390604 1.2302761 98 0.2215387 0.2461045 -0.1480963 0.6390604
T1_C_AD 0.5345607 90.95821 0.5942579 0.1074512 -0.2851811 0.4995367 0.5371485 98 0.5923826 0.1074512 -0.2851811 0.4995367
T2_C_ACB 0.8096621 72.27913 0.4207920 0.1810792 -0.2681167 0.6290750 0.7928051 75 0.4303922 0.1810792 -0.2681167 0.6290750
T2_C_AD 0.8472621 71.56320 0.3996737 0.1946403 -0.2547452 0.6427363 0.8521785 75 0.3968281 0.1946403 -0.2547452 0.6427363

T-test Juniors ORIGINAL

ttest1j <- nice_t_test(data = df1_juniors, response = names(df1_juniors)[c(381,385,390,394)] , group = "T1_C1_Condition")
## Using Welch t-test (base R's default; cf. https://doi.org/10.5334/irsp.82).
## For the Student t-test, use `var.equal = TRUE`. 
## 
ttest1ja <- nice_t_test(data = df1_juniors, response = names(df1_juniors)[c(381,385,390,394)] , group = "T1_C1_Condition", var.equal = TRUE)
## Using Student t-test. 
## 
ttest1j_1ja <- merge(ttest1j, ttest1ja, by = "Dependent Variable")
knitr::kable(ttest1j_1ja)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB 1.782325 57.97100 0.0799332 0.4590473 -0.0560341 0.9702799 1.776895 58 0.0808296 0.4590473 -0.0560341 0.9702799
T1_C_AD 1.038762 48.18783 0.3040999 0.2754841 -0.2391876 0.7877672 1.056648 57 0.2951301 0.2754841 -0.2391876 0.7877672
T2_C_ACB 1.066634 44.21520 0.2919267 0.3015547 -0.2784870 0.8782921 1.027812 45 0.3095317 0.3015547 -0.2784870 0.8782921
T2_C_AD 1.479322 43.54660 0.1462526 0.4161441 -0.1675125 0.9952862 1.418375 45 0.1629700 0.4161441 -0.1675125 0.9952862

T-test Seniors ORIGINAL

ttest1s <- nice_t_test(data = df1_seniors, response = names(df1_seniors)[c(381,385,390,394)] , group = "T1_C1_Condition")
## Using Welch t-test (base R's default; cf. https://doi.org/10.5334/irsp.82).
## For the Student t-test, use `var.equal = TRUE`. 
## 
ttest1sa <- nice_t_test(data = df1_seniors, response = names(df1_seniors)[c(381,385,390,394)] , group = "T1_C1_Condition", var.equal = TRUE)
## Using Student t-test. 
## 
ttest1s_1sa <- merge(ttest1s, ttest1sa, by = "Dependent Variable")
knitr::kable(ttest1s_1sa)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB -0.3156634 37.99895 0.7539853 -0.0998215 -0.7193666 0.5210038 -0.3156634 38 0.7539852 -0.0998215 -0.7193666 0.5210038
T1_C_AD -0.4524157 38.80227 0.6534889 -0.1409254 -0.7531923 0.4731378 -0.4510473 39 0.6544535 -0.1409254 -0.7531923 0.4731378
T2_C_ACB 0.1322876 24.09626 0.8958553 0.0483046 -0.6679130 0.7636638 0.1322876 28 0.8957029 0.0483046 -0.6679130 0.7636638
T2_C_AD 0.1441233 26.37435 0.8864988 0.0526264 -0.6636503 0.7679680 0.1441233 28 0.8864355 0.0526264 -0.6636503 0.7679680

T-test NEW v OLD

ttest_1 <- merge(ttest, ttest1, by = "Dependent Variable")
knitr::kable(ttest_1)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB 1.2424194 82.66308 0.2175949 0.2696658 -0.1583116 0.6960355 1.2317435 97.96597 0.2209934 0.2461045 -0.1480963 0.6390604
T1_C_AD 1.6891409 69.80381 0.0956549 0.3644666 -0.0654060 0.7921818 0.5345607 90.95821 0.5942579 0.1074512 -0.2851811 0.4995367
T2_C_ACB 0.7310472 69.23723 0.4672172 0.1672072 -0.2990546 0.6322809 0.8096621 72.27913 0.4207920 0.1810792 -0.2681167 0.6290750
T2_C_AD 1.1145715 62.54072 0.2692990 0.2679671 -0.1999331 0.7339732 0.8472621 71.56320 0.3996737 0.1946403 -0.2547452 0.6427363
#Differences: None

T-test Juniors NEW v OLD

ttestj_1j <- merge(ttestj, ttest1j, by = "Dependent Variable")
knitr::kable(ttestj_1j)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB 1.6263011 48.90484 0.1103130 0.4526544 -0.1006968 1.0016023 1.782325 57.97100 0.0799332 0.4590473 -0.0560341 0.9702799
T1_C_AD 1.4758308 40.74441 0.1476763 0.4093986 -0.1475684 0.9622837 1.038762 48.18783 0.3040999 0.2754841 -0.2391876 0.7877672
T2_C_ACB 0.9359604 42.96552 0.3545247 0.2677672 -0.3280057 0.8604628 1.066634 44.21520 0.2919267 0.3015547 -0.2784870 0.8782921
T2_C_AD 1.8606349 42.18237 0.0697761 0.5239694 -0.0807351 1.1227960 1.479322 43.54660 0.1462526 0.4161441 -0.1675125 0.9952862
#Differences: No changes in significance, but T1_C_ACB lower p-value in OLD and T2_C_AD lower p-value in NEW.

T-test Seniors NEW v OLD

ttests_1s <- merge(ttests, ttest1s, by = "Dependent Variable")
knitr::kable(ttests_1s)
Dependent Variable t.x df.x p.x d.x CI_lower.x CI_upper.x t.y df.y p.y d.y CI_lower.y CI_upper.y
T1_C_ACB -0.1345750 30.93253 0.8938198 -0.0468512 -0.7292594 0.6363091 -0.3156634 37.99895 0.7539853 -0.0998215 -0.7193666 0.5210038
T1_C_AD 0.8257089 27.43396 0.4160923 0.2832158 -0.3947708 0.9568397 -0.4524157 38.80227 0.6534889 -0.1409254 -0.7531923 0.4731378
T2_C_ACB 0.1190039 22.96915 0.9063069 0.0451886 -0.7102722 0.7997505 0.1322876 24.09626 0.8958553 0.0483046 -0.6679130 0.7636638
T2_C_AD 0.2896773 21.99976 0.7747757 0.1128515 -0.6438189 0.8672806 0.1441233 26.37435 0.8864988 0.0526264 -0.6636503 0.7679680
#Differences: None

Summary ORIGINAL

# Proximal effects: Increased appreciation of difference for all students but especially juniors (Students with different backgrounds and experiences can find their own way of being successful at college; T1_Q131_psych_measures_6). Increased anticipated college belonging for all students but especially juniors (I do not think I would fit in well at college.; T1_Q131_psych_measures_7). Increased expectancy of success in college for all students but especially seniors (I expect that the academic experience at college will be difficult for me.; T1_Q131_psych_measures_2). Increased college fit for seniors (I think I would fit in at some colleges but not other colleges.; T1_Q131_psych_measures_8).

# Distal effects: Increased appreciation of differences for juniors (There are different ways to be successful as a college student; T2_Q131_psych_measures_11). Increased likelihood of applying to college (When thinking about college ... - I plan to go to college after graduating high school; T2_Q58_2).

# Original results from last year's analysis
knitr::include_graphics("T-test.png")

knitr::include_graphics("Juniors.png")

knitr::include_graphics("Seniors.png")