Fit a linear regression model

Estimate how a numeric response changes with several predictors and inspect the unexplained variation.

Guides · Basic statistics · 4 min read

Example: electricity use in drying batches

72 independent batches, with electricity use and three numerical explanatory variables.

Download the example data (CSV)

This is the same example used in Help. Import the CSV to follow the steps, or use Open example in a practice copy in Help to prefill the inputs.

1. Create the workspace

In the sidebar, open Basic Statistics and choose Linear Regression. Create an analysis, name it, select New blank worksheet, then choose Create analysis.

2. Import the example data

Download the CSV above and import it into the worksheet. Choose Comma as the delimiter, Dot as the decimal separator and First row contains column names.

3. Assign the input columns

On Inputs, assign electricity_kwh to Response (Y). Open Predictors and select batch_mass_kg, inlet_moisture_pct and ambient_temperature_c in that order. Results label them X1, X2 and X3 respectively.

4. Set the model

Enter 0.95 in Confidence level (0–1). Check Include intercept and Show variance inflation factors (VIF). Leave Standardize predictors unchecked to retain the entered units.

Linear Regression: Inputs with the example’s assignments and settings
Inputs with the example columns and settings before running the analysis. View full-size image (opens in a new tab)

5. Run analysis

Choose Run analysis, then open Results.

6. Interpret results

  1. Identify the fitted response

    The model uses 72 independent batches to describe electricity use from mass, inlet moisture and ambient temperature. R² is about 0.8938. This describes fit to these batches; the recorded relationships do not establish causes.

  2. Read a coefficient in its units

    Holding the other predictors fixed, an extra 10 kg is associated with about 3.42 kWh more use. Moisture adds about 2.65 kWh per percentage point and temperature about −0.753 kWh per °C. All three 95% coefficient intervals exclude zero. The all-zero intercept lies outside the study conditions.

  3. Read the residual plot

    A residual is measured electricity minus fitted electricity, in kWh. Observation 49 is about 11.09 kWh below its fit, the largest absolute residual. Check its records and inspect the whole cloud for curves or changing spread. Do not assume an error from that point alone.

    Residuals vs fitted
    Residuals vs fitted View full-size chart (opens in a new tab)
  4. Check the residual tails

    The QQ plot compares ordered residuals with normal reference positions. Look for systematic curves and unusual tails. The residual Shapiro–Wilk test has p = 0.4018 and does not reject normality at 0.05; neither result proves the error model. This concerns residuals, not the raw electricity values.

    Residual QQ plot
    Residual QQ plot View full-size chart (opens in a new tab)
  5. Check use on new batches

    VIFs of about 1.003–1.045 show little inflation from linear dependence among predictors; they do not establish the right model form. Keep predictions within comparable conditions: observed mass 80.1–217.1 kg, moisture 6.05–13.57% and temperature 15.2–27.9°C. Staying within those separate ranges is not enough if a new combination differs from those studied. Validate predictions on new batches before planning from them.

More details: read each result section

Complete result tables use six significant digits, as in Help.

Linear regression fit

R² describes fitted variation; Adjusted R² accounts for predictor count, and Raw adjusted R² retains the value before the stated display convention. Model F and p-value test the predictors together. Model DF and Residual DF record available information. The remaining fit settings document confidence, intercept and scaling. These are study-fit results, not held-out predictive performance.

Linear regression fit · 18 rows
StatisticValue
R²0.893774
Adjusted R²0.889088
Raw adjusted R²0.889088
Adjusted R² conventionNegative values reported as zero (validation dataset)
Model F190.715
Model p-value4.9105e-33
Model DF3
Residual DF68
AIC438.592
BIC447.699
Observations72
Predictors retained3
Parameters4
Input rows72
Used rows72
Dropped rows0
Fitted rows72
PredictorsX1, X2, X3
  • Model is statistically significant. Significant predictors: X1, X2, X3

Regression coefficients

X1 is batch mass, X2 inlet moisture and X3 ambient temperature. β is the estimated coefficient in response units per predictor unit. SE is coefficient uncertainty; t and p-value test a zero coefficient; CI low and CI high bound its 95% interval. Each slope holds the other predictors fixed. The intercept assumes all predictors are zero.

Regression coefficients · 4 rows
TermβSEtp-valueCI lowCI high
Intercept28.83485.200515.54465.20972e-718.457339.2122
X10.3424740.014785823.16235.58816e-340.3129690.371979
X22.647860.2787079.500514.24797e-142.091713.20401
X3-0.7529580.161902-4.650690.0000157443-1.07603-0.429887

