Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

mvregress - Multivariate linear regression

Syntax

b = mvregress(X,Y)
[b,SIGMA] = mvregress(X,Y)
[b,SIGMA,RESID] = mvregress(X,Y)
[b,SIGMA,RESID,COVB] = mvregress(...)
[b,SIGMA,RESID,objective] = mvregress(...)
[...] = mvregress(X,Y,param1,val1,param2,val2,...)

Description

b = mvregress(X,Y) returns a vector b of coefficient estimates for a multivariate regression of the d-dimensional responses in Y on the predictors in X. If d = 1, X can be an n-by-p matrix of p predictors at each of n observations. If d ≥ 1, X can be a cell array of length n, with each cell containing a d-by-p design matrix for one multivariate observation. If all observations have the same d-by-p design matrix, X can be a single cell. Y is n-by-d. b is p-by-1.

mvregress treats NaNs in X or Y as missing values. Missing values in X are ignored. Missing values in Y are handled according to the value of the 'algorithm' parameter described below.

[b,SIGMA] = mvregress(X,Y) also returns a d-by-d matrix SIGMA for the estimated covariance of Y.

[b,SIGMA,RESID] = mvregress(X,Y) also returns an n-by-d matrix RESID of residuals.

The RESID values corresponding to missing values in Y are the differences between the conditionally imputed values for Y and the fitted values. The SIGMA estimate is not the sample covariance matrix of the RESID matrix.

[b,SIGMA,RESID,COVB] = mvregress(...) also returns a matrix COVB for the estimated covariance of the coefficients. By default, or if the 'varformat' parameter is 'beta' (see below), COVB is the estimated covariance matrix of b. If the 'varformat' parameter is 'full', COVB is the combined estimated covariance matrix for beta and SIGMA.

[b,SIGMA,RESID,objective] = mvregress(...) also returns the value of the objective function, or log likelihood, objective, after the last iteration.

[...] = mvregress(X,Y,param1,val1,param2,val2,...) specifies additional parameter name/value pairs chosen from the following:

Examples

Predict regional flu estimates based on Google™ queries using the national CDC estimates as a predictor:

load flu
% response: regional queries
y = double(flu(:,2:end-1));  
% predictor: national CDC estimates
x = flu.WtdILI;             
[nobs,nregions] = size(y);

% Create and fit model with separate intercepts but 
% common slope
X = cell(nobs,1);
for j=1:nobs
    X{j} = [eye(nregions), repmat(x(j),nregions,1)];
end
[b,sig,resid,vars,loglik] = mvregress(X,y);

% Plot raw data with fitted lines
B = [b(1:nregions)';repmat(b(end),1,nregions)]
axes1 = axes('Position',[0.13 0.5838 0.6191 0.3412]);
xx = linspace(.5,3.5)';
h = plot(x,y,'x', xx, [ones(size(xx)),xx]*B,'-');
for j=1:nregions; 
		set(h(nregions+j),'color',get(h(j),'color')); 
end
regions = flu.Properties.VarNames;
legend1 = legend(regions{2:end-1});
set(legend1,'Position', [0.7733 0.1967 0.2161 0.6667]);
% Create and fit model with separate intercepts and slopes
for j=1:nobs
X{j} = [eye(nregions), x(j)*eye(nregions)];
end
[b,sig,resid,vars,loglik2] = mvregress(X,y);
% Plot raw data with fitted lines
B = [b(1:nregions)';b(nregions+1:end)']
axes2 = axes('Parent',gcf,'Position',...
		[0.13 0.11 0.6191 0.3412]);
h = plot(x,y,'x', xx, [ones(size(xx)),xx]*B,'-');

for j=1:nregions; 
		set(h(nregions+j),'color',get(h(j),'color')); 
end

% Likelihood ratio test for significant difference
chisq = 2*(loglik2-loglik)
p = 1-chi2cdf(chisq, nregions-1)

References

[1] Little, Roderick J. A., and Donald B. Rubin. Statistical Analysis with Missing Data. 2nd ed., Hoboken, NJ: John Wiley & Sons, Inc., 2002.

[2] Meng, Xiao-Li, and Donald B. Rubin. "Maximum Likelihood Estimation via the ECM Algorithm." Biometrika. Vol. 80, No. 2, 1993, pp. 267–278.

[3] Sexton, Joe, and A. R. Swensen. "ECM Algorithms that Converge at the Rate of EM." Biometrika. Vol. 87, No. 3, 2000, pp. 651–662.

[4] Dempster, A. P., N. M. Laird, and D. B. Rubin. "Maximum Likelihood from Incomplete Data via the EM Algorithm." Journal of the Royal Statistical Society. Series B, Vol. 39, No. 1, 1977, pp. 1–37.

See Also

mvregresslike, manova1

Multivariate Normal Distribution

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS