UK-based online statistics and data analysis support for USA, UK, and international clients. No exams, no impersonation, no fabricated data.
One-predictor OLS, exact grade-point slope and full diagnostic interpretation

Simple Linear Regression: Formula, Slope, R-Squared, Prediction, Python, R, SPSS and Excel

Simple Linear Regression estimates a straight-line relationship between one predictor and one continuous outcome. This complete worked guide predicts final grade G3 from second-period grade G2 for 649 student records, verifies the equation, correlation, ANOVA, confidence and prediction bands, residuals, influence diagnostics and Python, R, SPSS and Excel evidence.

649 complete pairsSlope = 1.0185Pearson r = 0.9185R² = 0.8437

Simple Linear Regression Model Overview

Simple Linear Regression is the ordinary least-squares model used when one continuous predictor is expected to explain or predict one continuous outcome through a straight-line conditional mean. The model answers a focused question: how much does the expected outcome change when the predictor increases by one unit?

In the worked analysis, G3 is the final-grade outcome and G2 is the second-period-grade predictor. The model uses 649 complete records and estimates the equation G3̂ = 0.121966 + 1.018490(G2). The slope is interpreted in original grade points, making the result immediately understandable to a new student.

Simple Linear Regression differs from correlation because the model explicitly names an outcome and supplies a prediction equation. Pearson correlation remains symmetric and unit-free. It differs from Multiple Linear Regression because no additional predictors are controlled. The simple slope therefore summarizes the total sample association between G2 and G3 rather than the conditional effect of G2 after adjustment.

Ordinary least squares chooses the intercept and slope that minimize the sum of squared vertical residuals. The method gives large residuals disproportionate influence because every residual is squared. This fitting rule creates exact algebraic properties: residuals sum to zero, the line passes through the sample means, and the overall F test equals the squared slope t test when only one predictor is included.

A Simple Linear Regression coefficient is interpreted on the outcome scale. The fitted G2 coefficient of 1.018490 means that a one-point increase in G2 is associated with an estimated 1.018490-point increase in expected G3. This is an association under the one-predictor model, not proof that changing G2 would causally change G3 by that amount.

The method supports a continuous outcome and a numeric predictor, or a binary predictor coded numerically when a two-group mean comparison is intended. Its central assumptions remain a meaningful straight-line conditional mean, independent observations, suitable residual variance treatment and no small set of cases dominating the equation. Normal residuals are most important for exact small-sample t and F inference; they are not required merely to calculate the fitted line.

The advantages are transparency, direct hand calculation, clear slope units and a close connection among correlation, R² and ANOVA. The limitations are omitted-variable vulnerability, an unbounded fitted line for a bounded grade outcome, sensitivity to large residuals and the danger of confusing strong prediction with causation.

The worked evidence is unusually strong in the central relationship: Pearson r = 0.918548, R² = 0.843730 and slope t = 59.103989. At the same time, the residual distribution contains a severe negative tail, with skewness −2.941425 and kurtosis 21.789655. The correct conclusion must therefore combine strong average fit with transparent individual-level diagnostic limitations.

Predicted G3 at G2 = 1111.3254
Slope 95% CI0.9847–1.0523
RMSE1.2761
MAE0.8080
Central conclusion: Simple Linear Regression provides a strong, precise and easily interpreted G2-to-G3 equation, but residual tails, individual prediction width, influence and causal limits must remain part of the report.

Quick Answer

The verified Simple Linear Regression evidence supports a strong positive line and a nearly one-for-one grade relationship.

Intercept0.1220
Slope1.0185
Adjusted R²0.8435
Residual SE1.2781

Stable Simple Linear Regression evidence

  • G2 slope = 1.018490.
  • 95% slope CI = [0.984653, 1.052328].
  • F(1,647) = 3493.281566.
  • Python, R, SPSS and Excel reproduce the core equation.

Important diagnostic limits

  • Residual skewness = −2.941425.
  • Residual kurtosis = 21.789655.
  • Maximum |studentized residual| = 7.602273.
  • Maximum Cook’s distance = 0.086831.
Primary equation: G3̂ = 0.121966 + 1.018490(G2)
Decision: use the equation as a transparent benchmark within the observed G2 range, report both fit and error, and do not describe the strong association as a causal effect.