Variance inflation factors

Predictor labels follow the selected order. VIF measures coefficient-variance inflation from linear dependence with other predictors. Values near 1 suggest little inflation; they do not validate linearity, independence or future predictions.

Variance inflation factors · 3 rows
PredictorVIF
X11.04507
X21.04345
X31.00284

Regression ANOVA

Model is variation fitted by the predictors; Residual is unexplained variation. SS is sum of squares, DF degrees of freedom and MS is SS divided by DF. F compares the model and residual mean squares; p-value tests the predictors together. Dashes mark inapplicable entries.

Regression ANOVA · 2 rows
SourceSSDFMSFp-value
Model14032.334677.45190.7154.9105e-33
Residual1667.766824.5259——

Residual summary

Residual is observed minus fitted electricity in kWh. Mean, SD, minimum, quartiles, median and maximum summarize the 72 study residuals. These summaries are not prediction intervals for a new batch.

Residual summary · 7 rows
StatisticValue
mean-3.75009e-14
sd4.8466
min-11.088
q1-3.95264
median0.706102
q33.15057
max10.0148

Residual normality

Test sw means Shapiro–Wilk on model residuals. Statistic and p-value assess a normal working error model. Read them with the QQ plot; p above 0.05 does not prove normal errors.

Residual normality · 3 rows
StatisticValue
Testsw
Statistic0.982202
p-value0.401846

Fitted values and residuals

Index locates an analyzed batch in source order. Fitted is model electricity use in kWh; Residual is measured minus fitted kWh. All 72 rows are included. Positive means use exceeded its fit and negative means it was lower. These fits use the study’s own measurements.

Fitted values and residuals · 72 rows
IndexFittedResidual
176.8375-3.81753
2111.443-2.13264
375.72041.14955
473.46563.88444
5100.348-2.22753
695.3359-7.58587
761.83098.55906
8106.667.07966
974.36820.981848
1099.82787.0722
1197.52722.16277
12104.1940.365946
1394.70321.26677
1485.201-6.62098
1579.8409-8.93085
1680.52063.12941
1784.9566-6.02665
1893.71881.90123
1990.0313-3.88125
2094.0478-1.20783
21114.851-6.16149
2292.2695-4.23952
2396.67626.52381
2466.6088-2.5788
2576.9681-3.57805
2690.04411.4559
2795.21152.02854
28108.5187.58219
2988.29189.85815
3077.9431.38699
31112.115-0.604855
3280.9672-0.84725
3393.56371.61629
3475.94646.92363
3581.21733.64274
3667.877-6.48696
3783.18361.18643
3883.2826-4.13263
3962.57751.63248
4077.0167-1.19671
4174.745210.0148
4262.3518-6.91183
4372.1913-6.30129
44103.0864.32423
4577.0182.35204
46106.022-5.8115
47101.4782.57173
4878.49891.67105
4997.358-11.088
5090.0492-0.529165
51104.944-0.953625
5291.57895.68115
5371.25821.67181
5484.72960.430356
55103.353-3.93251
5670.06783.20216
5799.82214.06795
5878.78684.27315
59102.6887.0117
6096.268-7.12799
6189.28494.64514
6271.7717-1.67166
6377.9742.30597
6485.5329-6.52289
6572.9776-0.0575804
66102.704-4.1637
6774.6012-6.77125
68106.379-4.28947
69103.1973.13337
70116.943-4.01301
7168.0824-1.86244
72102.3215.51867

7. Create a report

Keep Linear regression fit, Regression coefficients, Variance inflation factors, Regression ANOVA, both residual plots, residual summaries and normality test, and every Fitted values and residuals row. Record predictor order and units; describe associations and check future predictive performance separately.

Choose Add to report from the completed run. Open Choose individual items and advanced options to select tables and charts, then choose Add to draft. Hidden items stay in the saved analysis.

Name the report and add the purpose of the study and your interpretation. Choose Save, review Preview, then use Export → Download HTML. The example below contains the full selected content, including results beyond one screen.

Complete native output for this Help example, including applicable tables, charts and run notes. Report numbers use the app’s displayed precision. Exported charts are static. On narrow screens, scroll wide charts and tables sideways.
View example report: Explain electricity use in drying batches

We use Microsoft Clarity to understand how visitors use this website, including session recordings and heatmaps. You can use the website without accepting analytics.

Your choice is saved in this browser for six months. Privacy notice

Current choice: Not chosen.