Written and maintained by CASRAI Editorial Board
Published
On this page
Multivariate regression in R means fitting one linear model to several outcome variables at once. You do it with lm() by putting a matrix on the left of the formula, for example lm(cbind(y1, y2) ~ x1 + x2, data = d). R then fits the same predictors to each column separately by least squares and returns an object of class "mlm", and you test hypotheses across all outcomes jointly with anova() or car::Anova(). If you only have one outcome and several predictors, that is multiple linear regression, covered briefly below.
What multivariate regression in R is used for in research
Researchers reach for a multiple-outcome model when several related measurements are taken on the same units and one question applies to all of them: does a treatment, a dose or a covariate shift the set of outcomes? Typical cases are a panel of correlated physiological measures, several subscales of one questionnaire, or repeated measures that are analysed as separate columns. The joint test answers “is there any effect on the outcome vector”, which a stack of separate univariate tests does not.
The terminology is a common source of confusion. A model with one response and many predictors is usually called multiple or multivariable regression; a model with a matrix of responses is multivariate regression. The distinction is explained in multivariable vs multivariate analysis. If your predictors are only group labels, the same machinery is MANOVA, walked through in MANOVA in R.
What R does is simple to state. According to the R manual for lm, when the response is a matrix, a linear model is fitted separately by least squares to each column of the matrix. The coefficients for each outcome are therefore the same ones you would get from running lm() on that outcome alone. What the multivariate object adds is the joint inference: tests of a term across all responses, using the residual sums of squares and products matrix.
If you meant multiple linear regression with one outcome
Write lm(y ~ x1 + x2, data = d). Everything after the model-fitting step differs from this guide: you read one coefficient table, one R² and one F test. The single-response workflow, including factor coding and the formula syntax, is the subject of the model-building guides on this site; glm in R covers non-Gaussian outcomes, which lm does not handle.
How to install or access R and the car package
R itself comes from CRAN, the Comprehensive R Archive Network. The CRAN bin directory lists precompiled distributions for Linux, macOS and Windows; pick your platform folder and follow the instructions there. The multivariate fitting and the anova() method for multivariate fits are in the base stats package, which ships with R, so nothing needs installing for the core workflow.
The car package adds Anova() (and Manova(), which the car reference manual describes as essentially a synonym for Anova() for multivariate linear models) for Type II and Type III tests. Install it once from CRAN and load it in each session:
install.packages("car")
library(car)
How to run a multivariate regression in R step by step
The steps below use the mtcars data frame that ships with R (in the datasets package), with three outcomes and two predictors. The data are used only to show the syntax; the page prints no results, so run the code and read your own output.
- Put the outcomes in a matrix on the left of the formula.
fit = lm(cbind(mpg, disp, hp) ~ wt + qsec, data = mtcars)The call is the same
lm(formula, data, subset, weights, na.action, method = "qr", ...)as for one response; only the left-hand side changes. - Check the object class.
class(fit)should return"mlm" "lm". The lm manual states that the result has classc("mlm", "lm")for multivariate (multiple) responses. If you see only"lm", your left-hand side was a single variable. - Inspect coefficients and per-response summaries.
coef(fit)returns one column of coefficients per outcome, andsummary(fit)prints a separate summary for each response. These are the univariate fits, one per column. - Test the whole model jointly.
anova(fit)The
anovamethod for multivariate fits has the signatureanova(object, ..., test, Sigma, T, M, X, idata, tol). Its default test statistic is Pillai. - Choose a different test statistic if you need one.
anova(fit, test = "Wilks") anova(fit, test = "Hotelling-Lawley") anova(fit, test = "Roy")The documented choices are Pillai (the default), Wilks, Hotelling-Lawley, Roy and Spherical.
- Test one predictor against the rest by comparing nested models.
fit0 = update(fit, . ~ . - qsec) anova(fit, fit0)This follows the multi-model form in the R manual, where the sums of squares and products matrix of the largest model supplies the denominator for all the tests.
- Get per-term tests with car.
Anova(fit, type = "II", test.statistic = "Pillai")For multivariate linear models
Anova()takestype(II or III) andtest.statistic, one of Pillai (default), Wilks, Hotelling-Lawley or Roy. - Look at the residual covariance.
SSD(fit)returns the residual sums of squares and products matrix with its degrees of freedom, andestVar(fit)returns the estimated variances and covariances among the outcomes.
For a reproducible record, set the formula, the data and the test statistic in a script and keep the output with the code, and cite R and the car package in the methods section. The p value in R guide explains how to extract and adjust the p-values these functions report.
How to read the output of a multivariate regression in R
Per-response results versus joint tests
The most useful habit is to separate what R computes per outcome from what it tests across outcomes. The data table below sets out each function used here, the package it comes from and what it returns, taken from the R and car documentation.
Coefficients, standard errors and per-outcome R² come from the separate least-squares fits, so each can be reproduced with a single-response lm(). A joint test, by contrast, uses the full residual covariance matrix and gives one statistic for the term across all outcomes. Report R² per outcome.
Choosing among the four test statistics
Pillai, Wilks, Hotelling-Lawley and Roy are four ways of summarising the same hypothesis and error matrices. They can give different p-values for the same data. R’s default is Pillai, and the other statistics are one argument away, so state in the methods section which you used and why, and do not switch after seeing the results.
Intercept row and Type II versus Type III
Two features of the output surprise people. First, the R manual notes that, unlike other anova methods, the intercept is not excluded when a single model is displayed, so an intercept row appears in anova(fit). Second, car::Anova() offers Type II and Type III tests. The car manual states that Type III tests require suitable contrasts, such as contr.sum and contr.poly, rather than the default treatment contrasts. If you use Type III tests with factor predictors, set the contrasts before fitting:
options(contrasts = c("contr.sum", "contr.poly"))
Check the contrasts you actually used against ?contrasts and your analysis plan. With only numeric predictors, as in the example above, the question does not arise.
A reporting skeleton
A reportable multivariate result names the test statistic, its value, the approximate F, the numerator and denominator degrees of freedom, and the p-value, followed by the per-outcome follow-ups with any multiplicity adjustment you applied. The skeleton below shows the order; the bracketed values are blanks for your own output, not results.
Pillai’s trace for wt was [value], approximate F([df1], [df2]) = [value], p = [value]. Follow-up univariate models for each outcome are in Table 1.
Check residuals for each outcome before trusting the joint test; the joint tests assume the usual linear-model conditions, and a quantile plot of each outcome’s residuals is a quick start (see quantile-quantile plots in R). For testing equal variance across groups with car, see Levene’s test in R.
Troubleshooting multivariate regression in R
Only one table appears, or class is just “lm”
The left side is not a matrix. Wrap the outcomes in cbind() (or as.matrix() on a data-frame subset) inside the formula.
The p-values differ from my univariate fits
They should. Per-response p-values test one outcome; the joint test uses all outcomes and their covariance. A joint test can be significant when no single outcome is, and the reverse.
Rows disappear from the model
Missing values are handled by na.action, an argument of lm(). With the usual default a row is dropped when any outcome or predictor is missing, so all outcomes are fitted on the same rows. Check nobs(fit) against your sample size and decide on a missing-data strategy deliberately.
Type III results look wrong with factor predictors
This is almost always the contrasts issue described above: Type III tests with the default treatment contrasts are not what you want, per the car documentation. Refit with sum-to-zero and polynomial contrasts, or use Type II.
I want to compare one test statistic with another
Re-run the same object with a different test argument. The model does not need refitting, since the statistics are computed from the same fitted object.
The wrong function: aov, manova and lm
If your predictors are factors and your question is purely about group differences, MANOVA is the standard framing; the call is described in the MANOVA guide linked above. If the outcomes are binary or counts, lm is the wrong model family altogether.
Free alternatives to multivariate regression in R
Other open-source tools fit a multi-column response too. The table lists what each tool’s own documentation says.
| Tool | Multiple-outcome capability, per its documentation |
|---|---|
statsmodels (Python), MANOVA |
Described as multivariate analysis of variance built on multivariate regression; it does not assume the explanatory variables are categorical; hypotheses are tested through mv_test; models specified by formula include an intercept by default. |
scikit-learn (Python), LinearRegression |
Ordinary least squares; y may be 2D with one column per target, and coef_ then has shape (n_targets, n_features). It fits and predicts; it does not provide the joint hypothesis tests described above. |
R, base lm() |
Fits each column of a matrix response separately by least squares and returns class "mlm"; joint tests via anova() with Pillai as default. |
If you need joint hypothesis tests in Python, statsmodels is the closer match; if you need only predictions for several targets, scikit-learn is enough.
Frequently asked questions
What is the formula for multivariate regression in R?
Use lm(cbind(y1, y2, y3) ~ x1 + x2, data = d). The left-hand side is a matrix of outcomes created with cbind(); the right-hand side is an ordinary model formula. The result has class "mlm".
Is multivariate regression the same as multiple regression in R?
No. Multiple regression has several predictors and one outcome. Multivariate regression has a matrix of outcomes. The same lm() function fits both, and what differs is the left-hand side of the formula and the tests you run afterwards.
Is there a multivariate regression in R PDF I can follow?
The authoritative references are the R manual pages for lm and anova.mlm and the car package reference manual, which CRAN publishes as a PDF; they are listed in the sources below. They document the arguments and test statistics precisely, though not as a worked tutorial.
Sources
- R documentation: Fitting Linear Models (lm), checked 2026-11-20
- R documentation: Comparisons between Multivariate Linear Models (anova.mlm), checked 2026-11-20
- R documentation: SSD matrix and estimated variance matrix in multivariate models, checked 2026-11-20
- CRAN: car package reference manual (Anova, Manova), checked 2026-11-20
- CRAN: precompiled binary distributions of R, checked 2026-11-20
- statsmodels documentation: MANOVA, checked 2026-11-20
- scikit-learn documentation: LinearRegression, checked 2026-11-20
Data: Functions for multivariate linear models in R: package, output and test options
Compares the R functions used to fit and test a multivariate linear model (matrix response): the package each belongs to, what each returns and its documented default or options. Compiled by CASRAI Editorial from the R stats manual pages and the car package reference manual; every cell is taken from those pages.
Period covered: 2026.
| Function | Package | What it returns or tests | Documented default or options |
|---|---|---|---|
| lm() | stats | Separate least-squares fit to each column of a matrix response; class c("mlm","lm") | method = "qr"; formula left side is a matrix, e.g. cbind(y1, y2) |
| anova() on an mlm | stats | Joint tests of terms or of nested models across all responses | test = Pillai (default); Wilks, Hotelling-Lawley, Roy, Spherical |
| Anova() on an mlm | car | Type II or Type III joint tests for each term | type = II (first listed); test.statistic = Pillai (default); Wilks, Hotelling-Lawley, Roy |
| Manova() | car | Essentially a synonym for Anova() for multivariate linear models | Same arguments as Anova() |
| SSD() | stats | Residual sums of squares and products matrix, degrees of freedom and call | Takes an mlm object |
| estVar() | stats | Matrix of estimated variances and covariances | Takes an mlm or SSD object |
Sources
- R documentation: lm (accessed 2026-11-20)
- R documentation: anova.mlm (accessed 2026-11-20)
- R documentation: SSD and estVar (accessed 2026-11-20)
- CRAN: car reference manual (accessed 2026-11-20)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







