Opens in a new tab

Simple Linear Regression in Stata
Reading the Three Blocks of regress

Simple linear regression in Stata prints its result in three parts: an ANOVA block, a fit block with R-squared and Root MSE, and a coefficient table. Each part answers a different question, and the residual checks come from separate commands.

What You'll Need
A continuous outcome variable
One predictor with a known unit
A do-file for the commands

IN SHORT

What regress Estimates and What It Leaves to You

Simple linear regression estimates how the average of a continuous outcome differs with one predictor, as a straight-line slope with its standard error and interval, and how much of the outcome’s variation the line accounts for. To run simple linear regression in Stata, type regress followed by the outcome and the predictor. The output has an ANOVA table, a block with the number of observations, F, R-squared and Root MSE, and a coefficient table. The beta option adds standardized slopes, and the residual plots come from rvfplot and predict. OnlineSPSS, a specialist statistical consultancy for academic, clinical and professional research, carries out and reviews this analysis through an in-house PhD-level statistician.

In This Guide

1
Plot the Raw Relationship
2
Fit the Model With regress
3
Read the Three Blocks in Order
4
Request Standardized Slopes
5
Plot Residuals Against Fitted Values
6
Store Residuals and View Their Shape

ANALYSIS SUPPORT

Analysis Support for This Method

One predictor is rarely the whole story. When other variables plausibly shape both the predictor and the outcome, the slope from a one-predictor model can mislead, and a model with further terms answers the question better.

Simple Linear Regression

A straight-line relationship estimated with its interval, from the shape of the data to the residual checks and the sentence that describes the slope.

Explore Simple Linear Regression
Multiple Linear Regression

Several predictors fitted together, so that each slope describes the outcome after the others are held at fixed values, with the choice of terms made from the research question.

Explore Multiple Linear Regression

BEFORE YOU RUN IT

What Sits Behind the Fitted Line

The output carries no warning about any of the following, so the shape of the data, the units and the independence of rows are looked at before regress is typed.

A Scatter Before the Model A scatter plot with the fitted line shows curvature, clusters and extreme points that summary numbers hide. A straight line is a modeling choice, and the command does not check it.

A Unit Attached to Each Variable The slope is in units of the outcome per unit of the predictor, so both units are recorded. Rescaling the predictor, for example per 10 units, often gives a clearer slope.

Independent Rows Each row should be a separate observation. Repeated measures, siblings in one family or pupils in one class break the independence on which the standard errors rely.

The Range of the Predictor The intercept is the average outcome at a predictor value of zero, which may fall outside the data. In that case, centering the predictor gives an intercept that describes a real case.

IN STATA

How to Run Simple Linear Regression in Stata

The regress command in Stata, rvfplot and predict are built into Stata, so nothing needs installing, and a model fitted from the menus prints the same output together with the command it ran.

1

Plot the Raw Relationship

Draw a scatter plot of the outcome against the predictor with the fitted line overlaid, and look for curvature, clusters and extreme points.

Watch: A point far out on the predictor can pull the line toward itself. If one point drives the slope, report the fit with and without it and state why it is kept.

2

Fit the Model With regress

Fit the model with regress, outcome first and predictor second, and note the number of observations used.

Check: Number of obs counts only rows with both variables observed. Compare it with the number of rows in the file before interpreting anything else in the output.

3

Read the Three Blocks in Order

Read the ANOVA table, the fit block with R-squared and Root MSE, and the coefficient table in that order, each for its own question.

Tip: With a single predictor, F equals the square of the slope’s t statistic and the two p-values are identical. The F test adds no second piece of evidence here.

4

Request Standardized Slopes

Run regress again with the beta option when a standardized slope is wanted. It puts a Beta column where the interval columns were.

Tip: With one predictor, the standardized slope equals the Pearson correlation of the two variables. The slope in original units, with its interval, remains the main estimate.

5

Plot Residuals Against Fitted Values

After regress, rvfplot draws the residuals against the fitted values; a funnel shape or a curve points to unequal spread or the wrong functional form.

Watch: Look for a pattern, not only for a flat cloud. A curve says the line is the wrong shape for these data, and no single p-value stands in for that look.

6

Store Residuals and View Their Shape

Store the residuals with predict and the residuals option, then view them in a normal quantile plot or a histogram.

Check: Residual shape matters most for intervals in small samples. With many observations, strong departures and influential points deserve more attention than mild skew.

Stata Commands
twoway scatter y x || lfit y x
regress y x
regress y x, beta
rvfplot, yline(0)
predict res, residuals
qnorm res

READING THE OUTPUT

Reading the regress Blocks Top to Bottom

The ANOVA table sits on the left, the fit statistics on the right and the coefficients below, and each carries one number that is commonly misread.

Output element What it tells you What to check
Source, SS, df and MS: Model, Residual, Total How the outcome’s variation splits into the part explained by the line and the rest That Model df is 1 and Residual df is the observations minus 2
Number of obs The rows used after rows with a missing value are left out That it matches the intended sample
F(1, n-2) and Prob > F The test of the model against a model with no predictor That it is not reported as a second finding beside the slope’s t test
R-squared and Adj R-squared The share of the outcome’s variation accounted for by the line That it is read as fit, and not as proof that the line is the right shape
Root MSE The typical size of a residual, in the unit of the outcome That it is compared with the outcome’s standard deviation
Coefficient on the predictor, with Std. err., t and P>|t| The estimated change in the average outcome per one-unit difference in the predictor That the unit and the sign are put into words
_cons The predicted average outcome when the predictor is zero That zero lies inside the observed range
[95% conf. interval] ([95% Conf. Interval] in older releases), or Beta after the beta option The range of slopes compatible with the data, or the standardized slope That the column on screen is the one being quoted

REPORTING

Reporting the Slope, Its Interval and the Fit

A regression sentence is assembled from all three blocks, with the units kept and the wording of an association unless the design supports more.

Give the slope as b = ___ with its 95% CI [___, ___], in units of the outcome per unit of the predictor, then t(df) = ___ and p = ___ with df as printed in the Residual row. Add R-squared = ___ and Root MSE = ___ in the unit of the outcome, and the number of observations used. Describe the slope as a difference in the average outcome between cases that differ by one unit on the predictor, which is an association unless the design supports a causal reading. Mention the residual plots viewed and any influential point that was handled, and state whether the standard errors are the default ones or came from vce(robust).

Slope With CIUnits StatedR-Squared, Root MSEn Observations UsedAssociation Wording

COMMON MISTAKES

Slope Reports That Lose Units or Imply Causes

None of the six triggers an error message, so all of them reach print unless the plots and the three blocks are reread beside the draft.

R-Squared as a Verdict A high R-squared does not show that the line has the right shape or that the slope is causal, and a low one does not make the slope meaningless. It describes fit only.

Standardized Slope as the Headline The Beta column drops the units and depends on the sample's spread, so it travels poorly between studies. The slope in original units, with its interval, is reported first.

Intercept Read Outside the Data A predictor that never reaches zero gives an intercept for a case that does not exist. Predictions are quoted only within the observed range of the predictor.

Residual Plot Skipped regress does not draw residual plots by itself, so a curve or a funnel goes unseen and the interval is read as if the model's assumptions held. rvfplot takes one line after the fit.

Causal Verbs for an Observed Slope A phrase such as x increases y describes an intervention that the data do not contain. Association wording fits a slope estimated from observed differences.

Silent Row Loss A row missing either variable drops out of the fit without a message, so the sample behind the slope can be smaller than the file. Number of obs is quoted and the loss described.

Residual plots missing from a finished regress run? Quantitative Data Analysis fits and checks a regression in Stata, with the slope’s interval and the residual checks reported.

Request an Assessment

What's Next

Association strength without a fitted line is covered under Correlation Analysis (Pearson & Spearman).
A binary outcome in place of a continuous one is modeled with Logistic Regression.
Pupils in classes or patients in clinics call for Linear Mixed Models (Multilevel Modeling).

FREQUENTLY ASKED QUESTIONS

Questions About regress and Its Residual Checks

A one-predictor model prints two tests that coincide and a Root MSE that is often overlooked, while its residual plots are requested separately after the fit.

With a single predictor, F is the square of the slope’s t statistic, so the two tests are one test and give the same p-value. The F line becomes informative with several predictors, where it tests them jointly. In a simple model the slope’s t statistic and its interval carry the evidence.

rvfplot in Stata draws the residuals against the fitted values after regress, and rvpplot draws them against a predictor you name. For other plots, store the residuals with predict and the residuals option and use them in a histogram or a normal quantile plot. These commands read the last model fitted, so they are run straight after regress.

Root MSE is the typical distance between the observed outcomes and the fitted line, expressed in the unit of the outcome. R-squared is a proportion and depends on how widely the predictor is spread in the sample. Root MSE shows whether the remaining error is small or large in practical terms.

Yes, because the three output blocks cannot show curvature or unequal spread. An in-house PhD-level statistician at OnlineSPSS reads the specification against your data, then the blocks, the plots and the sentence that reports them. The meaning of the slope for your field is your judgment. Results-section tables and text, if wanted, belong to a different service: Results Reporting & Interpretation.

Your data and project details are handled confidentially, and project information is not published. Researcher names and institutions are not used publicly without permission. An NDA is available where required and can be arranged before sensitive materials are shared. Read more about confidentiality and data security.

You share your research question, design and relevant materials, such as the dataset or the output you have, and a statistically trained Research Coordinator reviews the request and responds the same day. The analysis, deliverables, timeline and one fixed project fee are then confirmed before any work begins, so the timeline follows from the agreed scope.

Still have a question? Find more answers in our full FAQ.

View All FAQs →

NEXT STEP

Is Your Slope Reported
in the Units of the Data?

R-squared alone never settles a one-predictor model. Whether a straight line was the right summary is seen in the scatter and the residual plots, which belong in the report beside the slope and its units.

No Commitment Required

Strictly Confidential

Fixed Project Fee

In-House PhD-Level Statisticians

Same-Day Response

Serving Researchers Since 2014