# Output of statistics-coursework-student-por.R, run with Rscript on 25 September 2026: R 4.5.3, car 3.1-5, lmtest 0.9-40, sandwich 3.1-3, against student-por.csv from https://archive.ics.uci.edu/static/public/320/student+performance.zip (SHA-256 a7594a11d7771c0efe1a740824e0e833da9c4cad07c39a9766a874575563fb3f). # t.test prints t = -3.658 because R orders the groups no, yes; the page reports yes minus no. wilcox.test prints W = 29582, the other group's U. Every other figure matches the Python output as printed. Loading required package: carData Loading required package: zoo Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date, as.Date.numeric 'data.frame': 649 obs. of 33 variables: $ school : chr "GP" "GP" "GP" "GP" ... $ sex : chr "F" "F" "F" "F" ... $ age : int 18 17 15 15 16 16 16 17 15 15 ... $ address : chr "U" "U" "U" "U" ... $ famsize : chr "GT3" "GT3" "LE3" "GT3" ... $ Pstatus : chr "A" "T" "T" "T" ... $ Medu : int 4 1 1 4 3 4 2 4 3 3 ... $ Fedu : int 4 1 1 2 3 3 2 4 2 4 ... $ Mjob : chr "at_home" "at_home" "at_home" "health" ... $ Fjob : chr "teacher" "other" "other" "services" ... $ reason : chr "course" "course" "other" "home" ... $ guardian : chr "mother" "father" "mother" "mother" ... $ traveltime: int 2 1 1 1 1 1 1 2 1 1 ... $ studytime : int 2 2 2 3 2 2 2 2 2 2 ... $ failures : int 0 0 0 0 0 0 0 0 0 0 ... $ schoolsup : chr "yes" "no" "yes" "no" ... $ famsup : chr "no" "yes" "no" "yes" ... $ paid : chr "no" "no" "no" "no" ... $ activities: chr "no" "no" "no" "yes" ... $ nursery : chr "yes" "no" "yes" "yes" ... $ higher : chr "yes" "yes" "yes" "yes" ... $ internet : Factor w/ 2 levels "no","yes": 1 2 2 2 1 2 2 1 2 2 ... $ romantic : chr "no" "no" "no" "yes" ... $ famrel : int 4 5 4 3 4 5 4 4 4 5 ... $ freetime : int 3 3 3 2 3 4 4 1 2 5 ... $ goout : int 4 3 2 2 2 2 4 4 2 1 ... $ Dalc : int 1 1 2 1 1 1 1 1 1 1 ... $ Walc : int 1 1 3 1 2 2 1 1 1 1 ... $ health : int 3 3 3 5 5 5 3 1 1 5 ... $ absences : int 4 2 6 0 0 6 0 2 0 0 ... $ G1 : int 0 9 12 14 11 12 13 10 15 12 ... $ G2 : int 11 11 13 14 13 12 12 13 16 12 ... $ G3 : int 11 11 12 14 13 13 13 13 17 13 ... Min. 1st Qu. Median Mean 3rd Qu. Max. 0.00 10.00 12.00 11.91 14.00 19.00 [1] 3.230656 0 1 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 15 1 1 3 10 35 35 97 104 72 82 63 49 36 29 15 2 1 2 3 4 212 305 97 35 0 1 2 3 549 70 16 14 no yes 151 498 Levene's Test for Homogeneity of Variance (center = median) Df F value Pr(>F) group 1 0.0913 0.7626 647 Welch Two Sample t-test data: G3 by internet t = -3.658, df = 229.37, p-value = 0.0003153 alternative hypothesis: true difference in means between group no and group yes is not equal to 0 95 percent confidence interval: -1.7635937 -0.5288077 sample estimates: mean in group no mean in group yes 11.02649 12.17269 Two Sample t-test data: G3 by internet t = -3.8597, df = 647, p-value = 0.0001249 alternative hypothesis: true difference in means between group no and group yes is not equal to 0 95 percent confidence interval: -1.7293279 -0.5630735 sample estimates: mean in group no mean in group yes 11.02649 12.17269 [1] 0.3585732 Shapiro-Wilk normality test data: g$yes W = 0.93817, p-value = 1.602e-13 Shapiro-Wilk normality test data: g$no W = 0.88525, p-value = 1.926e-09 Wilcoxon rank sum test with continuity correction data: G3 by internet W = 29582, p-value = 6.39e-05 alternative hypothesis: true location shift is not equal to 0 studytime_f G3.n G3.mean G3.sd 1 under 2 h 212.000000 10.844340 3.218624 2 2 to 5 h 305.000000 12.091803 3.243125 3 5 to 10 h 97.000000 13.226804 2.502104 4 over 10 h 35.000000 13.057143 3.038410 Levene's Test for Homogeneity of Variance (center = median) Df F value Pr(>F) group 3 1.0263 0.3804 645 Df Sum Sq Mean Sq F value Pr(>F) studytime_f 3 465 155.03 15.88 5.71e-10 *** Residuals 645 6298 9.76 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = G3 ~ studytime_f, data = d) $studytime_f diff lwr upr p adj 2 to 5 h-under 2 h 1.2474637 0.5277536 1.967174 0.0000559 5 to 10 h-under 2 h 2.3824645 1.3958316 3.369097 0.0000000 over 10 h-under 2 h 2.2128032 0.7442940 3.681312 0.0006612 5 to 10 h-2 to 5 h 1.1350008 0.1967750 2.073227 0.0103107 over 10 h-2 to 5 h 0.9653396 -0.4710944 2.401774 0.3083885 over 10 h-5 to 10 h -0.1696613 -1.7567354 1.417413 0.9927036 [1] 0.06876527 One-way analysis of means (not assuming equal variances) data: G3 and studytime_f F = 18.183, num df = 3.0, denom df = 139.1, p-value = 5.188e-10 Kruskal-Wallis rank sum test data: G3 by studytime_f Kruskal-Wallis chi-squared = 50.316, df = 3, p-value = 6.842e-11 no yes GP 32 391 MS 37 189 no yes GP 0.07565012 0.92434988 MS 0.16371681 0.83628319 Pearson's Chi-squared test with Yates' continuity correction data: tab X-squared = 11.115, df = 1, p-value = 0.0008564 Pearson's Chi-squared test data: tab X-squared = 12.024, df = 1, p-value = 0.0005253 no yes GP 44.97227 378.0277 MS 24.02773 201.9723 X-squared 0.1361124 Call: lm(formula = G3 ~ studytime + failures + absences + higher + school + sex + Medu, data = d) Residuals: Min 1Q Median 3Q Max -12.4096 -1.4549 -0.1158 1.7465 7.4327 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.99821 0.53471 18.698 < 2e-16 *** studytime 0.43727 0.13734 3.184 0.00152 ** failures -1.46938 0.19385 -7.580 1.22e-13 *** absences -0.03785 0.02405 -1.574 0.11600 higheryes 1.71060 0.37824 4.523 7.28e-06 *** schoolMS -1.39704 0.24140 -5.787 1.12e-08 *** sexM -0.69085 0.22706 -3.043 0.00244 ** Medu 0.30582 0.10109 3.025 0.00258 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 2.734 on 641 degrees of freedom Multiple R-squared: 0.2914, Adjusted R-squared: 0.2836 F-statistic: 37.65 on 7 and 641 DF, p-value: < 2.2e-16 2.5 % 97.5 % (Intercept) 8.94822089 11.048198058 studytime 0.16758504 0.706964538 failures -1.85003601 -1.088718304 absences -0.08507911 0.009373524 higheryes 0.96785684 2.453338532 schoolMS -1.87106399 -0.923009963 sexM -1.13671015 -0.244980044 Medu 0.10730711 0.504330050 Estimate Std. Error t value Pr(>|t|) (Intercept) 10.0277805 0.3115066 32.191228 1.851812e-136 studytime 0.9728416 0.1482611 6.561676 1.090809e-10 2.5 % 97.5 % (Intercept) 9.4160945 10.639466 studytime 0.6817105 1.263973 [1] 0.06239439 Estimate Std. Error t value Pr(>|t|) (Intercept) 9.78299866 0.55920730 17.494404 2.671799e-56 studytime 0.43757931 0.13726394 3.187868 1.503111e-03 failures -1.45714097 0.19396968 -7.512210 1.963970e-13 absences -0.03930405 0.02406237 -1.633424 1.028717e-01 higheryes 1.71335816 0.37803802 4.532238 6.965537e-06 schoolMS -1.34344932 0.24472460 -5.489637 5.811686e-08 sexM -0.69938216 0.22702552 -3.080632 2.154205e-03 Medu 0.27805034 0.10324613 2.693083 7.264893e-03 internetyes 0.35110788 0.26865608 1.306905 1.917145e-01 Shapiro-Wilk normality test data: residuals(fit) W = 0.94169, p-value = 2.841e-15 studentized Breusch-Pagan test data: fit BP = 39.172, df = 7, p-value = 1.812e-06 RESET test data: fit RESET = 4.4434, df1 = 2, df2 = 639, p-value = 0.01212 studytime failures absences higher school sex Medu 1.124863 1.146182 1.079628 1.179940 1.148056 1.082419 1.140113 79 151 156 164 170 171 0.014686631 0.008007588 0.015327391 0.028435410 0.009511705 0.009058532 173 186 213 352 414 441 0.017710430 0.006430393 0.031477263 0.013669044 0.008370172 0.023230987 520 524 553 564 568 572 0.018779435 0.018986791 0.007555939 0.017243986 0.023792868 0.016200226 584 587 596 598 601 604 0.024281642 0.027890368 0.007342402 0.017148237 0.011940657 0.027890368 606 607 611 618 627 637 0.022084025 0.007617814 0.024285408 0.006689477 0.027890368 0.011296229 638 640 641 0.019020293 0.018849185 0.026897283 [1] 0.03147726 [1] 15 [1] 15 GP MS 1 14 [1] 7 [1] 4 11 t test of coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.998209 0.505253 19.7885 < 2.2e-16 *** studytime 0.437275 0.126625 3.4533 0.0005902 *** failures -1.469377 0.203336 -7.2264 1.415e-12 *** absences -0.037853 0.024862 -1.5225 0.1283729 higheryes 1.710598 0.373527 4.5796 5.599e-06 *** schoolMS -1.397037 0.273644 -5.1053 4.359e-07 *** sexM -0.690845 0.233594 -2.9575 0.0032160 ** Medu 0.305819 0.110842 2.7590 0.0059626 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 2.5 % 97.5 % (Intercept) 9.00605901 10.9903599 studytime 0.18862553 0.6859240 failures -1.86866217 -1.0700921 absences -0.08667358 0.0109680 higheryes 0.97711400 2.4440814 schoolMS -1.93438328 -0.8596907 sexM -1.14954639 -0.2321438 Medu 0.08816059 0.5234766 Call: lm(formula = G3 ~ studytime + failures + absences + higher + school + sex + Medu, data = subset(d, G3 > 0)) Residuals: Min 1Q Median 3Q Max -10.8006 -1.5806 -0.2295 1.4274 6.7629 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 10.28011 0.45110 22.789 < 2e-16 *** studytime 0.34830 0.11419 3.050 0.002385 ** failures -1.20352 0.16470 -7.307 8.34e-13 *** absences -0.07807 0.02012 -3.881 0.000115 *** higheryes 1.48627 0.32135 4.625 4.55e-06 *** schoolMS -0.83796 0.20351 -4.118 4.34e-05 *** sexM -0.60863 0.19059 -3.193 0.001476 ** Medu 0.38325 0.08491 4.513 7.62e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 2.264 on 626 degrees of freedom Multiple R-squared: 0.3003, Adjusted R-squared: 0.2925 F-statistic: 38.39 on 7 and 626 DF, p-value: < 2.2e-16 Shapiro-Wilk normality test data: residuals(fit_nz) W = 0.98706, p-value = 2.127e-05 studentized Breusch-Pagan test data: fit_nz BP = 14.949, df = 7, p-value = 0.03666 RESET test data: fit_nz RESET = 9.0881, df1 = 2, df2 = 624, p-value = 0.0001287 Analysis of Variance Table Model 1: G3 ~ studytime + failures + absences + higher + school + sex + Medu Model 2: G3 ~ failures + absences + higher + school + sex + Medu + factor(studytime) Res.Df RSS Df Sum of Sq F Pr(>F) 1 641 4792.6 2 639 4782.1 2 10.479 0.7001 0.4969 RESET test data: fit_st RESET = 4.3524, df1 = 2, df2 = 637, p-value = 0.01326 Analysis of Variance Table Model 1: G3 ~ studytime + failures + absences + higher + school + sex + Medu Model 2: G3 ~ studytime + absences + higher + school + sex + Medu + factor(failures) Res.Df RSS Df Sum of Sq F Pr(>F) 1 641 4792.6 2 639 4662.8 2 129.74 8.8897 0.0001556 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 RESET test data: fit_fc RESET = 1.2853, df1 = 2, df2 = 637, p-value = 0.2773 Estimate Std. Error t value Pr(>|t|) 8.147901e-01 2.067353e-01 3.941223e+00 8.999621e-05 RESET test data: fit_sq RESET = 1.8049, df1 = 2, df2 = 638, p-value = 0.1653 failures G3 1 0 12.510018 2 1 8.642857 3 2 8.812500 4 3 8.071429 Call: lm(formula = G3 ~ studytime + absences + higher + school + sex + Medu + factor(failures), data = d) Residuals: Min 1Q Median 3Q Max -12.5072 -1.5053 0.0401 1.6572 7.3153 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 10.18549 0.53054 19.198 < 2e-16 *** studytime 0.42296 0.13598 3.110 0.001951 ** absences -0.02562 0.02396 -1.069 0.285309 higheryes 1.65044 0.37445 4.408 1.23e-05 *** schoolMS -1.27260 0.24049 -5.292 1.67e-07 *** sexM -0.71995 0.22447 -3.207 0.001406 ** Medu 0.27448 0.10026 2.738 0.006361 ** factor(failures)1 -2.76421 0.36410 -7.592 1.12e-13 *** factor(failures)2 -2.61203 0.70177 -3.722 0.000215 *** factor(failures)3 -3.09348 0.74737 -4.139 3.95e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 2.701 on 639 degrees of freedom Multiple R-squared: 0.3106, Adjusted R-squared: 0.3009 F-statistic: 31.98 on 9 and 639 DF, p-value: < 2.2e-16 2.5 % 97.5 % (Intercept) 9.14368683 11.22729649 studytime 0.15593952 0.68997976 absences -0.07267458 0.02142871 higheryes 0.91513060 2.38574843 schoolMS -1.74485294 -0.80035439 sexM -1.16073656 -0.27916870 Medu 0.07759643 0.47137267 factor(failures)1 -3.47919176 -2.04922865 factor(failures)2 -3.99008675 -1.23397183 factor(failures)3 -4.56108092 -1.62588162 G1 G2 G3 G1 1.0000000 0.8649816 0.8263871 G2 0.8649816 1.0000000 0.9185480 G3 0.8263871 0.9185480 1.0000000 Call: lm(formula = G3 ~ studytime + failures + absences + higher + school + sex + Medu + G1 + G2, data = d) Residuals: Min 1Q Median 3Q Max -9.0712 -0.4778 -0.0398 0.6375 5.5162 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.17562 0.32343 0.543 0.587324 studytime 0.06104 0.06337 0.963 0.335854 failures -0.20135 0.09244 -2.178 0.029757 * absences 0.01956 0.01109 1.764 0.078220 . higheryes 0.16751 0.17624 0.950 0.342249 schoolMS -0.20490 0.11367 -1.803 0.071913 . sexM -0.19300 0.10433 -1.850 0.064794 . Medu -0.03965 0.04676 -0.848 0.396721 G1 0.12859 0.03662 3.512 0.000477 *** G2 0.88333 0.03396 26.013 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.25 on 639 degrees of freedom Multiple R-squared: 0.8523, Adjusted R-squared: 0.8502 F-statistic: 409.8 on 9 and 639 DF, p-value: < 2.2e-16