============================================================================== 1. Descriptives (student-por.csv) ============================================================================== rows: 649; columns: 33 in the file (+3 dummies built here) missing values in the file: 0 Numeric summary: count mean std median min max G3 649.000 11.906 3.231 12.000 0.000 19.000 G1 649.000 11.399 2.745 11.000 0.000 19.000 G2 649.000 11.570 2.914 11.000 0.000 19.000 absences 649.000 3.659 4.641 2.000 0.000 32.000 age 649.000 16.744 1.218 17.000 15.000 22.000 G3 = 0: 15 students (2.3%) G3 count table (0 to 20): G3 0 15 1 1 5 1 6 3 7 10 8 35 9 35 10 97 11 104 12 72 13 82 14 63 15 49 16 36 17 29 18 15 19 2 studytime bands (1: under 2 h, 2: 2 to 5 h, 3: 5 to 10 h, 4: over 10 h): studytime 1 212 2 305 3 97 4 35 failures (past class failures): failures 0 549 1 70 2 16 3 14 internet: internet yes 498 no 151 higher: higher yes 580 no 69 school: school GP 423 MS 226 sex: sex F 383 M 266 Medu (mother's education, 0 none to 4 higher): Medu 0 6 1 143 2 186 3 139 4 175 absences: median 2, share with 0 absences 37.6%, max 32 ============================================================================== 2. Two-sample t-test: G3 by internet access at home ============================================================================== n mean sd median internet no 151 11.026 3.447 11.000 yes 498 12.173 3.117 12.000 Levene (Brown-Forsythe, centre = median, as car::leveneTest default): W = 0.091, p = 0.763 Welch t = 3.658, df = 229.4, p < 0.001 (two-sided) mean difference (yes minus no) = 1.146, 95% CI [0.529, 1.764] Student (pooled) t = 3.860, df = 647, p < 0.001 (for the Excel equal-variance route) Cohen's d = 0.359, approximate 95% CI [0.175, 0.542] Shapiro-Wilk within each group (the zero grades make both non-normal): yes W = 0.938, p < 0.001; no W = 0.885, p < 0.001 Mann-Whitney U (rank-based check, no normality assumption) = 45,616, p < 0.001; R's wilcox.test prints the other group's U, 29,582 ============================================================================== 3. One-way ANOVA: G3 by weekly study-time band ============================================================================== n mean sd median 1 (under 2 h) 212 10.844 3.219 11.000 2 (2 to 5 h) 305 12.092 3.243 12.000 3 (5 to 10 h) 97 13.227 2.502 13.000 4 (over 10 h) 35 13.057 3.038 13.000 Levene (centre = median): W = 1.026, p = 0.380 ANOVA table (type I, one factor): df sum_sq mean_sq F PR(>F) between (studytime) 3.000 465.078 155.026 15.876 0.000 within (residual) 645.000 6,298.189 9.765 NaN NaN F(3, 645) = 15.88, p < 0.001 mean squares to two decimals: between 155.03, within 9.76; total SS 6763.27 on 648 df eta squared = SS_between / SS_total = 465.08 / 6763.27 = 0.069 Welch ANOVA (fallback if Levene rejects): F(3, 139.1) = 18.18, p < 0.001 Kruskal-Wallis H(3) (rank-based check, no normality assumption) = 50.32, p < 0.001 Tukey HSD (alpha = 0.05): Multiple Comparison of Means - Tukey HSD, FWER=0.05 =================================================== group1 group2 meandiff p-adj lower upper reject --------------------------------------------------- band 1 band 2 1.2475 0.0001 0.5278 1.9672 True band 1 band 3 2.3825 0.0 1.3958 3.3691 True band 1 band 4 2.2128 0.0007 0.7443 3.6813 True band 2 band 3 1.135 0.0103 0.1968 2.0732 True band 2 band 4 0.9653 0.3084 -0.4711 2.4018 False band 3 band 4 -0.1697 0.9927 -1.7567 1.4174 False --------------------------------------------------- ============================================================================== 4. Chi-square test of independence: school x higher ============================================================================== Observed: higher no yes school GP 32 391 MS 37 189 Row percentages (share of each school): higher no yes school GP 7.600 92.400 MS 16.400 83.600 Expected counts under independence (row total x column total / N): higher no yes school GP 44.970 378.030 MS 24.030 201.970 Pearson chi-square with Yates continuity correction (R chisq.test default on 2x2): chi2(1) = 11.115, p < 0.001 Pearson chi-square without correction (Excel CHISQ.TEST): chi2(1) = 12.024, p < 0.001 Cramer's V (from the uncorrected statistic) = 0.136 minimum expected count = 24.03 (rule: every expected count at least 5) ============================================================================== 5. Multiple linear regression (model fixed before looking at the output) ============================================================================== G3 ~ studytime + failures + absences + higher_yes + school_MS + sex_M + Medu dummies: higher_yes = 1 if higher == yes; school_MS = 1 if school == MS; sex_M = 1 if sex == M OLS coefficients with conventional standard errors: coef SE t p CI low CI high Intercept 9.998 0.535 18.698 0.000 8.948 11.048 studytime 0.437 0.137 3.184 0.002 0.168 0.707 failures -1.469 0.194 -7.580 0.000 -1.850 -1.089 absences -0.038 0.024 -1.574 0.116 -0.085 0.009 higher_yes 1.711 0.378 4.523 0.000 0.968 2.453 school_MS -1.397 0.241 -5.787 0.000 -1.871 -0.923 sex_M -0.691 0.227 -3.043 0.002 -1.137 -0.245 Medu 0.306 0.101 3.025 0.003 0.107 0.504 n = 649; R2 = 0.291; adjusted R2 = 0.284; F(7, 641) = 37.65, p < 0.001; residual SE = 2.734 Unadjusted slope of G3 on studytime alone (for the adjusted-versus-raw comparison): 0.973 per band, 95% CI [0.682, 1.264], p < 0.001, R2 = 0.062 Internet added to the seven-predictor model (ties test 1 to the model): internet_yes = 0.351, p = 0.192; studytime = 0.438, p = 0.002 ============================================================================== 6. Diagnostics on the model in section 5 ============================================================================== residuals: mean -0.0000, SD 2.720, min -12.410, max 7.433, skewness -0.892, excess kurtosis 3.293 standardised residuals below -3: 12; above +3: 0 of the residuals below -3, students with G3 = 0: 11 Shapiro-Wilk on residuals: W = 0.942, p < 0.001 Breusch-Pagan (studentised, Koenker): LM = 39.17, p < 0.001; F = 5.88, p < 0.001 Ramsey RESET (squared and cubed fitted values, as lmtest::resettest default): F(2, 639) = 4.44, p = 0.012 VIF: studytime 1.125 failures 1.146 absences 1.080 higher_yes 1.180 school_MS 1.148 sex_M 1.082 Medu 1.140 Cook's distance: max 0.0315; count above 4/n = 0.0062: 33; count above 1: 0 five largest Cook's distances (row index, G3, studytime, failures, absences, Cook's D): row 212: G3 = 16, studytime = 1, failures = 1, absences = 30, D = 0.0315 row 163: G3 = 0, studytime = 1, failures = 2, absences = 0, D = 0.0284 row 586: G3 = 0, studytime = 2, failures = 0, absences = 0, D = 0.0279 row 626: G3 = 0, studytime = 2, failures = 0, absences = 0, D = 0.0279 row 603: G3 = 0, studytime = 2, failures = 0, absences = 0, D = 0.0279 The 15 zero-grade students: 15 of 15 record 0 absences; 14 of 15 are at MS; 7 of 15 already had G2 = 0; G1 runs from 4 to 11 Re-run 1: same model, HC3 heteroscedasticity-consistent standard errors (t-based intervals, as R's coefci): coef SE t p CI low CI high Intercept 9.998 0.505 19.789 0.000 9.006 10.990 studytime 0.437 0.127 3.453 0.001 0.189 0.686 failures -1.469 0.203 -7.226 0.000 -1.869 -1.070 absences -0.038 0.025 -1.523 0.128 -0.087 0.011 higher_yes 1.711 0.374 4.580 0.000 0.977 2.444 school_MS -1.397 0.274 -5.105 0.000 -1.934 -0.860 sex_M -0.691 0.234 -2.957 0.003 -1.150 -0.232 Medu 0.306 0.111 2.759 0.006 0.088 0.523 n = 649; R2 = 0.291; adjusted R2 = 0.284; F(7, 641) = 32.94, p < 0.001; residual SE = 2.734 Re-run 2: same model without the 15 students with G3 = 0 (n = 634): coef SE t p CI low CI high Intercept 10.280 0.451 22.789 0.000 9.394 11.166 studytime 0.348 0.114 3.050 0.002 0.124 0.573 failures -1.204 0.165 -7.307 0.000 -1.527 -0.880 absences -0.078 0.020 -3.881 0.000 -0.118 -0.039 higher_yes 1.486 0.321 4.625 0.000 0.855 2.117 school_MS -0.838 0.204 -4.118 0.000 -1.238 -0.438 sex_M -0.609 0.191 -3.193 0.001 -0.983 -0.234 Medu 0.383 0.085 4.513 0.000 0.217 0.550 n = 634; R2 = 0.300; adjusted R2 = 0.292; F(7, 626) = 38.39, p < 0.001; residual SE = 2.264 re-run 2 residuals: skewness 0.146, excess kurtosis 0.448; standardised residuals below -3: 1, above +3: 1 re-run 2 Shapiro-Wilk: W = 0.987, p < 0.001; Breusch-Pagan (studentised): LM = 14.95, p = 0.037 re-run 2 RESET: F(2, 624) = 9.09, p < 0.001 ============================================================================== 6b. Which term bends the line? Nested F-tests and RESET on re-coded models ============================================================================== Each candidate term is freed from its linear coding into categories; the nested F asks whether the categories fit better than the linear coding, and RESET is repeated on the re-coded model. studytime as four categories instead of a 1 to 4 scale: nested F(2, 639) = 0.70, p = 0.497 (equal steps not rejected); RESET F(2, 637) = 4.35, p = 0.013 (curvature unchanged) failures as categories instead of a count: nested F(2, 639) = 8.89, p < 0.001 (the count coding is rejected); RESET F(2, 637) = 1.29, p = 0.277 (curvature gone) failures squared added to the original model: coefficient 0.815, p < 0.001; RESET F(2, 638) = 1.80, p = 0.165 Raw mean G3 by number of past failures (the whole drop comes with the first failure): n mean failures 0 549 12.510 1 70 8.643 2 16 8.812 3 14 8.071 Re-run 3: same model with failures as categories (0 failures is the baseline): coef SE t p CI low CI high Intercept 10.185 0.531 19.198 0.000 9.144 11.227 C(failures)[T.1] -2.764 0.364 -7.592 0.000 -3.479 -2.049 C(failures)[T.2] -2.612 0.702 -3.722 0.000 -3.990 -1.234 C(failures)[T.3] -3.093 0.747 -4.139 0.000 -4.561 -1.626 studytime 0.423 0.136 3.110 0.002 0.156 0.690 absences -0.026 0.024 -1.069 0.285 -0.073 0.021 higher_yes 1.650 0.374 4.408 0.000 0.915 2.386 school_MS -1.273 0.240 -5.292 0.000 -1.745 -0.800 sex_M -0.720 0.224 -3.207 0.001 -1.161 -0.279 Medu 0.274 0.100 2.738 0.006 0.078 0.471 n = 649; R2 = 0.311; adjusted R2 = 0.301; F(9, 639) = 31.98, p < 0.001; residual SE = 2.701 RESET F(2, 637) = 1.29, p = 0.277 ============================================================================== 7. Leakage: adding the period grades G1 and G2 as predictors ============================================================================== correlation G1 with G3: r = 0.826; G2 with G3: r = 0.919; G1 with G2: r = 0.865 OLS with G1 and G2 added: coef SE t p CI low CI high Intercept 0.176 0.323 0.543 0.587 -0.459 0.811 studytime 0.061 0.063 0.963 0.336 -0.063 0.185 failures -0.201 0.092 -2.178 0.030 -0.383 -0.020 absences 0.020 0.011 1.764 0.078 -0.002 0.041 higher_yes 0.168 0.176 0.950 0.342 -0.179 0.514 school_MS -0.205 0.114 -1.803 0.072 -0.428 0.018 sex_M -0.193 0.104 -1.850 0.065 -0.398 0.012 Medu -0.040 0.047 -0.848 0.397 -0.131 0.052 G1 0.129 0.037 3.512 0.000 0.057 0.201 G2 0.883 0.034 26.013 0.000 0.817 0.950 n = 649; R2 = 0.852; adjusted R2 = 0.850; F(9, 639) = 409.76, p < 0.001; residual SE = 1.250 Side by side (coefficient, p) for the seven original predictors: coef without G1, G2 p without coef with G1, G2 p with studytime 0.437 0.002 0.061 0.336 failures -1.469 0.000 -0.201 0.030 absences -0.038 0.116 0.020 0.078 higher_yes 1.711 0.000 0.168 0.342 school_MS -1.397 0.000 -0.205 0.072 sex_M -0.691 0.002 -0.193 0.065 Medu 0.306 0.003 -0.040 0.397 adjusted R2: 0.284 without the period grades, 0.850 with them