Table of Contents

  1. Model Overview
  2. Quick Answer
  3. Why Simple Linear Regression Is Needed
  4. How Simple Linear Regression Works
  5. Variables and Coding
  6. Verified Results
  7. Python Chart Stories
  8. R Chart Pairs
  9. Coefficient Interpretation
  10. Predictions and Meaning
  11. Assumptions and Diagnostics
  12. Python, R, SPSS and Excel
  13. Code and Formulas
  14. Advanced Topics
  15. APA-Style Reporting
  16. Publication Checklist
  17. Downloads
  18. Related Guides
  19. Frequently Asked Questions
  20. Conclusion

Why This Analysis Needs Simple Linear Regression

The research question contains one continuous predictor, G2, and one continuous outcome, G3. The scatterplot shows a strong positive pattern, and the purpose is to quantify that pattern with one slope, one intercept, explained variance and prediction uncertainty.

A simple model is valuable before richer adjustment because it provides a transparent benchmark. It shows how much predictive information G2 contains by itself and supplies exact values against which Multiple Linear Regression, Polynomial Regression or robust alternatives can be compared.

Quantify directionEstimate whether expected G3 rises or falls with G2.
Measure fitCalculate correlation, R², ANOVA and prediction error.
Audit assumptionsInspect residual shape, intervals and influential observations.

The method does not need additional predictors to answer the unadjusted prediction question. Adding variables would change the estimand from the total sample relationship to a conditional one. That richer question may be useful, but it is not identical to the Simple Linear Regression question answered here.

Not an automatic causal model: a strong G2 slope can reflect prior achievement, shared assessment structure and omitted background variables. The equation predicts; it does not by itself prove intervention effects.

How Simple Linear Regression Works

Least-Squares Objective

Choose b₀ and b₁ to minimize Σ[G3ᵢ − (b₀ + b₁G2ᵢ)]²

The residual for each student is observed G3 minus fitted G3. Squared residuals are summed, and the equation with the smallest total is selected.

Slope and Intercept

b₁ = Σ(G2ᵢ − G2̄)(G3ᵢ − G3̄) ÷ Σ(G2ᵢ − G2̄)²
b₀ = G3̄ − b₁G2̄

The intercept anchors the line through the sample means. The slope converts one predictor point into expected outcome points.

Four-Step Calculation Flow

Step 1Calculate means, centered deviations and sums of squares.
Step 2Estimate slope and intercept.
Step 3Generate fitted values and residuals.
Step 4Evaluate ANOVA, intervals, diagnostics and predictions.

Worked Prediction

At G2 = 11: G3̂ = 0.121966 + 1.018490(11) = 11.325360

If the observed G3 is 11, the residual is −0.325360. The negative sign means the observed outcome is below the fitted average.

Variables Used, Coding and Standardization

The analysis uses the original grade-point units. No automatic standardization is applied to the primary equation, so the slope remains directly interpretable.

RoleVariableDefinitionCoding or unitSimple Linear Regression use
OutcomeG3Final gradeContinuous grade; observed range 0–19Predicted conditional mean
PredictorG2Second-period gradeContinuous grade; observed range 0–19One-point slope interpretation
Model outputFitted G3Predicted average final gradeContinuous0.121966 + 1.018490×G2
Diagnostic outputResidualObserved G3 minus fitted G3Continuous errorPositive above line; negative below line
UncertaintyMean confidence bandAverage G3 at one G2 value95% intervalNarrower near mean G2
UncertaintyPrediction intervalOne future G3 at one G2 value95% intervalIncludes residual outcome variation

The same 649 complete rows and intercept convention are used in every software implementation. Changing missing-data handling or removing the intercept would change the equation and invalidate a direct comparison.

Analysis sample: 649 complete G2–G3 records are retained. Simple Linear Regression changes no recorded grade values.

Verified Simple Linear Regression Results

Model Performance

MetricExact valueInterpretation
Observations649All complete G2–G3 pairs
Pearson correlation0.918548Strong positive linear association
0.84373084.373% of fitted-sample G3 variance explained
Adjusted R²0.843489Nearly identical because one predictor is used
RMSE1.276125Squared-error prediction summary in G3 points
MAE0.808023Average absolute fitted error
Residual standard error1.278096Conditional noise estimate using 647 df
AIC2144.9520Information criterion for this fitted Gaussian model
BIC2158.3823Information criterion with stronger complexity penalty

