THE UNIVERSITY OF ILLINOIS AT CHICAGO

ECON 534: Econometrics I

AUTUMN 2004



Prof. George Karras





Example 2: Multivariate Regression



Consider the following regression model:



stdgdpi = 1 + 2*stdsolowi + 3*stdm1i + 4*meangovi + i, i=1,2,...,N, (1)



where stdgdp is the standard deviation of detrended GDP (a measure of business-cycle volatility), stdsolow is the standard deviation of the Solow residual, stdm1 is the standard deviation of the detrended M1 money supply, meangov is average government consumption as a fraction of GDP, is an error term, and 1, 2, 3, and 4 are parameters. The following is a RATS output which estimates (1) using the cross-sectional OECD data from G.Karras and F.Song (Fall 1996), "Sources of Business-Cycle Volatility: An Exploratory Study on a Sample of OECD Countries" Journal of Macroeconomics:





A. Input the data.



allocate 24

*

* cross section data from G.Karras and F.Song, Journal of Macroeconomics,

* Fall 1996 (Appendix)

*

* Note: N=24, K=4.

*

data(unit=input,org=obs) / number stdgdp stdsolow stdm1 meangov

1 0.0175898335346 2.3588138191884 0.0543157559544 0.1569046197688 (Australia)

2 0.0169331673977 2.0860331691907 0.0453915686851 0.1625823916291 (Austria)

3 0.0167926798370 1.8673502679234 0.0431795903515 0.1509336430254 (Belgium)

4 0.0194867550979 1.6762360647194 0.0895004826866 0.1807037033556 (Canada)

5 0.0179411133736 2.0093689346665 0.0447975353847 0.2189690791726 (Denmark)

6 0.0248948646821 2.2531112291235 0.1226715868950 0.1670768824372 (Finland)

7 0.0125789655760 1.6345309753864 0.0512042108332 0.1651290702207 (France)

8 0.0183784650456 1.8362044275719 0.0417975409105 0.1789682462017 (Germany)

9 0.0219341162869 4.0656503371884 0.0402864692620 0.1519544022388 (Greece)

10 0.0419316041961 3.6793784978823 0.1038025616835 0.1478924694045 (Iceland)

11 0.0223727069730 2.0875114394318 0.0586297877174 0.1605421280493 (Ireland)

12 0.0183036147471 2.5356831042386 0.0728270014533 0.1457770768282 (Italy)

13 0.0256984255909 3.3821794920687 0.0510256704137 0.0884022813210 (Japan)

14 0.0281542447889 3.0984816295201 0.0449064361729 0.1363891290764 (Luxembourg)

15 0.0177404506142 2.1480772183521 0.0381423313581 0.1532562086739 (Netherlands)

16 0.0306835312134 3.2139640709227 0.1768667034676 0.1453466284482 (N.Zealand)

17 0.0165243320437 1.6500173929878 0.0682760106228 0.1789848701432 (Norway)

18 0.0273089906354 3.9663215803002 0.0606549403413 0.1391622409978 (Portugal)

19 0.0244528411518 2.7065317524957 0.0637879072683 0.1134299233788 (Spain)

20 0.0144892333545 1.9019994121437 0.0621086944958 0.2365157205679 (Sweden)

21 0.0274475844095 1.9450768451571 0.0539401662015 0.1178606711949 (Switzerland)

22 0.0302366336809 3.0070092375755 0.1236136549118 0.1313023449675 (Turkey)

23 0.0204076379533 1.7481745014348 0.1321026401195 0.1913590390690 (U.K.)

24 0.0202967057965 1.6960134063870 0.0309017914202 0.1785955083676 (U.S.A.)

B. Obtain the RATS regression output

linreg stdgdp

# constant stdsolow stdm1 meangov



Dependent Variable STDGDP - Estimation by Least Squares

Usable Observations 24 Degrees of Freedom 20

Centered R**2 0.646052 R Bar **2 0.592960

Uncentered R**2 0.972792 T x R**2 23.347

Mean of Dependent Variable 0.0221907707

Std Error of Dependent Variable 0.0065412907

