mvregress
statistics: beta = mvregress (X, Y)
statistics: beta = mvregress (…, name, value)
statistics: [beta, Sigma, E, CovB, logL] = mvregress (…)
Multivariate (multiple-response) linear regression by maximum likelihood.
mvregress (X, Y) fits the multivariate normal regression
of the n-by-d response matrix Y on the design X and
returns the coefficient estimates beta.
X is either a numeric n-by-p matrix, in which case the same p predictors apply to every response and beta is returned as a p-by-d matrix; or a cell array of n design matrices, each d-by-K, in which case beta is a K-by-1 vector.
Missing responses (NaN entries of Y) are handled according to
the estimation algorithm.
The following name/value pairs are accepted:
"algorithm""mvn" (multivariate normal; observations with any missing response
are discarded), "ecm" (expectation-conditional-maximization, using
every observed response), or "cwls" (covariance-weighted least
squares, with the weight given by "covar0"). The default is
"mvn" when Y has no missing values and "ecm" otherwise."covar0""cwls" (default the
identity), or the initial covariance for "ecm"."maxiter""tolbeta", "tolobj"1e-8 and 1e-8). The additional outputs are the estimated residual covariance Sigma
(d-by-d), the residuals E (n-by-d), the
covariance CovB of the coefficient estimates, and the log-likelihood
logL. (With missing data and the "ecm" algorithm, CovB
is the standard observed-information covariance and can differ from
MATLAB’s value at the 1e-3 level; all other outputs agree.)
See also: mvregresslike, regress, fitlm
Source Code: mvregress
Two correlated responses regressed on a common predictor.
X = [ones(30,1), (1:30)'/30]; B = [1 -1; 2 0.5]; E = [0.3 0.1; 0.1 0.2]; Y = X * B + randn (30, 2) * chol (E); [beta, Sigma] = mvregress (X, Y)
beta = 1.1640 -1.1613 1.6884 0.9119 Sigma = 0.3804 0.1121 0.1121 0.1200