The difference between RMSE and residual standard error is expected because the denominators differ. The residual standard error uses 647 residual degrees of freedom, whereas the reported RMSE uses the number of observations.

Regression ANOVA

SourceSum of squaresdfMean squareFp-value
Regression5706.37383915706.3738393493.2815665.6424 × 10−263
Residual1056.8927256471.633528
Total6763.266564648

The overall F statistic tests whether the one-predictor model improves on an intercept-only mean model. Because only one slope is tested, F equals the squared slope t statistic.

Coefficient Estimates

TermBSEtp95% CISimple Linear Regression reading
Intercept0.1219660.2055930.593240.553228[−0.281745, 0.525677]Baseline at G2 = 0 is imprecise
G21.0184900.01723259.1039895.6424 × 10−263[0.984653, 1.052328]Strong positive grade-point slope

G2 provides the substantive result. Its interval is narrow, positive and centered near one. The intercept is retained because the fitted model requires a baseline and because removing it would change the slope, R² and residual structure.

Python Charts and Exact-Value Explanations

The five verified Python assets are explained with the attached format’s pattern, key values, interpretation and practical reason each figure matters.

Python Chart 1: G2–G3 Scatterplot and Fitted Line

Simple Linear Regression scatterplot of G2 predicting G3 with fitted line
Verified Python output for the worked Simple Linear Regression analysis: scatterplot and fitted line.
Pattern

The points form a dense upward diagonal band. A smaller group of zero final grades lies far below the main pattern even when G2 is in the ordinary range.

Key Values

The fitted equation is G3̂ = 0.121966 + 1.018490(G2). Pearson r = 0.918548 and R² = 0.843730.

Interpretation

Expected G3 increases almost one point for each additional G2 point. The zero-grade cases do not erase the central positive relationship, but they create the largest negative residuals.

Why It Matters

The chart establishes the mean structure and reveals why Outlier Detection and residual review remain necessary.

Reading rule: interpret each figure as one part of the Simple Linear Regression evidence rather than as a standalone decision.

Python Chart 2: Mean Confidence Band around the Fitted Line

Simple Linear Regression fitted mean with 95 percent confidence band
Verified Python output for the worked Simple Linear Regression analysis: mean confidence band.
Pattern

The band is narrowest around mean G2 and widens toward the predictor edges. The fitted line remains the center of the band at every G2 value.

Key Values

At G2 = 11, predicted G3 is 11.325360 and the 95% mean-response interval is approximately [11.224974, 11.425746].

Interpretation

The band estimates the population mean G3 for a given G2. It does not describe the likely range for one individual student.

Why It Matters

The distinction is essential when reporting a Confidence Interval rather than a prediction interval.

Reading rule: interpret each figure as one part of the Simple Linear Regression evidence rather than as a standalone decision.

Python Chart 3: Residuals versus Predicted Values

Simple Linear Regression residuals versus fitted values
Verified Python output for the worked Simple Linear Regression analysis: residuals versus fitted values.
Pattern

Residual bands arise because G3 is recorded in integer grade points. Several observations extend sharply downward from the main cloud.

Key Values

RMSE = 1.276125, MAE = 0.808023 and residual standard error = 1.278096.

Interpretation

Most errors are modest, but a small number of extreme negative errors dominate tail diagnostics. Strong overall fit therefore coexists with important individual misses.

Reading rule: interpret each figure as one part of the Simple Linear Regression evidence rather than as a standalone decision.

Python Chart 4: Residual Normal Q-Q Plot

Simple Linear Regression residual normal Q-Q plot
Verified Python output for the worked Simple Linear Regression analysis: residual Q-Q plot.
Pattern

The central residuals are much closer to the reference line than the lower tail. The most negative errors bend dramatically away from normal-theory expectations.

Key Values

Shapiro–Wilk W = 0.710847, p = 6.0596 × 10⁻³², skewness = −2.941425 and kurtosis = 21.789655.

Interpretation

Exact normal-error assumptions are not supported. The large sample helps slope estimation, but conventional prediction and tail inference still deserve sensitivity analysis.

Reading rule: interpret each figure as one part of the Simple Linear Regression evidence rather than as a standalone decision.

Python Chart 5: Observed versus Predicted G3

Simple Linear Regression observed versus predicted G3 values
Verified Python output for the worked Simple Linear Regression analysis: observed versus predicted values.
Pattern

Most points follow the diagonal in the central grade range. Horizontal bands reflect integer observed grades, while several zero outcomes fall far below the diagonal.

Key Values

R² = 0.843730, adjusted R² = 0.843489 and F(1,647) = 3493.281566.

Interpretation

The model reproduces overall grade ordering very well, but individual prediction is weaker for the extreme low-outcome cases.

Why It Matters

Report Adjusted R-Squared with error metrics rather than describing R² as the percentage of students predicted correctly.

Reading rule: interpret each figure as one part of the Simple Linear Regression evidence rather than as a standalone decision.

R Charts and Paired Explanations

The R evidence independently cross-checks the Simple Linear Regression calculations. Four unique R assets are arranged in two matched pairs with a dedicated explanation beneath each chart.

R Simple Linear Regression chart pair 1
R Simple Linear Regression confidence and prediction bands
R cross-check for Simple Linear Regression: confidence and prediction bands.
R Simple Linear Regression residual histogram
R cross-check for Simple Linear Regression: residual histogram.
Explanation for R chart 1

R Chart 1: Mean Confidence and Individual Prediction Bands

Pattern: The narrow band estimates the average response and the wider band estimates one future outcome. Both are centered on the same fitted line.

Key values: At G2 = 11, the mean interval is approximately [11.2250, 11.4257], while the individual prediction interval is approximately [8.8136, 13.8371].

Interpretation: Individual prediction uncertainty is much larger because residual variation is added to line-estimation uncertainty.

Why it matters: The correct interval depends on whether the research question concerns an average or one student.
Explanation for R chart 2

R Chart 2: Residual Distribution

Pattern: The central residual mass is concentrated near zero, but the lower tail is much longer than the upper tail.

Key values: Residual skewness is −2.9414, kurtosis is 21.7897 and the Shapiro–Wilk p-value is 6.06 × 10⁻³².

Interpretation: The histogram confirms that a few extremely negative errors drive the non-normal tail rather than a broad failure of the central fitted relationship.

Why it matters: Report the tail problem and consider robust or bootstrap sensitivity without deleting valid outcomes automatically.
R Simple Linear Regression chart pair 2
R Simple Linear Regression influence plot
R cross-check for Simple Linear Regression: influence plot.
R Simple Linear Regression scatterplot and fitted line
R cross-check for Simple Linear Regression: independent fitted-line reproduction.
Explanation for R chart 1

R Chart 3: Leverage, Studentized Residuals and Cook’s Distance

Pattern: Most observations have low leverage and modest residuals. A smaller group combines large vertical errors with enough leverage to affect the fitted line.

Key values: Maximum |studentized residual| = 7.602273, maximum leverage = 0.025876 and maximum Cook’s distance = 0.086831.

Interpretation: Influence is not the same as being unusual on G3 alone. It reflects residual size, predictor position and their effect on the estimated equation.

Why it matters: These records require source verification and transparent sensitivity analysis, not automatic removal.
Explanation for R chart 2

R Chart 4: Independent Fitted-Line Verification

Pattern: The R plot reproduces the same positive line and the same difficult zero-grade observations visible in Python.

Key values: R and Python agree on intercept 0.121966, slope 1.018490, Pearson r 0.918548 and R² 0.843730.

Interpretation: Cross-software agreement confirms the core calculation when rows, formula and intercept convention are identical.

Why it matters: Use numerical agreement to validate implementation, while keeping diagnostic limitations unchanged.

Simple Linear Regression Coefficient and Parameter Interpretation

Primary Equation

G3̂ = 0.121966 + 1.018490(G2)

The G2 coefficient is the expected G3 difference associated with a one-point G2 difference. Holding nothing else constant because no other predictor is included, a student one point higher on G2 has approximately 1.0185 points higher fitted G3.

The slope confidence interval [0.984653, 1.052328] indicates that every plausible value under the classical model is positive and close to one grade point. Statistical precision is high because the sample is large, G2 varies substantially and the G2–G3 association is strong.

The intercept of 0.121966 is the fitted G3 at G2 = 0. Its p-value is .553228. The intercept is not the main research target, and its nonsignificance does not justify a no-intercept model.