Standard Error of Estimate 0.0041733238

Sum of Squared Residuals 0.0003483326

Regression F(3,20) 12.1685

Significance Level of F 0.00009402

Durbin-Watson Statistic 2.217786



Variable Coeff Std Error T-Stat Signif

*******************************************************************************

1. Constant 0.015138492 0.007544442 2.00658 0.05850603

2. STDSOLOW 0.004136110 0.001381421 2.99410 0.00717051

3. STDM1 0.069799137 0.024255859 2.87762 0.00930712

4. MEANGOV -0.049979664 0.032630638 -1.53168 0.14126723



C. Replicate using Matrix Algebra



C1. Input the vector y and the matrix X. Display X.



declare vector y(24)

declare rectangular x(24,4)

do i=1,24

(01.0023) compute y(i) = stdgdp(i)

(01.0045) compute x(i,1) = 1

(01.0064) compute x(i,2) = stdsolow(i)

(01.0088) compute x(i,3) = stdm1(i)

(01.0112) compute x(i,4) = meangov(i)

(01.0136) end do i

write x

1.0000 2.3588 0.0543 0.1569

1.0000 2.0860 0.0454 0.1626

1.0000 1.8674 0.0432 0.1509

1.0000 1.6762 0.0895 0.1807

1.0000 2.0094 0.0448 0.2190

1.0000 2.2531 0.1227 0.1671

1.0000 1.6345 0.0512 0.1651

1.0000 1.8362 0.0418 0.1790

1.0000 4.0657 0.0403 0.1520

1.0000 3.6794 0.1038 0.1479

1.0000 2.0875 0.0586 0.1605

1.0000 2.5357 0.0728 0.1458

1.0000 3.3822 0.0510 0.0884

1.0000 3.0985 0.0449 0.1364

1.0000 2.1481 0.0381 0.1533

1.0000 3.2140 0.1769 0.1453

1.0000 1.6500 0.0683 0.1790

1.0000 3.9663 0.0607 0.1392

1.0000 2.7065 0.0638 0.1134

1.0000 1.9020 0.0621 0.2365

1.0000 1.9451 0.0539 0.1179

1.0000 3.0070 0.1236 0.1313

1.0000 1.7482 0.1321 0.1914

1.0000 1.6960 0.0309 0.1786



C2. Compute X'X and invert to get (X'X)-1.



compute xprimex = tr(x)*x

write xprimex

24.0000 58.5537 1.6747 3.7980

58.5537 156.3632 4.1992 8.9593

1.6747 4.1992 0.1477 0.2645

3.7980 8.9593 0.2645 0.6245





compute xprimexinv = inv(tr(x)*x)

write xprimexinv

3.2681 -0.4663 -0.7730 -12.8578

-0.4663 0.1096 -0.3782 1.4242

-0.7730 -0.3782 33.7807 -4.1795

-12.8578 1.4242 -4.1795 61.1346











