This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Implement Seemingly Unrelated Regression

This example shows how to include exogenous data for several seemingly unrelated regression (SUR) analyses. The response and exogenous series are random paths from a standard Gaussian distribution.

In seemingly unrelated regression (SUR), each response variable is a function of a subset of the exogenous series, but not of any endogenous variable. That is, for j=1,..,n and t=1,...,T, the model for response j at period t is

yjt=aj+bj1xk1t+bj2xk2t+...+bjkjxkjt+εjt

The indices of the regression coefficients and exogenous predictors indicate that:

  • You can associate each response with a different subset of exogenous predictors.

  • The response series might not share intercepts or regression coefficients.

SUR accommodates intra-period innovation correlation, but inter-period innovation independence, i.e.,

E(εitεjs|X)={0;ts,ijσij;ij,t=sσi2>0;i=j,t=s.

Simulate Data from True Model

Suppose that the true model is

y1t=1+2x1t-1.5x2t+0.5x3t+0.75x4t+ε1ty2t=-1+4x1t+2.5x2t-1.75x3t-0.05x4t+ε2ty3t=0.5-2x1t+0.5x2t-1.5x3t+0.7x4t+ε3t,

where εjt, j=1,...,n are multivariate Gaussian random variables each having mean zero and jointly having covariance matrix

Σ=[10.5-0.050.510.25-0.050.251]

Suppose that the paths represent different econometric measurements, e.g. stock returns.

Simulate four exogenous predictor paths from the standard Gaussian distribution.

rng(1);   % For reproducibility
n = 3;    % Number of response series 
nExo = 4; % Number of exogenous series
T = 100;
X = randn(100,nExo);

mvregress, the workhorse of estimate, requires you to input the exogenous data in a T-by-1 cell vector. Cell t of the cell vector is a design matrix indicating the linear relationship of the exogenous variables with each response series at period t. However, estimate associates each predictor to every response. As a result, estimate requires the predictor data in a matrix.

Create a VAR model object that characterizes the true model. Simulate a length 100 path of responses from the model.

aTrue = [1; -1; 0.5];
bTrue = [[2; 4; -2] [-1.5; 2.5; 0.5] [0.5; -1.75; -1.5] [0.75; -0.05; 0.7]];
InnovCov = [1 0.5 -0.05; 0.5 1 0.25; -0.05 0.25 1];
TrueMdl = varm('Beta',bTrue,'Constant',aTrue,'Covariance',InnovCov)
TrueMdl = 
  varm with properties:

     Description: "3-Dimensional VARX(0) Model with 4 Predictors"
     SeriesNames: "Y1"  "Y2"  "Y3" 
       NumSeries: 3
               P: 0
        Constant: [1 -1 0.5]'
              AR: {}
           Trend: [3×1 vector of zeros]
            Beta: [3×4 matrix]
      Covariance: [3×3 matrix]
Y = simulate(TrueMdl,T,'X',X);

SUR Using All Predictors for Each Response Series

Create a VAR model suitable for SUR using the shorthand syntax of varm.

Mdl1 = varm(n,0);

Mdl1 is a varm model object template representing a three-dimensional VAR(0) model. Unlike TrueMdl, none of the coefficients, intercepts, and intra-period covariance matrix have values. Therefore, Mdl1 is suitable for estimation.

Estimate the regression coefficients using estimate. Extract the residuals. Display the estimated model using summarize.

[EstMdl1,~,~,E] = estimate(Mdl1,Y,'X',X);
summarize(EstMdl1)
 
   3-Dimensional VARX(0) Model with 4 Predictors
 
    Effective Sample Size: 100
    Number of Estimated Parameters: 15
    LogLikelihood: -412.026
    AIC: 854.052
    BIC: 893.129
 
                     Value      StandardError    TStatistic      PValue   
                   _________    _____________    __________    ___________

    Constant(1)      0.97898       0.11953          8.1902      2.6084e-16
    Constant(2)      -1.0644       0.10019         -10.623      2.3199e-26
    Constant(3)      0.45323       0.10123          4.4772      7.5611e-06
    Beta(1,1)         1.7686       0.11994          14.745      3.2948e-49
    Beta(2,1)         3.8576       0.10054           38.37     4.1502e-322
    Beta(3,1)        -2.2009       0.10158         -21.667     4.1715e-104
    Beta(1,2)        -1.5508       0.12345         -12.563      3.3861e-36
    Beta(2,2)         2.4407       0.10348          23.587     5.2666e-123
    Beta(3,2)        0.46414       0.10455          4.4395      9.0156e-06
    Beta(1,3)        0.69588       0.13491          5.1583      2.4922e-07
    Beta(2,3)        -1.7139       0.11308         -15.156      6.8911e-52
    Beta(3,3)        -1.6414       0.11425         -14.367      8.3713e-47
    Beta(1,4)        0.67036       0.12731          5.2654       1.399e-07
    Beta(2,4)      -0.056437       0.10672        -0.52885         0.59691
    Beta(3,4)        0.56581       0.10782          5.2476      1.5406e-07

 
   Innovations Covariance Matrix:
    1.3850    0.6673   -0.1591
    0.6673    0.9731    0.2165
   -0.1591    0.2165    0.9934

 
   Innovations Correlation Matrix:
    1.0000    0.5748   -0.1357
    0.5748    1.0000    0.2202
   -0.1357    0.2202    1.0000

EstMdl is a varm model object containing the estimated parameters. E is a T-by- n matrix of residuals.

Alternatively, and in this case, you can use the backslash operator on X and Y. However, you must include a column of ones in X for the intercepts.

coeff = ([ones(T,1) X]\Y)
coeff = 5×3

    0.9790   -1.0644    0.4532
    1.7686    3.8576   -2.2009
   -1.5508    2.4407    0.4641
    0.6959   -1.7139   -1.6414
    0.6704   -0.0564    0.5658

coeff is a n-by- nExo + 1 matrix of estimated regression coefficients and intercepts. The estimated intercepts are in the first column, and the rest of the matrix contains the estimated regression coefficients

Compare all estimates to their true values.

fprintf('\n');
fprintf('               Intercepts      \n');
               Intercepts      
fprintf('     True    |   estimate  |  backslash\n');
     True    |   estimate  |  backslash
fprintf('--------------------------------------\n');
--------------------------------------
for j = 1:n
    fprintf('  %8.4f   |  %8.4f  | %8.4f\n',aTrue(j),EstMdl1.Constant(j),coeff(1,j));
end
    1.0000   |    0.9790  |   0.9790
   -1.0000   |   -1.0644  |  -1.0644
    0.5000   |    0.4532  |   0.4532
cB = coeff';
cB = cB(:);
fprintf('\n');
fprintf('              Coefficients      \n');
              Coefficients      
fprintf('     True    |   estimate  |  backslash\n');
     True    |   estimate  |  backslash
fprintf('--------------------------------------\n');
--------------------------------------
for j = 1:numel(EstMdl1.Beta)
    fprintf('  %8.4f   |  %8.4f  | %8.4f\n',bTrue(j),...
        EstMdl1.Beta(j),cB(n + j));
end
    2.0000   |    1.7686  |   1.7686
    4.0000   |    3.8576  |   3.8576
   -2.0000   |   -2.2009  |  -2.2009
   -1.5000   |   -1.5508  |  -1.5508
    2.5000   |    2.4407  |   2.4407
    0.5000   |    0.4641  |   0.4641
    0.5000   |    0.6959  |   0.6959
   -1.7500   |   -1.7139  |  -1.7139
   -1.5000   |   -1.6414  |  -1.6414
    0.7500   |    0.6704  |   0.6704
   -0.0500   |   -0.0564  |  -0.0564
    0.7000   |    0.5658  |   0.5658
fprintf('\n');
fprintf('                 Innovations Covariance\n');
                 Innovations Covariance
fprintf('            True            |             estimate\n');
            True            |             estimate
fprintf('----------------------------------------------------------\n');
----------------------------------------------------------
for j = 1:n
    fprintf('%8.4f %8.4f %8.4f  |   %8.4f %8.4f %8.4f\n',...
        InnovCov(j,:),EstMdl1.Covariance(j,:));
end
  1.0000   0.5000  -0.0500  |     1.3850   0.6673  -0.1591
  0.5000   1.0000   0.2500  |     0.6673   0.9731   0.2165
 -0.0500   0.2500   1.0000  |    -0.1591   0.2165   0.9934

The estimates from implementing estimate and the backslash operator are the same, and are fairly close to their corresponding true values.

One way to check the relationship strength between the predictors and responses is to compute the coefficient of determination (i.e., the fraction of variation explained by the predictors), which is

R2=1-jnσˆεj2jnσˆYj2,

where σˆεj2 is the estimated variance of residual series j, and σˆYj2 is the estimated variance of response series j.

R2 = 1 - sum(diag(cov(E)))/sum(diag(cov(Y)))
R2 = 0.9118

The SUR model and predictor data explain approximately 93% of the variation in the response data.

See Also

Objects

Functions

Related Topics