Pearson r = 0.918548 and R² = 0.843730 describe association strength and explained sample variation. Neither statistic measures causal effect, individual prediction certainty or the proportion of students predicted exactly.

Coefficient rule: report the slope in grade-point units, its interval and the one-predictor nature of the estimand. Do not silently convert the result into an adjusted or causal effect.

Predictions, Effects and Model Meaning

A Simple Linear Regression prediction is obtained by substituting a G2 value into the fitted equation. At G2 = 11, the fitted mean G3 is 11.325360.

Mean-response 95% interval at G2 = 11: approximately [11.224974, 11.425746]
Individual 95% prediction interval at G2 = 11: approximately [8.813637, 13.837083]

The mean-response interval is narrow because it estimates the average outcome for a predictor value. The individual interval is much wider because it includes person-to-person residual variation around that average.

The prediction is not automatically constrained to the grade scale. The fitted equation should therefore be used within the observed G2 range and interpreted cautiously near boundaries.

Prediction caution: the supplied performance values are in-sample. Future-cohort prediction requires cross-validation or an external test sample.

Simple Linear Regression Assumptions and Diagnostics

Mean structure

The expected G3 relationship should be reasonably straight across G2.

Sampling structure

Students should be independent at the modeled sampling level.

Influence structure

No few observations should determine the slope and intercept.

Linearity

The scatterplot shows a strong straight-line pattern, but residual plots should still be inspected for curvature. Use Ramsey RESET Test and compare with Polynomial Regression if a systematic bend remains.

Residual Variance

Use Breusch-Pagan Test and White Test. Heteroskedasticity changes classical uncertainty even when the OLS point estimates remain unchanged.

Residual Shape

The residual distribution is strongly negatively skewed and heavy-tailed. Use Q-Q Plot Normality Check, Shapiro-Wilk Test and Skewness and Kurtosis.

High Leverage and Influence

Review leverage, Studentized Residuals and Cook’s Distance. The maximum |studentized residual| is 7.602273 and maximum Cook’s distance is 0.086831.

Independence

Durbin–Watson is 1.846403, which does not indicate strong first-order autocorrelation under the row order. Independence still depends mainly on the study design.

Diagnostic boundary: never remove a record solely because it has a large residual or influence statistic. Verify the source, document the reason and report original and sensitivity results.

Simple Linear Regression in Python, R, SPSS and Excel

Python

Python fits the one-predictor OLS equation, exports ANOVA, coefficients, confidence and prediction intervals, and produces the five verified chart stories.

  • statsmodels OLS with an intercept
  • Coefficient confidence interval
  • Row-level prediction summary
  • Influence measures and residual diagnostics

R

R uses lm(G3 ~ G2) to independently reproduce the same equation and diagnostic evidence.

  • summary() and anova()
  • confint() for slope bounds
  • predict() for mean and individual intervals
  • Four unique paired R charts

SPSS

SPSS places G3 in the Dependent box and G2 in the Independent box, then reports Model Summary, ANOVA and Coefficients tables.

  • 95% coefficient confidence intervals
  • Predicted and residual variables
  • Studentized residual, leverage and Cook’s distance
  • Archived SPV and PDF output

Excel

The worked workbook exposes the complete calculation rather than hiding the equation behind a command.

  • Sxx, Sxy, slope and intercept
  • Observed, fitted and residual columns
  • ANOVA sums of squares
  • Mean confidence and individual prediction formulas
Cross-software rule: agreement is expected only when the sample, missing-data treatment, intercept, formula and interval definitions are aligned. Differences should be traced rather than averaged.

Code and Formula Panels

Python: OLS, intervals and influence
import pandas as pd
import statsmodels.api as sm

df = pd.read_csv("dataset.csv")[["G2", "G3"]].dropna()
X = sm.add_constant(df[["G2"]])
y = df["G3"]

fit = sm.OLS(y, X).fit()
print(fit.summary())
print(fit.conf_int(alpha=0.05))

prediction = fit.get_prediction(X).summary_frame(alpha=0.05)
influence = fit.get_influence().summary_frame()
R: lm, confidence band and prediction band
dat <- read.csv("dataset.csv")
dat <- na.omit(dat[c("G2", "G3")])

fit <- lm(G3 ~ G2, data = dat)
summary(fit)
anova(fit)
confint(fit, level = 0.95)

mean_band <- predict(fit, interval = "confidence", level = 0.95)
pred_band <- predict(fit, interval = "prediction", level = 0.95)
influence.measures(fit)
Excel: slope, intercept and prediction formulas
Slope:
=SXY/SXX

Intercept:
=Mean_G3-Slope*Mean_G2

Predicted G3:
=Intercept+Slope*G2

Residual:
=Observed_G3-Predicted_G3

Mean SE:
=Residual_SE*SQRT(1/N+(G2-Mean_G2)^2/SXX)

Prediction SE:
=Residual_SE*SQRT(1+1/N+(G2-Mean_G2)^2/SXX)
SPSS: one-predictor regression and saved diagnostics
REGRESSION
 /MISSING LISTWISE
 /STATISTICS COEFF OUTS R ANOVA CI(95)
 /DEPENDENT G3
 /METHOD=ENTER G2
 /SAVE PRED(Predicted_G3) RESID(Residual_G3)
       ZPRED(ZPred_G3) ZRESID(ZResid_G3)
       SRESID(Studentized_Residual) COOK(Cooks_Distance) LEVER(Leverage).

OUTPUT SAVE
 /OUTFILE='D:\DATA ANALYSIS\H Regression Tests and Models\Simple Linear Regression\SPSS_Output\spv\Simple-Linear-Regression.spv'.

OUTPUT EXPORT
 /CONTENTS EXPORT=ALL LAYERS=PRINTSETTING MODELVIEWS=PRINTSETTING
 /PDF DOCUMENTFILE='D:\DATA ANALYSIS\H Regression Tests and Models\Simple Linear Regression\SPSS_Output\pdf\Simple-Linear-Regression-SPSS-Output.pdf'.

Advanced Simple Linear Regression Topics

The advanced section follows the attached two-column expandable grid so technical detail remains available without overwhelming the beginner reading path.

1. Simple Linear Regression Estimand and Research Question
  • The estimand is the population mean difference in G3 associated with one unit of G2 under a straight-line conditional mean.
  • The fitted slope is an associational parameter unless the design justifies causation.
  • The one-predictor estimand differs from the conditional G2 slope in a multiple-predictor model.
2. Ordinary Least-Squares Geometry
  • The fitted line minimizes the sum of squared vertical residuals.
  • The normal equations force residuals to sum to zero and be orthogonal to G2.
  • The line passes through mean G2 and mean G3 when an intercept is included.
3. Why R-Squared Equals Pearson r Squared
  • With one predictor and an intercept, fitted values are a linear transformation of G2.
  • The explained proportion therefore equals the squared sample correlation.
  • The identity is exact apart from rounding and does not generalize to individual multiple-regression slopes.
4. Why the Overall F Statistic Equals the Slope t Statistic Squared
  • The model has exactly one non-intercept coefficient.
  • The F test and two-sided t test evaluate the same null hypothesis that the slope equals zero.
  • 59.103989 squared equals approximately 3493.281566.
5. Slope Units and Practical Interpretation
  • The slope is measured in final-grade points per second-period-grade point.
  • A one-point G2 difference corresponds to approximately 1.0185 points in expected G3.
  • The original units make the effect easy to communicate without standardization.
6. Intercept Interpretation
  • The intercept estimates expected G3 when G2 equals zero.
  • Its confidence interval crosses zero and its p-value is .5532.
  • A nonsignificant intercept is not a valid reason to force the line through the origin.
7. Centering G2
  • Subtracting mean G2 makes the intercept equal predicted G3 at average G2.
  • Centering does not change slope, fitted values, residuals, R² or tests of slope.
  • It can make the baseline interpretation more useful.
8. Standardized Simple Linear Regression
  • Standardizing both G2 and G3 produces a slope equal to Pearson r.
  • The standardized slope is 0.918548.
  • Use the unstandardized slope for grade-point interpretation and the standardized slope for scale-free comparison.
9. Regression ANOVA Decomposition
  • Total sum of squares equals regression plus residual sum of squares.
  • 5706.373839 + 1056.892725 equals 6763.266564.
  • The F ratio compares regression mean square with residual mean square.