C3. Compute ^=(X'X)-1X'y, y^=X^, and ^=y-y^.



declare vector betahat(4)

compute betahat = inv(tr(x)*x)*tr(x)*y

write betahat

0.0151 4.1361e-003 0.0698 -0.0500





declare vector yhat(24)

declare vector epsilonhat(24)

compute yhat = x*betahat

compute epsilonhat = y - yhat

do i=1,24

(01.0023) display y(i) yhat(i) epsilonhat(i)

(01.0066) end do i

0.01759 0.02084 -0.00325

0.01693 0.01881 -0.00188

0.01679 0.01833 -0.00154

0.01949 0.01929 1.99621e-004

0.01794 0.01563 0.00231

0.02489 0.02467 2.25334e-004

0.01258 0.01722 -0.00464

0.01838 0.01671 0.00167

0.02193 0.02717 -0.00524

0.04193 0.03021 0.01172

0.02237 0.01984 0.00253

0.01830 0.02342 -0.00512

0.02570 0.02827 -0.00257

0.02815 0.02427 0.00388

0.01774 0.01903 -0.00129

0.03068 0.03351 -0.00283

0.01652 0.01778 -0.00126

0.02731 0.02882 -0.00151

0.02445 0.02512 -6.63314e-004

0.01449 0.01552 -0.00103

0.02745 0.02106 0.00639

0.03024 0.02964 5.95143e-004

0.02041 0.02203 -0.00162

0.02030 0.01538 0.00491



C4. Demonstrate that X'^=0, i^i=0, and ^2s2=i^i2/(N-K).



compute xprimeepsilonhat = tr(x)*epsilonhat

write xprimeepsilonhat

-1.2681e-015

-2.6221e-015

-8.2206e-017

-1.9284e-016





compute mean = 0.

compute sigmahatsq = 0.

do i=1,24

(01.0023) compute mean = mean + epsilonhat(i)/24.

(01.0049) compute sigmahatsq = sigmahatsq + (epsilonhat(i)**2)/(24.-4.)

(01.0084) end do i

compute sigmahat = sqrt(sigmahatsq)

display mean sigmahat

-5.28820e-017 0.00417









C5. Derive Var(^)=s2(X'X)-1.



declare rectangular varbetahat(4,4)

compute varbetahat = sigmahatsq*inv(tr(x)*x)

write varbetahat

5.6919e-005 -8.1216e-006 -1.3464e-005 -2.2394e-004

-8.1216e-006 1.9083e-006 -6.5876e-006 2.4806e-005

-1.3464e-005 -6.5876e-006 5.8835e-004 -7.2793e-005

-2.2394e-004 2.4806e-005 -7.2793e-005 1.0648e-003











C6. Derive R2 and R_2.



compute Rsquare = (%corr(y,yhat))**2

compute Rsquarebar = 1. - (24.-1.)*(1.-Rsquare)/(24.-4.)

display Rsquare Rsquarebar

0.64605 0.59296

*

end





Normal Completion



A SPEAKEASY Alternative:



1. THE X MATRIX



:_x

X (A 24 by 4 Matrix)

1 2.3588 .054316 .1569

1 2.086 .045392 .16258

... etc. ...

1 1.7482 .1321 .19136

1 1.696 .030902 .1786





2. CALCULATE AND INVERT (X'X)



:_xprimex = transpose(x)*x

:_xprimex

XPRIMEX (A 4 by 4 Matrix)

24 58.554 1.6747 3.798

58.554 156.36 4.1992 8.9593

1.6747 4.1992 .14767 .2645

3.798 8.9593 .2645 .62452



:_1/xprimex

1/XPRIMEX (A 4 by 4 Matrix)

3.2681 -.46632 -.77303 -12.858

-.46632 .10957 -.37824 1.4242

-.77303 -.37824 33.781 -4.1795

-12.858 1.4242 -4.1795 61.135





3. CALCULATE BETA



:_(1/xprimex)*transpose(x)*vfam(yr_sd_hp)

(1/XPRIMEX)*TRANSPOSE(X)*VFAM(YR_SD_HP) (A Vector with 4 Components)

.015138 .0041361 .069799 -.04998





4. OBTAIN THE SPEAKEASY REGRESSION OUTPUT



:_olsq yr_sd_hp c solow_sd m1_sd_hp govmean

ORDINARY LEAST SQUARES

VARIABLES...

YR_SD_HP #C SOLOW_SD M1_SD_HP GOVMEAN

INDEPENDENT COL ESTIMATED STANDARD T- CONTRIBUTION

VARIABLE COEFFICIENT ERROR STATISTIC TO R**2

#C 1 .015138 .0075444 2.0066

SOLOW_SD 1 .0041361 .0013814 2.9941 .15865

M1_SD_HP 1 .069799 .024256 2.8776 .14655

GOVMEAN 1 -.04998 .032631 -1.5317 .041519

R-SQUARED = .64605

R-SQUARED(CORRECTED) = .59296

MULTICOLLINEARITY EFFECT = .29934

DURBIN-WATSON STATISTIC = 2.2178

NUMBER OF OBSERVATIONS = 24

SUM OF SQUARED RESIDUALS = 3.4833E-4

STANDARD ERROR OF THE REGRESSION = .0041733

:_quit