We are given the regression model
where
The linear regression model is as following;
This model can be written in a simpler way;
load gnp,cpi,r_3mo,m2; m=log(m2./cpi); y=log(gnp./cpi); x=ones(rows(m),1)~y~r_3mo; beta=inv(x'x)*x'm; beta'; -0.76819 1.20619 -0.01538Thus, the coefficient estimates of
x=ones(rows(m),1)~log(gnp)~r_3mo~log(cpi); beta=inv(x'x)*x'log(m2); beta'; -0.33583 1.2001 -0.00675 -0.19640 -0.77329 1.2001 -0.15555 -0.19640 /* if ln is used instead of log */ -0.74465 1.1119 -0.01547 -0.07839 /* if ln is used with ascii data */ -0.32340 1.1119 -0.00672 -0.07839 /* if log is used with ascii data */We see that although the signs of
e=m-x*inv(x'x)*x'm;
rsqr=1-e'e/(sumc((m-meanc(m))^2);
rsqr;
0.99392
The R2 for the second regression is computed
similarly and it has an
R2=.99945, slightly
higher than the first regression. This is to be
expected since the second regression has an
extra coefficient
load gnp,c;
x=ones(rows(gnp),1)~gnp;
beta=inv(x'x)*x'c;
beta';
-19.842 0.6435
so the estimated aggregate marginal propensity to consume
is 64.35 cents out of each dollar of GNP.
ec=c-x*inv(x'x)*x'c; ecl=ec[1:23]; /* Lagged errors at t-1 */ ecf=ec[2:24]; /* Current errors at t */ stdl=sqrt(meanc((ecl-meanc(ecl))^2)); stdf=sqrt(meanc((ecf-meanc(ecf))^2)); rho=meanc((ecf-meanc(ecf)).*(ecl-meanc(ecl)))/(stdl*stdf); rho; 0.5654Note: the Gauss stdc command divides by T-1 instead of T. If you used stdc instead of the direct commands above (which divide by T to compute variance), you would get
load data[200,4]=soy.asc;
p=data[.,1];
q=data[.,2];
d_shocks=data[.,3];
s_shocks=data[.,4];
n=rows(data);
xd=ones(n,1)~p~d_shocks;
beta=inv(xd'xd)*xd'q;
beta';
1.733 .267 .359
The OLS estimates lead to the
counterintuitive finding that the demand for soybeans
is positively sloped. Is this because Soybeans are a Giffen good?
No! Read on.
The results for the OLS regression of the supply curve parameters are:
xs=ones(n,1)~p~s_shocks;
alpha=inv(xs'xs)*xs'q;
alpha';
8.039 .353 .625
The OLS estimates lead to the
intuitively plausible finding that the supply curve for soybeans
is positively sloped.
The method of 2-stage least squares is one
way to get around the problem of simultaneous equations
bias. It is an example of an instrumental variables
estimator (IV). The idea is to project the
endogenous variable p in the demand regression on
exogenous variables (also known as instrumental
variables which are known not to be correlated with
the error term
.
z=ones(n,1)~d_shocks~s_shocks; xhat=z*inv(z'z)*z'x; yhat=z*inv(z'z)*z'y; beta2sls=inv(xhat'xhat)*xhat'yhat; beta2sls'; 8.554 -1.635 .354So the 2SLS estimate of