10. RMSE, MAE and Residual Standard Error
  • RMSE uses n in the denominator, while residual standard error uses n − 2.
  • That difference explains 1.276125 versus 1.278096.
  • MAE of 0.808023 is less sensitive to extreme errors than RMSE.
11. Mean Confidence Band
  • The band estimates the average G3 at a chosen G2.
  • It is narrowest near mean G2 and widens at predictor edges.
  • It should not be used to forecast one student.
12. Individual Prediction Interval
  • The interval adds residual variance to uncertainty about the fitted mean.
  • It is much wider than the mean confidence band.
  • It is the correct interval for one future G3 at a specified G2.
13. Discrete Grade Bands in Diagnostic Plots
  • Observed grades are integers while fitted values are continuous.
  • Residual and observed-versus-predicted plots therefore form visible diagonal or horizontal bands.
  • The banding is expected and should not be mistaken for a software error.
14. Bounded Outcome Scale
  • Observed G3 lies between 0 and 19 in the complete data.
  • The fitted linear equation is mathematically unbounded.
  • Predictions outside the observed G2 range can become implausible or impossible.
15. Residual Normality
  • The Q-Q plot and Shapiro-Wilk Test show a severe negative tail.
  • Large-sample slope estimates can remain informative, but exact Gaussian prediction assumptions are questionable.
  • Valid zero outcomes should not be deleted merely to improve normality.
16. Heteroskedasticity
  • Use Breusch-Pagan Test and White Test.
  • Changing residual variance can make classical standard errors and intervals unreliable.
  • Robust standard errors alter uncertainty but do not alter the OLS fitted line.
17. Linearity and Omitted Curvature
18. Studentized Residuals
  • Studentization scales residuals by their estimated case-specific standard deviation.
  • The maximum absolute studentized residual is 7.602273.
  • Such a value warrants verification and sensitivity analysis.
19. Leverage
  • Leverage measures how unusual a G2 value is relative to the sample distribution.
  • The maximum leverage is 0.025876.
  • High leverage becomes especially consequential when paired with a large residual.
20. Cook’s Distance
  • Cook’s distance summarizes how much the fitted equation changes when one case is removed.
  • The maximum value is 0.086831.
  • Thresholds are screening guides rather than automatic deletion rules.
21. Association versus Causation
  • G2 precedes G3 but timing alone does not establish causality.
  • Omitted variables and shared grading mechanisms can contribute to the strong relationship.
  • Use predictive or associational wording unless design assumptions support a causal claim.
22. Adding Covariates
  • Multiple Linear Regression can adjust for G1, failures, studytime and other variables.
  • The conditional G2 slope may differ from the simple slope.
  • The simple model remains a transparent benchmark for comparison.
23. External Validation
  • R² and error metrics are calculated on the fitted 649 cases.
  • Performance on another school, year or cohort may be lower.
  • Use cross-validation or an external test sample for future prediction claims.
24. Bootstrap Sensitivity
  • Bootstrap resampling can estimate slope and prediction uncertainty with fewer distributional assumptions.
  • The entire fitting process must be repeated in each resample.
  • Report the resampling unit, number of resamples and interval method.
25. Robust Regression Sensitivity
  • A robust estimator can reduce the coefficient influence of extreme residuals.
  • It targets a different estimating equation than ordinary least squares.
  • Compare slope stability and interpretation rather than expecting identical fit metrics.
26. Reproducibility across Python, R, SPSS and Excel
  • The core equation should match when the same rows and intercept convention are used.
  • AIC or BIC can differ slightly because of software likelihood conventions.
  • Fitted values, slope, intercept, R² and ANOVA provide the strongest cross-software checks.

APA-Style Reporting

Model report: A Simple Linear Regression was conducted to examine whether second-period grade G2 predicted final grade G3 among 649 students. The model was significant, F(1, 647) = 3493.28, p < .001, and explained 84.37% of G3 variance, R² = .844, adjusted R² = .843.

Coefficient report: G2 was strongly positively associated with G3, B = 1.018, SE = 0.017, t(647) = 59.10, p < .001, 95% CI [0.985, 1.052]. The fitted equation was G3̂ = 0.122 + 1.018(G2).

Diagnostic report: residual standard error was 1.278 grade points. Residuals showed substantial negative skew and heavy tails, and influence screening identified several cases requiring review. The result should therefore be described as a strong sample association with transparent diagnostic limitations.

