Multiple Regression in Stata
Factor Variables, VIF and Robust Errors
Multiple regression in Stata lets factor-variable prefixes build the indicators, while the checks after regress are separate commands. Collinearity, unequal spread and joint hypotheses each have their own follow-up, and one of them changes the standard errors.
IN SHORT
What regress Fits and Which Commands Check It
A multiple regression estimates how a continuous outcome differs across several predictors at once, each coefficient describing the expected difference in the outcome with the other predictors held constant in the model. To run multiple regression in Stata, type regress followed by the outcome and the predictors, marking categorical ones with i. and continuous ones with c. so that no indicator variables are made by hand. The checks are separate commands that follow the fit: estat vif for collinearity, estat hettest for unequal spread and testparm or test for joint hypotheses. 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
ANALYSIS SUPPORT
Analysis Support for This Method
Predictors often enter in planned blocks, and the gain in explained variance from one block to the next is a question of its own. A single list of predictors does not answer it.
Multiple Linear Regression
Coefficients with intervals, the checks behind them and a specification justified by the research question, set out for your data and the output Stata produces.
Hierarchical Regression
Predictors added in theory-led blocks, with the change in explained variance judged at each step and the coefficients reported from the final model.
BEFORE YOU RUN IT
What regress Expects of the Predictor Set
Prefixes, reference levels, the number of usable rows and the independence of observations are fixed before fitting, so the checks that follow examine a model worth checking.
A Prefix for Every Predictor Writing i.group makes Stata create the indicators itself and c.age marks a continuous variable. A categorical code left without a prefix is read as a number, and the fit looks plausible but is wrong.
A Chosen Reference Level The omitted level of a factor is the comparison for each of its coefficients. The ib. prefix sets it explicitly, so the base is a well-populated, meaningful group and not just the lowest code.
Rows Enough for the Terms Coefficients are estimated from the rows left after missing values are removed. The observation count in the header is compared with the planned n, and the number of terms is kept in proportion to it.
Independent Rows Standard errors from regress assume independent observations. Patients within clinics, pupils within classes or repeated measures need clustered errors or a multilevel model, which no check below repairs.
IN STATA
How to Run Multiple Regression in Stata
regress and the commands that follow it are part of official Stata, so nothing is installed, the checks run on the plain fit and the robust refit comes last.
Fit With Factor Variables
Fit the model with regress, putting i. before each categorical predictor and c. before each continuous one, in the order planned.
Check: The numerator degrees of freedom of the F test should equal the number of slopes planned, counting each non-base factor level. A shortfall means a term was dropped, usually for collinearity, and Stata marks it as omitted.
Plot Residuals Against Fitted
Draw rvfplot and look for a curved band, which points to the wrong functional form, or a funnel, which points to unequal spread.
Watch: A curved band means the form of a relationship is wrong, a problem that robust standard errors do not repair. Reconsider the specification before turning to the other checks.
Read the Output of estat vif
Run estat vif on the fitted model and read the variance inflation factor and its reciprocal for each term.
Tip: High values are expected among terms built from one variable, such as a variable and its square, because they are correlated by construction. Centering the variable first usually lowers them.
Test for Unequal Spread
Run estat hettest, the Breusch-Pagan test, and set its result beside the residual plot instead of reading the p-value alone.
Watch: By default the test assumes normally distributed errors, and the iid option relaxes that. In a large sample, trivial unequal spread is flagged, so the plot and the size of the spread matter.
Refit With Robust Errors
Refit with vce(robust) when the spread is unequal. The coefficients stay as they were, and the standard errors, intervals and p-values change.
Tip: Put the two sets of standard errors side by side. Robust errors address unequal spread only, and a curved relationship, an omitted predictor or dependent rows remain exactly as they were.
Test Each Factor Jointly
Use testparm for a factor with several levels, or test for a list of coefficients, to obtain one F test for the whole set.
Check: A joint test uses the variance stored by the last fit, so run it after the robust refit when robust errors are reported. A test run on the plain fit does not carry over.
regress y c.x1 c.x2 i.group
rvfplot
estat vif
estat hettest
regress y c.x1 c.x2 i.group, vce(robust)
testparm i.group
READING THE OUTPUT
Reading regress Output and the Checks After It
The header, the coefficient table and each follow-up command answer separate questions, and a copied value is only as sound as the fit it came from.
| Output element | What it tells you | What to check |
|---|---|---|
| Number of obs and F(k, df) in the header | Rows used and the joint test of all slopes | That the count matches the plan after missing values |
| R-squared and Adj R-squared | Share of outcome variance accounted for in this sample | That the adjusted value is preferred when models of unequal size are compared informally |
| Coefficient (Coef. in older releases) with Std. err. | Expected difference per unit, or against the base level of a factor | That the unit or the base level is named in the text |
| [95% conf. interval] | Coefficient values compatible with the data | That it is reported beside the estimate |
| Root MSE | Typical residual size in the outcome’s units | That it is read against the scale of the outcome |
| estat vif: VIF and 1/VIF | Inflation of variance and the share not shared with other terms | That terms built from one variable are read knowing they correlate |
| estat hettest: chi2 and Prob > chi2 | Test of constant error variance | That the plot agrees and the option used is named |
| Robust label over Std. err. | Standard errors without constant variance assumed | That the label is stated in the methods |
REPORTING
Reporting the Model, Its Checks and Its Standard Errors
A regression table leaves out the checks behind it, so the sentence around the table carries the sample, the reference levels and the choice of errors.
Report the model with its F test, F(df1, df2) = ___, p = ___, and R-squared = ___, then each coefficient as b = ___, 95% CI [___, ___], naming the unit of the predictor or the reference level of a factor. State the sample actually used, since regress drops rows with a missing value on any variable. Say which standard errors are reported: robust when vce(robust) was used and conventional otherwise. Describe the collinearity check by the largest VIF and the term it belongs to, and the spread check by the plot and the test run. Give joint tests for multi-level factors as an F statistic with both degrees of freedom. Word coefficients as differences associated with predictors, unless the design supports causal language. Mention any term that Stata omitted from the fit.
COMMON MISTAKES
Gaps Between the Fitted Model and the Text
Each gap below is visible in the do-file and the log, which is where a careful reviewer would look first.
Indicators Made by Hand Manually coded indicators and interactions drift out of step when the data change, and later commands such as contrast and pwcompare cannot treat them as one factor. Factor-variable notation keeps them tied to the model.
VIF Cutoff Treated as a Rule A single threshold, such as 10, is a convention and not a test. The value is read for the terms that matter, with the sample size and the source of any overlap in mind.
Robust Taken as a Cure vce(robust) corrects standard errors for unequal spread. It does not repair a curved relationship, an omitted predictor or rows that depend on one another.
hettest Read Without a Plot In a large sample a small p-value can flag spread that is trivial, and in a small one a large p-value can miss a funnel. The residual plot is read beside the test.
A Factor Judged Level by Level Reading a multi-level predictor from the separate p-values of its indicators ignores that the set entered together. The joint test gives a single answer for the factor.
Causal Wording From Coefficients A coefficient adjusts for the other variables in the model, which is not the same as removing confounding. Wording that implies an effect needs a design or an argument behind it.
Coefficients reported, robust choice still unexplained? Independent Statistical Review examines the specification, the diagnostics and the standard errors behind each coefficient.
FREQUENTLY ASKED QUESTIONS
Questions About Checks, Standard Errors and Factors
Collinearity tends to be overread and robust errors overtrusted, while a factor with several levels needs one test for the whole set of its indicators.
What does estat vif in Stata show, and when does it matter?
It reports a variance inflation factor and its reciprocal for each term, showing how much of that term the other predictors explain. High values widen standard errors, so a coefficient looks imprecise. They are expected for a variable and its square, and no cutoff is a test: the source of the overlap and the sample size decide whether it matters.
Do robust standard errors in Stata fix unequal spread?
They correct the standard errors for unequal spread and leave the coefficients as they were. Intervals and p-values then no longer assume constant variance. They do not repair a misspecified form, omitted predictors or dependence between rows, which need a different specification or clustered errors.
How do I test whether a categorical predictor matters overall?
Use testparm i.group, or test with the coefficients of its levels listed, to get one F test for the whole factor. The test uses the variance of the last model fitted, so it follows the robust refit when vce(robust) was used. Single indicator coefficients only compare each level with the base, and they can disagree with the joint test.
My regress model is fitted: what is left to review?
An in-house PhD-level statistician at OnlineSPSS goes through the fitted model, the plots and tests above, and the sentence reporting each coefficient. The checks can also be rerun on your data and do-file. The stage sits under Results Reporting & Interpretation, and what the coefficients mean for your field remains yours.
How do you protect my research data and confidentiality?
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.
What happens when I request an assessment, and how long does it take?
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.
NEXT STEP
Does the Model
Match the Question?
A model can pass every check on this page and still answer a different question from the one the study asked, which is why the specification is weighed first.
No Commitment Required
Strictly Confidential
Fixed Project Fee
In-House PhD-Level Statisticians
Same-Day Response
Serving Researchers Since 2014