Reporting boundary: do not state that G2 causes G3, and do not describe fitted-sample R² as validated future performance.

Publication Checklist

  • Name G3 as the outcome and G2 as the predictor.
  • Report n = 649 and the observed grade ranges.
  • Write the complete fitted equation.
  • Report slope, SE, t, p and 95% confidence interval.
  • Retain and interpret the intercept appropriately.
  • Report Pearson r, R² and adjusted R².
  • Include RMSE, MAE and residual standard error.
  • Separate mean confidence bands from prediction intervals.
  • Discuss residual normality, variance and influence.
  • State that the result is associational.
  • Avoid unsupported extrapolation beyond observed G2.
  • Verify Python, R, SPSS and Excel agreement.

Downloads and Verification Resources

Frequently Asked Questions

What is Simple Linear Regression?

Simple Linear Regression predicts one continuous outcome from one predictor using one intercept and one slope.

What are the variables in this example?

G3 is the final-grade outcome and G2 is the second-period-grade predictor.

How many observations are analyzed?

The fitted model uses 649 complete G2–G3 pairs.

What is the fitted equation?

The equation is G3̂ = 0.121966 + 1.018490(G2).

What does the slope mean?

A one-point higher G2 is associated with approximately 1.0185 higher expected G3 points.

Is the slope statistically significant?

Yes. t(647) = 59.104, p < .001, with 95% CI [0.984653, 1.052328].

Is the intercept statistically significant?

No. The intercept p-value is .5532 and its interval includes zero.

What is Pearson r?

Pearson r is 0.918548, indicating a strong positive linear association.

What is R-squared?

R² is 0.843730, meaning the fitted line explains 84.373% of sample G3 variation.

Why does R-squared equal r squared?

That identity holds for ordinary least squares with one predictor and an intercept.

What is the prediction when G2 equals 11?

The fitted mean is approximately 11.325360.

What is the difference between a confidence band and prediction interval?

The confidence band targets the average G3, while the prediction interval targets one future individual G3.

Are the residuals normally distributed?

No. The residuals have a severe negative tail and formal normality tests reject the normal model.

Should the zero final grades be deleted?

No. They should be verified and examined through transparent sensitivity analysis rather than removed automatically.

Does the model prove that G2 causes G3?

No. The model estimates a strong association and prediction relationship, not causation.

Can the results be reproduced in Python, R, SPSS and Excel?

Yes. The same rows, intercept convention and formulas reproduce the core equation and fit statistics.

Simple Linear Regression Conclusion

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression results are most trustworthy when numerical agreement and diagnostic evidence support the same conclusion.

Simple Linear Regression predictions should stay within the observed predictor range unless extrapolation is scientifically justified.

Simple Linear Regression remains a benchmark model even when later analyses add covariates or use robust estimators.

Simple Linear Regression interpretation should connect the slope, fitted line, explained variance, residual error and prediction limits.

Simple Linear Regression finds a strong positive relationship between G2 and G3. The fitted slope is 1.018490, the 95% interval is [0.984653, 1.052328], Pearson r is 0.918548 and R² is 0.843730.

The equation is transparent and useful within the observed grade range. It predicts an average G3 of 11.325360 when G2 equals 11. However, individual prediction remains wider than mean-response uncertainty, and a small group of extreme low outcomes creates substantial residual non-normality and influence.

The verified Python, R, SPSS and Excel evidence supports the same core result. Correct use requires a justified straight-line mean, residual and influence diagnostics, careful interval interpretation, validation for future prediction and honest reporting that the relationship is associative rather than causal.

Back to top

Need help applying this to your own data?

Salar Cafe can help interpret output, clean datasets, review assumptions, build dashboards and explain statistical results ethically.

Need help interpreting your data analysis results?

Contact Salar Cafe
Engr. Muhammad Yar Saqib author profile photo

Engr. Muhammad Yar Saqib

Engr. Muhammad Yar Saqib is an electrical engineer educated at the University of Bradford, United Kingdom, a writer and poet, and an Assistant Education Officer in the School Education Department, Punjab, serving since July 2017. He writes practical guides on statistics, SPSS, data analysis, mathematics and educational technology, with an emphasis on transparent methods, reproducible calculations and ethical learning support.