Econometric Analysis
Fourth Edition
William H. Greene
New York University
Contents
Chapter
Chapter
Chapter
3
Chapter
5
Chapter
24
Chapter
1.
2.
3.
Introduction
Matrix Algebra
Probability and Distribution Theory
4.
Statistical Inference
5.
6.
38
Chapter 7.
51
Chapter 8.
1
2
Chapter 1. Introduction
/*==========================================================
Example 1.1. Keyness Consumption Function
*/==========================================================
?
? Read data
?
Read ; Nobs = 10 ; Nvar = 2 ; Names = C,X
; By Variables $
672.1 696.8 737.1 767.9 762.8
779.4 823.1 864.3 903.2 927.6
751.6 779.2 810.3 864.7 857.5
874.9 906.8 942.9 988.8 1015.7
?
? Plot the figure
?
Plot ; Lhs = X ; Rhs = C ; Regression Line $
Regression line is X
950
= -67.58063 +
.97927C
900
850
800
750
700
650
700
750
800
850
900
950
1000
1050
/*==========================================================
Example 1.2. Income and Education - An Econometric Issue
*/==========================================================
?
? There are no computations in Example 1.2.
?
Calc;List;fn=a'xqfr(x,MA)$
/*
MatrixX1
+
1|.1125000D+02
2|.1750000D+01
3|.7250000D+01
FN=.24375000000000010D+02
The constrained solution requires solution of
[ -2A C' ] (x
)
(-a)
[
C 0 ] (lambda) = ( 0)
C = [ 1 -1 1 ]
[ 1 1 1 ]
There are simpler ways to get this solution,
but the following is complete and explicit.
*/
Matrix ; C = [1, -1, 1 /
1, 1, 1] $
Matrix ; MTWOA = -2 * MA ; Minusa = -1 * a $
Matrix ; Zero = [0 / 0] ; Zero22 = [0,0/0,0]$
Matrix ; CT = C' $
Matrix ; D = [MTWOA , CT /
C
, Zero22 ]$
Matrix ; q = [Minusa / zero ] $
Matrix ; XL = <D> * q $
/*
Note that the solution for x(2) is not identically zero because of rounding.
*/
Matrix ; List ; x = XL(1:3) ; lambda=XL(4:5) $
Calc;List;fn=a'xqfr(x,MA)$
/*
MatrixXhas3rowsand1columns.
1
+
1|.1500000D+01
2|.5551115D15
3|.1500000D+01
MatrixLAMBDAhas2rowsand1columns.
1
+
1|.5000000D+00
2|.7500000D+01
FN=.22499999999999980D+01
P(x)
.200
.192
.184
.176
.168
.160
.152
.144
.136
.128
.120
.112
.104
.096
.088
.080
.072
.064
.056
.048
.040
.032
.024
.016
.008
.000
P(X<=x)
------.00674
.04043
.12465
.26503
.44049
.61596
.76218
.86663
.93191
.96817
.98630
.99455
.99798
.99930
.99977
.99993
.99998
.99999
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
*/
/*==================================================================
Example 3.2. Approximation to the Chi-Squared Distribution
Computes exact and approximate values of chi-squared probabilities.
*/==================================================================
Proc=apxchi(x,d)$
Calc;z=sqr(2*x)-sqr(2*d-1)
;list
;approx=Phi(z)
;exact=chi(x,d)$
Endproc
Exec;proc=apxchi(85,70)$
/*
APPROX = .89409039431135510D+00
EXACT
= .89297135030469340D+00
*/
/*==================================================================
Example 3.3. Linear Transformation of Normal Variable
No computations.
*/==================================================================
/*==================================================================
Example 3.4. Linear Transformations
Linear transformation of normally distributed variable. No
computations.
*/==================================================================
/*==================================================================
Example 3.5. Regression in an Exponential Distribution
Conditional distribution for an exponential model. No computations.
*/==================================================================
/*==================================================================
Example 3.6. Poisson Regression
Poisson Regression. Linear conditional mean function. No computations.
*/==================================================================
/*==================================================================
Example 3.7. Conditional Variance in a Poisson Model
Poisson Regression. Conditional variance function. No computations.
*/==================================================================
/*==================================================================
Example 3.8. Uniform - Exponential Mixture Distibution.
No computations.
*/==================================================================
/*==================================================================
Example 3.9. Covariance in a Mixture Distibution.
No computations.
*/==================================================================
/*==================================================================
Example 3.10. Decomposition of Variance.
No computations.
*/==================================================================
/*==================================================================
Example 3.11. Conditional Variance in a Poisson Regression.
Simple arithmetic computations.
*/==================================================================
/*==================================================================
Example 3.12. Analysis of Variance in a Poisson Model.
No computations.
*/==================================================================
90
80
70
60
50
40
30
20
10
0
10
12
14
16
18
20
22
/*==================================================================
Example 4.2. Sampling Distribution of a Sample Mean
Central limit theorem. Computes a draw from chi-squared 1 by squaring
a draw from standard normal. Averages 4 such draws. Repeats
1000 times, and plots a histogram of the draws.
*/==================================================================
Sample ; 1-1000$
Create ; Means = (1/4)*(
(Rnn(0,1))^2+(Rnn(0,1))^2
+(Rnn(0,1))^2+(Rnn(0,1))^2)$
Histogram ; Rhs=means ; int=30$ (30 Bars)
128
Frequency
96
64
32
0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526272829
Bin
HistogramforMEANSNOBS=1000,Toolow:0,Toohigh:0
BinLowerlimitUpperlimitFrequencyCumulativeFrequency
========================================================================
0.026.17546(.0460)46(.0460)
1.175.32475(.0750)121(.1210)
2.324.473103(.1030)224(.2240)
3.473.623113(.1130)337(.3370)
4.623.772112(.1120)449(.4490)
5.772.921100(.1000)549(.5490)
6.9211.07077(.0770)626(.6260)
71.0701.21966(.0660)692(.6920)
81.2191.36858(.0580)750(.7500)
91.3681.51747(.0470)797(.7970)
101.5171.66739(.0390)836(.8360)
111.6671.81631(.0310)867(.8670)
121.8161.96528(.0280)895(.8950)
131.9652.11425(.0250)920(.9200)
142.1142.26313(.0130)933(.9330)
152.2632.41217(.0170)950(.9500)
162.4122.56210(.0100)960(.9600)
172.5622.71113(.0130)973(.9730)
182.7112.8603(.0030)976(.9760)
192.8603.0095(.0050)981(.9810)
203.0093.1583(.0030)984(.9840)
213.1583.3074(.0040)988(.9880)
223.3073.4574(.0040)992(.9920)
233.4573.6062(.0020)994(.9940)
243.6063.7553(.0030)997(.9970)
253.7553.9041(.0010)998(.9980)
263.9044.0531(.0010)999(.9990)
274.0534.2020(.0000)999(.9990)
284.2024.3520(.0000)999(.9990)
294.3524.5011(.0010)1000(1.0000)
/*==================================================================
Example 4.3. Sampling Distribution of the Sample Minimum.
No computations.
*/==================================================================
/*==================================================================
Example 4.4. Mean Squared Error of the Sample Variance.
No computations.
*/==================================================================
/*==================================================================
Example 4.5. Quadratic Loss Function.
No computations.
*/==================================================================
/*==================================================================
Example 4.6. Likelihood Function for the Exponential Distribution.
No computations.
*/==================================================================
/*===================================================================
Example 4.7. Likelihood Function for the Normal Distribution.
No computations.
*/==================================================================
/*==================================================================
Example 4.8. Variance Bound for the Poisson Distribution.
No computations.
*/==================================================================
/*==================================================================
Example 4.9. Information Matrix for the Normal Distribution.
No computations.
*/==================================================================
/*==================================================================
Example 4.10. Convergence of the Sample Minimum in Exponential
Sampling. No computations.
*/==================================================================
/*==================================================================
Example 4.11. Estimating a Function of the Mean
No computations.
*/==================================================================
/*==================================================================
Example 4.12. Probability Limit of a Function of x-bar and s-squared
No computations.
*/==================================================================
/*==================================================================
Example 4.13. Limiting Distribution of t(n-1)
The following plots the distribution of t for 2, 10, 40,and infinite
degrees of freedom.
*/==================================================================
Sample ; 1-101$
Plot and connect 100 segments
Create ; t=trn(-4,.08)$
Values -4 to +4 in steps of .08
?
? This procedure obtains the value of the density over a
? grid of values contained in variable t, and puts then
? in a variable passed as fn.
?
Proc = tdensity(fn,t,d)$
Create;fn=Gma((d+1)/2)/Gma(d/2) / sqr(d*pi) *
(1+t*t/d)^(-(d+1)/2)$
Endproc$
?
? Compute for 2, 10, 40, infinity. (Last is N(0,1).)
Execute ; Proc=tdensity(t2,t,2)$
Execute ; Proc=tdensity(t10,t,10)$
Execute ; Proc=tdensity(t40,t,40)$
Create ; tinf=N01(t)$
?
? Now plot the four densities in the same figure.
Plot
; lhs=t ;rhs=t2,t10,t40,tinf ; Fill intervals
; Yaxis=Density
; Title=t Densities with Different Degrees of Freedom$
10
Density
.34
T2
T10
T40
TINF
.25
.17
.08
.00
-6
-4
-2
/*==================================================================
Example 4.14. Asymptotic Distribution of the Mean of an Exponential
Sample.
We generate the plot in the text for the mean of a sample of 16 from
exponential with parameter theta=1. Note, N and Theta are reserved
names in LIMDEP, so we use other names
*/==================================================================
Sample ; 1-101$
Calc
; thet = 1 ; nobs=16 ; df=2*nobs $
?
? Density of the chi-squared variable with 2n degrees of freedom
? Computed for t = 0 to 50.
Create ; t = trn(0,.5)
; Exact = .5^(df/2)/Gma(df/2) * Exp(-.5*t)*(t^(df/2-1)) $
?
? For the simple linear transformation from t to Xbar=theta/2n*t,
? just scale the variable down and the density up.
?
Create ; Xbar_n = t*thet/df
; Exact = Df/thet * Exact $
?
? Asymptotic distribution is normal with mean theta, and
? standard deviation theta/sqr(n).
?
Create ; Asymp = 1/Sqr(thet/nobs) *
N01((Xbar_n-thet)/Sqr(Thet/Nobs))$
?
? Now, just plot two densities.
?
Plot
; Lhs = Xbar_n
; Rhs = Exact,Asymp
; Fill;Endpoints=0,1.75
; Yaxis=Density
; Title=Asymptotic and Exact Distribution$
11
Density
1.4
1.0
.7
.3
.0
.0
.3
.7
1.0
1.4
1.8
XBAR_N
/*==================================================================
Example 4.15. Asymptotic Inefficiency of the Median in Normal
Sampling
No computations.
*/==================================================================
/*==================================================================
Example 4.16. Asymptotic Distribution for a Function of Two Estimates
No computations.
*/==================================================================
/*==================================================================
Example 4.17. Asymptotic Moments of the Sample Variance
No computations.
*/==================================================================
/*==================================================================
Example 4.18. Poisson Likelihood Function.
No computations.
*/==================================================================
/*==================================================================
Example 4.19. Likelihood for the Normal Distribution.
No computations.
*/==================================================================
/*==================================================================
Example 4.20. Multivariate Normal Mean Vector
No computations.
*/==================================================================
12
/*==================================================================
Example 4.21. Information Matrix for a Multivariate Normal Distribution
No computations.
*/==================================================================
/*==================================================================
Example 4.22. Variance Estimators for an MLE
*/==================================================================
Read ; Nobs=20 ; Nvar=3 ; Names=
I,
Y,
X $
1
20.5
12
2
31.5
16
3
47.7
18
4
26.2
16
5
44.0
12
6
8.28
12
7
30.8
16
8
17.2
12
9
19.9
10
10
9.96
12
11
55.8
16
12
25.2
20
13
29.0
12
14
85.5
16
15
15.1
10
16
28.5
18
17
21.4
16
18
17.7
20
19
6.42
12
20
84.9
16
?
? 1. Compute Maximum Likelihood Estimator
?
Results that will follow are shown.
?
Maximize ; Fcn = -log(beta+e)-y/(beta+e)
; Labels = beta
; Start = 0 $
/*=================================================================
Note that the standard error shown below is the square root of the
BHHH estimate which we compute below. This is the one that LIMDEP
uses.
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
20
|
| Iterations completed
2
|
| Log likelihood function
-88.43626
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |
+---------+--------------+----------------+--------+---------+
BETA
15.60272720
10.025547
1.556
.1196
*/=================================================================
13
?
? Compute variance estimators. Compute as a set of observations
? sum, then take reciprocals of sums.
Create
14
*/==================================================================
/*==================================================================
Example 4.25. Mixture of Normal Distributions.
No computations.
*/==================================================================
/*==================================================================
Example 4.26. Gamma distribution.
Method of moments and MLE.
*/==================================================================
Read ; Nobs=20 ; Nvar=3 ; Names=
I,
Y,
X $
1
20.5
12
2
31.5
16
3
47.7
18
4
26.2
16
5
44.0
12
6
8.28
12
7
30.8
16
8
17.2
12
9
19.9
10
10
9.96
12
11
55.8
16
12
25.2
20
13
29.0
12
14
85.5
16
15
15.1
10
16
28.5
18
17
21.4
16
18
17.7
20
19
6.42
12
20
84.9
16
?
?------------------------------------------------------------? First compute moments. With 'i' = variable, then means.
?------------------------------------------------------------Create ; m1i=y ; m2i=y*y ; mstari=log(y) ; m_1i=1/y$
Calc
; list ; m1=xbr(m1i) ; m2=xbr(m2i) ; mstar=xbr(mstari)
; m_1=xbr(m_1i) $
?------------------------------------------------------------? Starting value for solutions to moment equations. If
? P=1, Lambda = 1/y-bar. Use these as initial guesses.
?------------------------------------------------------------Calc
; l0 = 1/m1$
?------------------------------------------------------------? Maximum likelihood estimation. Results are shown.
?------------------------------------------------------------Maximize
; fcn=p*log(l)-lgm(p)-l*y+(p-1)*log(y)
; labels=p,l ; start = 1,l0$
15
/*
Normal exit from iterations. Exit status=0.
+---------------------------------------------+
| User Defined Optimization
|
| Number of observations
20
|
| Iterations completed
6
|
| Log likelihood function
-85.37567
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |
+---------+--------------+----------------+--------+---------+
P
2.410601626
.87682554
2.749
.0060
L
.7707018675E-01 .27077098E-01
2.846
.0044
*/
?------------------------------------------------------------? Alternative estimators using the method of moments.
? Just finding solution to two equations, so set sample to 1.
?------------------------------------------------------------?
Sample ; 1 $
?
?------------------------------------------------------------? Based on m1 and m2. Note, equations are m1=P/l = 0 and
? m2=P(P+1)/l^2 = 0. But, the solution is the same for
? l*m1 - P = 0 and l*l*m2 - P(P+1) = 0. Also, the solutions
? are forced by minimizing the sum of squares. For two
? equations and two unknowns, this zeros exactly.
?------------------------------------------------------------?
Minimize ; fcn = (l*m1 - p)^2 + (l*l*m2 - p*(p+1))^2
; labels = p,l ; Start = 1,l0 $
/*
+---------------------------------------------+
| Iterations completed
81
|
| Log likelihood function
-.2122069E-14 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |
+---------+--------------+----------------+--------+---------+
P
2.056818141
1.0000000
2.057
.0397
L
.6575925992E-01 1.0000000
.066
.9476
*/
?------------------------------------------------------------? Based on m_1 and m2
?------------------------------------------------------------?
Minimize ; fcn = ((p-1)*m_1 - l)^2 + (l*l*m2 - p*(p+1))^2
; labels = p,l ; Start = 1,l0 $
/*
+---------------------------------------------+
| Number of observations
1
|
| Iterations completed
11
|
| Log likelihood function
-.9040069E-09 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |
+---------+--------------+----------------+--------+---------+
P
2.607765493
1.0000000
2.608
.0091
L
.8044102328E-01 1.0000000
.080
.9359
*/
?-------------------------------------------------------------
16
? Based on m1 and m*
?------------------------------------------------------------?
Minimize ; fcn = (l*m1 - P)^2 + (mstar - (psi(p)-log(l)))^2
; labels = p,l ; Start = 1,l0 $
/*
+---------------------------------------------+
| Number of observations
1
|
| Iterations completed
9
|
| Log likelihood function
-.4243523E-12 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |
+---------+--------------+----------------+--------+---------+
P
2.410597740
1.0000000
2.411
.0159
L
.7707008485E-01 1.0000000
.077
.9386
*/
?------------------------------------------------------------? Based on m2 and m*
?------------------------------------------------------------?
Minimize ; fcn = (l*l*m2 - P*(P+1))^2 + (mstar - (psi(p)-log(l)))^2
; labels = p,l ; Start = 1,l0 $
/*
+---------------------------------------------+
| Number of observations
1
|
| Iterations completed
10
|
| Log likelihood function
-.1754566E-10 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |
+---------+--------------+----------------+--------+---------+
P
2.264470105
1.0000000
2.264
.0235
L
.7130398476E-01 1.0000000
.071
.9432
*/
?------------------------------------------------------------? Based on m_1 and m*
?------------------------------------------------------------?
Mini ; fcn = ((p-1)*m_1 - l)^2 + (mstar - (psi(p)-log(l)))^2
; labels = p,l ; Start = 1,l0 $
/*
+---------------------------------------------+
| Number of observations
1
|
| Iterations completed
11
|
| Log likelihood function
-.2031249E-12 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |
+---------+--------------+----------------+--------+---------+
P
3.035841208
1.0000000
3.036
.0024
L
.1018203332
1.0000000
.102
.9189
*/
17
18
/*==================================================================
Example 4.27. Characterizing normality of a distribution
No computations, but here is how they could be applied. We use the data from
table 4.1
*/==================================================================
Read ; Nobs=20 ; Nvar=3 ; Names=
I,
Y,
E $
1
20.5
12
2
31.5
16
3
47.7
18
4
26.2
16
5
44.0
12
6
8.28
12
7
30.8
16
8
17.2
12
9
19.9
10
10
9.96
12
11
55.8
16
12
25.2
20
13
29.0
12
14
85.5
16
15
15.1
10
16
28.5
18
17
21.4
16
18
17.7
20
19
6.42
12
20
84.9
16
Create ; d = y - Xbr(y)
; m2 = d^2 ; m3 = d^3 ; m4 = d^4 ; m5 = d^5
; m6 = d^6 ; m7 = d^7 ; m8 = d^8$
Calc
; mu2 = Xbr(m2) ; mu3 = Xbr(m3) ; mu4 = Xbr(m4)
; mu5 = Xbr(m5) ; mu6 = Xbr(m6) ; mu7 = Xbr(m7)
; mu8 = Xbr(m8) $
Calc
; Theta1 = Mu3 / Mu2^(1.5)
; Theta2 = Mu4 / Mu2^2 -3$
Names ; M = m2,m3,m4 $
Matrix ; V = 1/n* XVCM(M) $
Calc
; j11 = -1.5 / mu2^2.5 * mu3
; j12 = mu2^(-1.5)
; j21 = -2/mu2^3 * mu4
; j23 = mu2^(-2) $
Matrix ; J = [j11,j12,0 / j21,0,j23]
; Vart = J * V * J'
; Theta12 = [Theta1 / Theta2]
; Stat(Theta12,Vart)$
/*
Matrix statistical results: Coefficients=TH2
Variance=VART
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
TH2 _ 1 1.368929905
.36055351
3.797
.0001
TH2 _ 2 1.071718598
.90811548
1.180
.2379
*/
19
/*==================================================================
Example 4.28. Confidence Intervals for the Normal Mean.
For N[mu,sigma^2]
*/==================================================================
?
? Data and sample set up in variable named X.
?
Proc = CI(x,sig) $
Calc ; xbar = Xbr(x)
; sdev = Sdv(x) $
Calc ; list ; z = ttb(sig,(n-1))
; Lower = xbar - z*sdev/sqr(n)
; Upper = xbar + z*sdev/sqr(n) $
Calc ; list ; c1 = ctb(sig,(n-1))
; c2 = ctb((1-sig),(n-1))
; Lower = sqr(n-1)*sdev/c1
; Upper = sqr(n-1)*sdev/c2 $
EndProc
?
? We now execute our procedure for the income data of the
? previous examples.
?
Exec;proc=ci(y,.95)$
/*
Z
= .17291328084071510D+01
LOWER
= .22626476765584580D+02
UPPER
= .39929523234415430D+02
C1
= .30143527215110020D+02
C2
= .10117013148930000D+02
LOWER
= .32356531161353670D+01
UPPER
= .96405921717317770D+01
*/
/*==================================================================
Example 4.29. Estimated Confidence Intervals for A Normal Mean.
No computation required.
*/==================================================================
/*==================================================================
Example 4.30. Confidence Intervals for A Normal Variance
No computation required.
*/==================================================================
20
/*==================================================================
Example 4.31. Power Function for a Test about a Mean
We compute the power function for a test based on the
results in Example 4.19. Sampling 25 observations from
the normal distribution, we obtain xbar=1.63 and s=1.51.
The test is H0:mu = 1.5. The hypothesis will be rejected
if the t-ratio, sqr(n)*(xbar-1.5)/s is > 2.064.
*/==================================================================
?
? The t statistic is shown first.
?
Calc list ; tstat=sqr(25)*(1.63-1.5)/.51$
?
? Now, compute and plot the power function.
?
? A grid of values for mu. We use .5 to 2.5, steps of .02
?
Sample ; 1-100$
Create ; mu=trn(.5,.02)$
Create ; pwr=0$
?
? We'll use the calc function for the t-table, in a loop
?
Proc $
Sample ; i$
? In the loop, Prob|t| > 2.064 if mu = mui equals
?
Prob|t*| > 2.064 - sqr(n)(mu-1.5)/s
?
Calc
; upper = 2.064-sqr(25)*(mui-1.5)/.51
; lower = -2.064-sqr(25)*(mui-1.5)/.51
; mui=mui+.02
; power = 1-tds(upper,24) + tds(lower,24)$
? Computed for this one observation, then put in the data.
Create ; pwr=power$
endproc
? Start the loop, then produce 100 values.
Calc
; mui=.5$
Exec
; i=1,100$
Sample ; 1-100$
Plot
; lhs=mu;rhs=pwr;fill;Title=Power Function for t test$
Power Function for t test
1.2
1.0
PW R
.8
.6
.4
.2
.0
MU
/*==================================================================
Example 4.32. Consistent Test About a Mean.
21
No computations done.
*/==================================================================
/*==================================================================
Example 4.33. Testing a Hypothesis about a Mean with a Confidence
Interval.
No computations done.
*/==================================================================
/*==================================================================
Example 4.34. One Sided Test About a Mean
No computations done.
*/==================================================================
/*==================================================================
Example 4.35. Wald Test for a Restriction
No computations done.
*/==================================================================
/*==================================================================
Example 4.36. Testing a Hypothesis About a Mean
No computations done.
*/==================================================================
/*===================================================
Section 4.9.4. Example of Various Test Procedures.
*/===================================================
Read ; Nobs = 20 ; Nvar = 3 ; Names = I,Y,E$
1
20.5
12
2
31.5
16
3
47.7
18
4
26.2
16
5
44.0
12
6
8.28
12
7
30.8
16
8
17.2
12
9
19.9
10
10
9.96
12
11
55.8
16
12
25.2
20
13
29.0
12
14
85.5
16
15
15.1
10
16
28.5
18
17
21.4
16
18
17.7
20
19
6.42
12
20
84.9
16
Sample;1-20$
?
? Just change name to be consistent with text
?
Create;x=e$
?
? Unrestricted maximum likelihood estimation.
?
22
23
/*
Matrix VH
*/
? 2. Expected Hessian. Compute variables and sum
?
Create ; ehbb=rml/(betaml+x)^2
; ehrr=psp(rml)
; ehbr=1/(betaml+x)$
Calc
; vehbb=sum(ehbb)
; vehrr=sum(ehrr)
; vehbr=sum(ehbr)$
Matrix ; list;evh=[vehbb/vehbr,vehrr];evh=<evh>$
/*
Matrix EVH
has 2 rows and 2 columns.
1
2
+---------------------------1| .4900316D+01 -.1472863D+01
2| -.1472863D+01 .5767540D+00
*/
? 3. BHHH estimator can be obtained using simple sums
?
Namelist ; G=gb,gr$
Matrix
; list ; VB = <G'G> $
/*
Matrix VB
has 2 rows and 2 columns.
1
2
+---------------------------1| .1337220D+02 -.4321743D+01
2| -.4321743D+01 .1537223D+01
*/
?--------------------------------------------------------? Testing procedures for the hypothesis RHO = 1.
?--------------------------------------------------------? 1. Form confidence interval
?
Calc ; list ; rholower=r-1.96*sqr(vh(2,2))
;rhoupper=r+1.96*sqr(vh(2,2))$
/*
RHOLOWER= .15941433617939830D+01
RHOUPPER= .47076493284860730D+01
*/
?
? 2. Likelihood ratio test requires restricted maximum
?
Note it's done by fixing RHO at the start value.
?
Maximize ; fcn=-r*log(beta+x)-log(gma(r))-y/(beta+x)+(r-1)*log(y)
; start=-5,1
; labels=beta,r
; fix=r$
Calc;list; lrtest=-2*(logl-lloglu)$
24
/*
+---------------------------------------------+
| User Defined Optimization
|
| Dependent variable
Function
|
| Number of observations
20
|
| Iterations completed
2
|
| Log likelihood function
-88.43626
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
BETA
15.60272448
.24174096E-02 6454.316
.0000
R
1.000000000
........(Fixed Parameter)........
LRTEST = .11040428574057930D+02
*/
? Wald test
? Recompute estimates, then use built-in Wald procedure.
? This uses the BHHH estimator for the VC matrix.
?
Maximize ; fcn=-r*log(beta+x)-log(gma(r))-y/(beta+x)+(r-1)*log(y)
; start=-5,1
; labels=beta,r$
Wald
; fn1=r-1$
/*
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
3.00955
|
| Prob. from Chi-squared[ 1] =
.08278
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) 2.150896345
1.2398481
1.735
.0828
*/
? Unfortunately, if the test is based on the Hessian, a different
? conclusion is reached. Using asymptotic results with 20
? observations can lead to this.
?
Calc ; List ; Waldtest=(rml-1)^2/VH(2,2)$
/*
WALDTEST= .73335066911316080D+01
*/
? LM Test. Compute gradient and Hessian using restricted values.
?
? These maximization results appear above.
?
Maximize ; fcn=-r*log(beta+x)-log(gma(r))-y/(beta+x)+(r-1)*log(y)
; start=-5,1
; labels=beta,r ; Fix = r $
Calc
; betaml=b(1);rml=b(2)$
Create
; gb=-rml/(betaml+x)+y/(betaml+x)^2
; gr=-log(betaml+x)-psi(rml)+log(y) $
Namelist ; G=gb,gr$
Matrix
; list ; lm=1'G*<G'G>*G'1$
/*
1| .1568679D+02
*/
25
26
/*
--> Calc
; List ; 10;3;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .10000000000000000D+02
Result = .30000000000000000D+01
VMEAN
= .22776773705592240D+00
VMEDIAN = .17605331923973410D+00
MND
= .77295108392155140D+00
--> Calc
; List ; 10;6;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .10000000000000000D+02
Result = .60000000000000000D+01
VMEAN
= .19460318324261890D+00
VMEDIAN = .17792811471082130D+00
MND
= .91431245751510570D+00
--> Calc
; List ; 10;10;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .10000000000000000D+02
Result = .10000000000000000D+02
VMEAN
= .13668025146327190D+00
VMEDIAN = .19708691312004350D+00
MND
= .14419560324924030D+01
--> Calc
; List ; 25;3;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .25000000000000000D+02
Result = .30000000000000000D+01
VMEAN
= .94318530651331700D-01
VMEDIAN = .61968114454716990D-01
MND
= .65700890404871950D+00
--> Calc
; List ; 25;6;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .25000000000000000D+02
Result = .60000000000000000D+01
VMEAN
= .51450736989300260D-01
VMEDIAN = .78848948688663210D-01
MND
= .15325134935396690D+01
--> Calc
; List ; 25;20;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .25000000000000000D+02
Result = .20000000000000000D+02
27
VMEAN
= .53514169743784310D-01
VMEDIAN = .68681800841004060D-01
MND
= .12834320549088120D+01
--> Calc
; List ; 100;3;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .10000000000000000D+03
Result = .30000000000000000D+01
VMEAN
= .29494182014539210D-01
VMEDIAN = .19603646167951140D-01
MND
= .66466146300607670D+00
--> Calc
; List ; 100;6;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .10000000000000000D+03
Result = .60000000000000000D+01
VMEAN
= .14990919512419500D-01
VMEDIAN = .18084504512921710D-01
MND
= .12063639257044430D+01
--> Calc
; List ; 100;10;Vmean ; Vmedian ; Mnd= VMedian/VMean $
Result = .10000000000000000D+03
Result = .10000000000000000D+02
VMEAN
= .11726483356199100D-01
VMEDIAN = .17747666776421600D-01
MND
= .15134688070860960D+01
*/
/*==================================================================
Example 5.4. Probabilities for a Discrete Choice Model
No computations done.
*/==================================================================
/*==================================================================
Example 5.5. The Bivariate Normal CDF
No computations done.
*/==================================================================
/*==================================================================
Example 5.6. Fractional Moments of the Truncated Normal
Distribution.
*/==================================================================
? This can be done elegantly using Geweke's method of Simulating a
? truncated distribution. When computation is cheap, brute force will
? suffice. Here, we estimate the expected value of z^.45 given
? z > 0 when the underlying distribution is normal with
? mean -.35 and standard deviation 1.179.
Rows
; 10000 $
Create ; z = Rnn(-.35,1.179) $
Reject ; z <= 0 $
Create ; zp = z^.45 $
Dstat ; Rhs = zp $
/*
The resulting subsample has 3867 observations, enough to estimate the
mean of a distribution with fair precision.
Descriptive Statistics
==============================================================================
=
Variable
Mean
Std.Dev.
Minimum
Maximum
Cases
-----------------------------------------------------------------------------ZP
.837394245 .338424255
.350684226E-01 1.78732350
3867
*/
/*==================================================================
Example 5.7. Mean of a Lognormal Distribution.
*/==================================================================
?
28
29
; Start = r0,beta0
; Alg = Method ; Output = 3 $
EndProc
Exec ; Proc = GammaMin(DFP,4,1)$
Exec ; Proc = GammaMin(Newton,4,1)$
Exec ; Proc = GammaMin(DFP,8,3)$
Exec ; Proc = GammaMin(Newton,8,3)$
Exec ; Proc = GammaMin(DFP,2,7)$
Exec ; Proc = GammaMin(Newton,2,7)$
/*
Results are as reported in the text. One example, the first trial with
the two different methods follows, with the third on using Netwon.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
First trial with DFP
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--> Exec ; Proc = GammaMin(DFP,4,1)$
Nonlinear Estimation of Model Parameters
Method=D/F/P ; Maximum iterations=100
Convergence criteria:gtHg
.1000D-05 chg.F
.0000D+00 max|dB|
.0000D+00
Nodes for quadrature: Laguerre=40;Hermite=20.
Replications for GHK simulator= 100
Start values:
.40000D+01
.10000D+01
1st derivs.
.25612D+00 -.10000D+01
Parameters:
.40000D+01
.10000D+01
Itr 1 F= .1792D+01 gtHg= .1032D+01 chg.F= .1792D+01 max|db|=
.1000D+01
1st derivs.
-.50064D-01
.46474D-01
Parameters:
.39165D+01
.13260D+01
Itr 2 F= .1644D+01 gtHg= .6831D-01 chg.F= .1475D+00 max|db|=
.3505D-01
1st derivs.
-.24433D-01 -.27472D-01
Parameters:
.39422D+01
.13022D+01
Itr 3 F= .1643D+01 gtHg= .3676D-01 chg.F= .1191D-02 max|db|=
.2110D-01
1st derivs.
-.45950D-01
.40884D-01
Parameters:
.39805D+01
.13452D+01
Itr 4 F= .1642D+01 gtHg= .6151D-01 chg.F= .1045D-02 max|db|=
.3039D-01
1st derivs.
-.45950D-01
.40884D-01
Parameters:
.39805D+01
.13452D+01
Itr 1 F= .1642D+01 gtHg= .6151D-01 chg.F= .1642D+01 max|db|=
.3039D-01
1st derivs.
-.22873D-01 -.25705D-01
Parameters:
.40047D+01
.13236D+01
Itr 2 F= .1641D+01 gtHg= .3003D-01 chg.F= .1003D-02 max|db|=
.7429D-02
1st derivs.
-.29678D-02
.80328D-02
Parameters:
.52166D+01
.17435D+01
Itr 3 F= .1623D+01 gtHg= .5550D-02 chg.F= .1762D-01 max|db|=
.2087D-02
1st derivs.
.28664D-04 -.74510D-04
Parameters:
.52315D+01
.17438D+01
Itr 4 F= .1623D+01 gtHg= .6290D-04 chg.F= .2087D-04 max|db|=
.3484D-04
1st derivs.
-.38532D-07
.94779D-06
Parameters:
.52313D+01
.17438D+01
Itr 5 F= .1623D+01 gtHg= .1848D-05 chg.F= .1989D-08 max|db|=
.2322D-05
1st derivs.
-.20931D-07
.56667D-07
Parameters:
.52313D+01
.17438D+01
Itr 6 F= .1623D+01 gtHg= .4556D-07 chg.F= .2325D-11 max|db|=
30
.2005D-07
* Converged
Normal exit from iterations. Exit status=0.
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
1
|
| Iterations completed
6
|
| Log likelihood function
-1.623390
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
R
5.231320409
1.0000000
5.231
.0000
BETA
1.743773508
1.0000000
1.744
.0812
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
First trial with Newton
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--> Exec ; Proc = GammaMin(Newton,4,1)$
Nonlinear Estimation of Model Parameters
Method=NEWTON; Maximum iterations=100
Convergence criteria:gtHg
.1000D-05 chg.F
.0000D+00 max|dB|
.0000D+00
Nodes for quadrature: Laguerre=40;Hermite=20.
Replications for GHK simulator= 100
Start values:
.40000D+01
.10000D+01
1st derivs.
.25612D+00 -.10000D+01
Parameters:
.40000D+01
.10000D+01
Itr 1 F= .1792D+01 gtHg= .5012D+00 chg.F= .1792D+01 max|db|=
.2030D+00
1st derivs.
.16474D-01 -.16874D+00
Parameters:
.38120D+01
.12030D+01
Itr 2 F= .1653D+01 gtHg= .2167D+00 chg.F= .1386D+00 max|db|=
.3112D+00
1st derivs.
.40035D-02 -.40076D-01
Parameters:
.47952D+01
.15773D+01
Itr 3 F= .1626D+01 gtHg= .6674D-01 chg.F= .2742D-01 max|db|=
.9545D-01
1st derivs.
.35301D-03 -.35036D-02
Parameters:
.51898D+01
.17279D+01
Itr 4 F= .1623D+01 gtHg= .6367D-02 chg.F= .2360D-02 max|db|=
.9095D-02
1st derivs.
.28057D-05 -.32759D-04
Parameters:
.52309D+01
.17436D+01
Itr 5 F= .1623D+01 gtHg= .6331D-04 chg.F= .2041D-04 max|db|=
.9067D-04
1st derivs.
-.42699D-08 -.14918D-07
Parameters:
.52313D+01
.17438D+01
Itr 6 F= .1623D+01 gtHg= .6725D-07 chg.F= .2004D-08 max|db|=
.9583D-07
* Converged
Normal exit from iterations. Exit status=0.
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
31
| Number of observations
1
|
| Iterations completed
6
|
| Log likelihood function
-1.623390
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
R
5.231320038
7.1712051
.729
.4657
BETA
1.743773343
2.5089255
.695
.4870
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Last trial with Newton
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Nonlinear Estimation of Model Parameters
Method=NEWTON; Maximum iterations=100
Convergence criteria:gtHg
.1000D-05 chg.F
.0000D+00 max|dB|
.0000D+00
Nodes for quadrature: Laguerre=40;Hermite=20.
Replications for GHK simulator= 100
Start values:
.20000D+01
.70000D+01
1st derivs.
-.25231D+01
.27143D+01
Parameters:
.20000D+01
.70000D+01
Itr 1 F= .1611D+02 gtHg= .2298D+02 chg.F= .1611D+02 max|db|=
.3441D+02
Obs.=
1 Cannot compute function:
Note: Iterations, fn not computable at crnt. trial estimate
Cannot compute function at current values. Exit status=4.
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
1
|
| Iterations completed
1
|
| Log likelihood function
.0000000
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
R
-47.82221823
1.0000000
-47.822
.0000
BETA
-233.8689728
1.0000000
-233.869
.0000
*/
32
/*==================================================================
Example 5.12. A Concentrated log likelihood function
*/==================================================================
?
? We plot the concentrated log likelihood, which suggests
? where the solution is. Then, we maximize it, and compute
? the other parameter residually. The full maximization
? over both parameters produces the same result.
?
Sample
; 1 $
Fplot
; Fcn = r*log(r/3) - lgm(r) - 1
; Start = 1
; Plot(r)
; Labels = r
; Pts = 100
; Limits = .05,10 $
Plot of User Defined Function
F u n c t io n
-1.5
-2.0
-2.5
-3.0
-3.5
-4.0
-4.5
.0
.2
.4
.6
.8
1.0
R (x10^01)
33
Calc
; List
; Beta = r/3 $
Maximize ; Fcn = r*log(bt)-lgm(r)-3*bt+r-1
; Labels = r,bt
; Start = 4,1 $
/*
BETA=.17437754344134900D+01
Normal exit from iterations. Exit status=0.
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
1
|
| Iterations completed
6
|
| Log likelihood function
-1.623390
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
R
5.231320513
1.0000000
5.231
.0000
BT
1.743773510
1.0000000
1.744
.0812
*/
34
/*==================================================================
Example 5.13 Maximum Likelihood Estimation
Program Code for Estimation of Harvey's Model
The data set for this model is 100 observations from Greene (1992)
Variables are:
Exp = Average monthly credit card expenditure
Age = Age in years+ 12ths of a year
Income = Income, divided by 10,000
OwnRent = individual owns (1) or rents (0) home
SelfEmpl = self employed (1=yes, 0=no)
*/==================================================================
?
? Initial Data Setup. Used for all examples
?
Read ; Nobs = 100 ; Nvar = 7 ; Names =
Derogs,Card,Age,Income,Exp,OwnRent,SelfEmpl $
0 1 38 4.52
124.98
1 0
0 1 33 2.42
9.85
0 0
0 1 34 4.50
15.00
1 0
0 1 31 2.54
137.87
0 0
0 1 32 9.79
546.50
1 0
0 1 23 2.50
92.00
0 0
0 1 28 3.96
40.83
0 0
0 1 29 2.37
150.79
1 0
0 1 37 3.80
777.82
1 0
0 1 28 3.20
52.58
0 0
0 1 31 3.95
256.66
1 0
0 0 42 1.98
0.00
1 0
0 0 30 1.73
0.00
1 0
0 1 29 2.45
78.87
1 0
0 1 35 1.91
42.62
1 0
0 1 41 3.20
335.43
1 0
0 1 40 4.00
248.72
1 0
7 0 30 3.00
0.00
1 0
0 1 40 10.00
548.03
1 1
3 0 46 3.40
0.00
0 0
0 1 35 2.35
43.34
1 0
1 0 25 1.88
0.00
0 0
0 1 34 2.00
218.52
1 0
1 1 36 4.00
170.64
0 0
0 1 43 5.14
37.58
1 0
0 1 30 4.51
502.20
0 0
0 0 22 3.84
0.00
0 1
0 1 22 1.50
73.18
0 0
0 0 34 2.50
0.00
1 0
0 1 40 5.50 1532.77
1 0
0 1 22 2.03
42.69
0 0
1 1 29 3.20
417.83
0 0
1 0 25 3.15
0.00
1 0
0 1 21 2.47
552.72
1 0
0 1 24 3.00
222.54
0 0
0 1 43 3.54
541.30
1 0
0 0 43 2.28
0.00
0 0
0 1 37 5.70
568.77
1 0
0 1 27 3.50
344.47
0 0
0 1 28 4.60
405.35
1 0
0 1 26 3.00
310.94
1 0
0 1 23 2.59
53.65
0 0
0 1 30 1.51
63.92
0 0
0 1 30 1.85
165.85
0 0
0 1 38 2.60
9.58
0 0
0 0 28 1.80
0.00
0 1
35
0 1
0 0
0 1
0 1
0 0
0 1
0 1
0 1
0 1
1 1
0 1
0 1
0 0
0 1
2 1
0 1
0 1
0 1
3 0
0 0
0 1
0 1
0 0
0 1
0 1
0 1
0 1
0 1
0 1
1 0
0 1
0 1
0 1
0 1
0 0
1 1
0 1
0 1
3 0
0 1
0 0
0 0
0 0
1 0
2 0
0 0
0 1
4 0
2 0
0 1
1 1
1 1
0 1
0 1
Create
Reject
36 2.00
319.49
38 3.26
0.00
26 2.35
83.08
28 7.00
644.83
50 3.60
0.00
24 2.00
93.20
21 1.70
105.04
24 2.80
34.13
26 2.40
41.19
33 3.00
169.89
34 4.80 1898.03
33 3.18
810.39
45 1.80
0.00
21 1.50
32.78
25 3.00
95.80
27 2.28
27.78
26 2.80
215.07
22 2.70
79.51
27 4.90
0.00
26 2.50
0.00
41 6.00
306.03
42 3.90
104.54
22 5.10
0.00
25 3.07
642.47
31 2.46
308.05
27 2.00
186.35
33 3.25
56.15
37 2.72
129.37
27 2.20
93.11
24 4.10
0.00
24 3.75
292.66
25 2.88
98.46
36 3.05
258.55
33 2.55
101.68
33 4.00
0.00
55 2.64
65.25
20 1.65
108.61
29 2.40
49.56
40 3.71
0.00
41 7.24
235.57
41 4.39
0.00
35 3.30
0.00
24 2.30
0.00
54 4.18
0.00
34 2.49
0.00
45 2.81
0.00
43 2.40
68.38
35 1.50
0.00
36 8.40
0.00
22 1.56
0.00
33 6.00
474.15
25 3.60
234.05
26 5.00
451.20
46 5.50
251.52
; y = Exp $
; Exp = 0 $
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
0
0
0
1
0
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
36
?
? Define variables in scedastic function
?
Namelist ; Z = One,Age,Income,OwnRent,SelfEmpl$
?
? Variables in deviations from means, hi used later.
?
Create
; y = y - Xbr(y) ; hi = log(y^2) $
?
? matrices that only need compute once, start values also.
?
Matrix
; ZZI = <Z'Z> ; gamma0 = ZZI * Z'hi ; H = 2*ZZI$
Calc
; c0 = gamma0(1)+1.2704 ; K = Col(Z)
; s20 = y'y/n ; delta = 1 ; iter=0 $
Create
; vi0 = (y^2 / s20 - 1) $
Matrix
; Gamma0(1) = c0
; Gamma
= Gamma0 $
?
? Computations in the iteration.
?
Procedure
Create
; vari = exp(Z'Gamma)
; vi = y^2 / vari - 1
; logli = -.5*(log(2*pi) + log(vari) + y^2/vari) $
?
? This is the iteration.
?
Matrix
; g = .5 * Z'vi ; update = H*g ; Gamma = Gamma + update $
?
? Display progress to solution
?
Calc
; list ; Iter = Iter+1 ; LoglU = Sum(logli)
; delta = g'update $
EndProc
?
? Do the estimation, with exit rule checked by the program
?
Execute ; While delta > .00001 $
?
? Display all results.
?
Matrix
; Stat (Gamma,H) $
/*
ITER
= .10000000000000000D+01
LOGLU
= -.51488159157020980D+03
DELTA
= .50216892265715530D+02
ITER
= .20000000000000000D+01
LOGLU
= -.50632062784012100D+03
DELTA
= .10110878618370730D+02
ITER
= .30000000000000000D+01
LOGLU
= -.50133108852306380D+03
DELTA
= .11384997784439750D+01
ITER
= .40000000000000000D+01
LOGLU
= -.50075807000005030D+03
DELTA
= .54612572364539240D-01
ITER
= .50000000000000000D+01
LOGLU
= -.50074068923265340D+03
DELTA
= .10654967586285280D-01
ITER
= .60000000000000000D+01
LOGLU
= -.50073784718162780D+03
DELTA
= .26491951233769230D-02
ITER
= .70000000000000000D+01
37
LOGLU
= -.50073714244356620D+03
DELTA
= .66467890235364090D-03
ITER
= .80000000000000000D+01
LOGLU
= -.50073696346889480D+03
DELTA
= .16586568129915330D-03
ITER
= .90000000000000000D+01
LOGLU
= -.50073691849030420D+03
DELTA
= .41471330270019660D-04
ITER
= .10000000000000000D+02
LOGLU
= -.50073690712118170D+03
DELTA
= .10359793062824090D-04
ITER
= .11000000000000000D+02
LOGLU
= -.50073690425106620D+03
DELTA
= .25907113319667200D-05
DELTA>.00001
Matrix statistical results: Coefficients=GAMMA
Variance=H
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
GAMMA_ 1 8.485631925
.83489674
10.164
.0000
GAMMA_ 2 .2030078669E-01 .27025653E-01
.751
.4526
GAMMA_ 3 .6713184878
.13026077
5.154
.0000
GAMMA_ 4 -.6084003442
.42520045
-1.431
.1525
GAMMA_ 5 -4.620293694
1.1792600
-3.918
.0001
*/
?
? Estimate of sigma-squared, plus a standard error for it.
?
Calc;List; Sigmasq = Exp(Gamma(1))
; SE = Sigmasq * Sqr(H(1,1)) $
/*
SIGMASQ = .48446579597521760D+04
SE
= .40447891203908600D+04
*/
?
? Test the hypothesis that coefficients are zero.
? 1. Likelihood ratio test
? 2. Wald test
? 3. LM test requires some computation
?
Calc
; list ; LogLR = -n/2*(1 + log(2*pi) + log(y'y/n))
; LRTest = -2*(LogLR - LogLU) $
Matrix
; Alpha = Gamma(2:K) ; Valpha = Part(H,2,K,2,K)
; List ; WaldTest = Alpha ' <VAlpha> Alpha $
Matrix
; list ; LMTest = .5* vi0'Z * <Z'Z> * Z'vi0 $
/*
LOGLR
= -.51653837177479360D+03
LRTEST = .31602935047454820D+02
Matrix WALDTEST has 1 rows and 1 columns.
1
+-------------1| .3332298D+02
Matrix LMTEST
1 columns.
*/
?
? Compute 3 different asymptotic covariance matrices
?
Create
; hi=y*y/exp(Z'gamma)
38
Matrix
;
;
;
;
;
vi=((hi-1)/2)^2$
List
Hessian = 2*<Z'[hi]Z>
EHessian= 2*<Z'Z>
BHHH
= <Z'[vi]Z> $
/*
Matrix HESSIAN
has
1
5 rows and
2
5 columns.
3
5 rows and
2
5 columns.
3
has
1
5 rows and
2
5 columns.
3
39
40
41
42
Namelist
; X = One,T,G,R,P $
Matrix;List ; XX = X'X
; Xy = X'y
; bb = <X'X>*X'y $
/*
Matrix XX
has 5 rows and 5 columns.
1
2
3
4
5
+---------------------------------------------------------------------1| .1500000D+02 .1200000D+03 .1931000D+02 .1117900D+03 .9977000D+02
2| .1200000D+03 .1240000D+04 .1643000D+03 .1035930D+04 .8756000D+03
3| .1931000D+02 .1643000D+03 .2521802D+02 .1489838D+03 .1312163D+03
4| .1117900D+03 .1035930D+04 .1489838D+03 .9438557D+03 .7990186D+03
5| .9977000D+02 .8756000D+03 .1312163D+03 .7990186D+03 .7166685D+03
Matrix XY
has 5 rows and 1 columns.
1
+-------------1| .3050000D+01
2| .2600400D+02
3| .3992563D+01
4| .2352069D+02
5| .2073158D+02
Matrix BB
has 5 rows and 1 columns.
1
+-------------1| -.5090708D+00
2| -.1658039D-01
3| .6703834D+00
4| -.2325928D-02
5| -.9401070D-04
*/
43
/*==================================================================
Example 6.9. Deviations from Means - Regression ona Constant.
We illustrate this with the first regression in Example 6.8.
*/==================================================================
Read ; Nobs = 15 ; Nvar = 5 ; Names = Y,T,G,R,P $
0.161 1 1.058 5.16 4.40
0.172 2 1.088 5.87 5.15
0.158 3 1.086 5.95 5.37
0.173 4 1.122 4.88 4.99
0.195 5 1.186 4.50 4.16
0.217 6 1.254 6.44 5.75
0.199 7 1.246 7.83 8.82
0.163 8 1.232 6.25 9.31
0.195 9 1.298 5.50 5.21
0.231 10 1.370 5.46 5.83
0.257 11 1.439 7.46 7.40
0.259 12 1.479 10.28 8.64
0.225 13 1.474 11.77 9.31
0.241 14 1.503 13.42 9.44
0.204 15 1.475 11.02 5.99
?
? Create deviations from means. (Not the most efficient
? way to do this, but it works fine.)
?
Calc ; List ; Yb = Xbr(Y)
; Tb = Xbr(T)
; Gb = Xbr(G) $
Create
; dy = y - yb
; dt = t - tb
; dg = g - gb $
?
? Two regressions. (Only coefficients are shown)
? 1. Including constant term.
Regress
; Lhs = Y ; Rhs = One,T,G $
/*
Constant -.5006389672
T
-.1719843909E-01
G
.6537233143
*/
?
? 2. Deviations, without constant term. Same results.
Regress
; Lhs = dy ; Rhs = dt,dg $
/*
DT
-.1719843909E-01
DG
.6537233143
*/
?
? What if Y is not transformed? No problem. Y need not
? be transformed.
?
Regress
; Lhs = Y ; Rhs = dt,dg $
/*
DT
-.1719843909E-01
DG
.6537233143
*/
/*==================================================================
Example 6.10. Partial Correlations
*/==================================================================
44
45
/*==================================================================
Example 6.11. Fit of a Consumption Function
*/==================================================================
Read ; Nobs = 11 ; Nvar = 3 ; Names = Year,X,C $
1940
241 226
1941
280 240
1942
319 235
1943
331 245
1944
345 255
1945
340 265
1946
332 295
1947
320 300
1948
339 305
1949
338 315
1950
371 325
Sample ; 1 - 11 $
Calc ; List ; yb = Xbr(C)
; xb = Xbr(X)
; Sxx = (N-1)*Var(X)
; Syy = (N-1)*Var(C)
; Sxy = (N-1)*Cov(X,C)
; SST = Syy
; slope = Sxy/Sxx
; SSR = slope^2 * Sxx
; SSE = SST - SSR
; Rsq = slope^2 * Sxx / SST $
/*
YB
= .27327272727272730D+03
XB
= .32327272727272730D+03
SXX
= .12300181818181820D+05
SYY
= .12618181818181820D+05
SXY
= .84231818181818160D+04
SST
= .12618181818181820D+05
SLOPE
= .68480140722236160D+00
SSR
= .57682067623807180D+04
SSE
= .68499750558011020D+04
RSQ
= .45713454168723260D+00
*/
Sample ; 1,2,7-11$
Calc
; ... exactly as above $
/*
YB
= .28657142857142860D+03
XB
= .31728571428571430D+03
SXX
= .11219428571428570D+05
SYY
= .87137142857142860D+04
SXY
= .95708571428571430D+04
SST
= .87137142857142860D+04
SLOPE
= .85306101660385040D+00
SSR
= .81645251240559370D+04
SSE
= .54918916165834890D+03
RSQ
= .93697416008249000D+00
*/
46
/*====================================================
Example 6.12. Analysis of Variance for an Investment Equation
*/====================================================
Read ; Nobs = 15 ; Nvar = 5 ; Names = Y,T,G,R,P $
0.161 1 1.058 5.16 4.40
0.172 2 1.088 5.87 5.15
0.158 3 1.086 5.95 5.37
0.173 4 1.122 4.88 4.99
0.195 5 1.186 4.50 4.16
0.217 6 1.254 6.44 5.75
0.199 7 1.246 7.83 8.82
0.163 8 1.232 6.25 9.31
0.195 9 1.298 5.50 5.21
0.231 10 1.370 5.46 5.83
0.257 11 1.439 7.46 7.40
0.259 12 1.479 10.28 8.64
0.225 13 1.474 11.77 9.31
0.241 14 1.503 13.42 9.44
0.204 15 1.475 11.02 5.99
?
Sample;1-15$
Namelist ; X = One,T,G,R,P $
Calc
; Yb = Xbr(y) $
Matrix
; bb = <X'X> * X'y
; Xy = X'y $
Calc ; List ; RegSS = bb'Xy - n*Yb^2
; TotSS = y'y
- n*Yb^2
; ResSS = TotSS - RegSS
; DFReg = Col(X) - 1
; DFRes = n - Col(X)
; DFTot = n - 1
; MSReg = RegSS / DFReg
; MSRes = ResSS / DFRes
; MSTot = TotSS / DFTot
; Rsq
= 1 - ResSS/TotSS $
/*
REGSS
= .15902521532841770D-01
TOTSS
= .16353333333333110D-01
RESSS
= .45081180049133530D-03
DFREG
= .40000000000000000D+01
DFRES
= .10000000000000000D+02
DFTOT
= .14000000000000000D+02
MSREG
= .39756303832104430D-02
MSRES
= .45081180049133530D-04
MSTOT
= .11680952380952220D-02
RSQ
= .97243303299074560D+00
*/
/*==================================================================
Example 6.13. Sampling Variance in the Two Variable Regression Model
No computations done.
*/==================================================================
47
/*==================================================================
Example 6.14. Investment Equation
*/==================================================================
Read ; Nobs = 15 ; Nvar = 5 ; Names = Y,T,G,R,P $
0.161 1 1.058 5.16 4.40
0.172 2 1.088 5.87 5.15
0.158 3 1.086 5.95 5.37
0.173 4 1.122 4.88 4.99
0.195 5 1.186 4.50 4.16
0.217 6 1.254 6.44 5.75
0.199 7 1.246 7.83 8.82
0.163 8 1.232 6.25 9.31
0.195 9 1.298 5.50 5.21
0.231 10 1.370 5.46 5.83
0.257 11 1.439 7.46 7.40
0.259 12 1.479 10.28 8.64
0.225 13 1.474 11.77 9.31
0.241 14 1.503 13.42 9.44
0.204 15 1.475 11.02 5.99
?
? Standard Regression Results
?
Namelist ; X = One,T,G,R,P $
Matrix
; bb = <X'X> * X'y
; ee = y'y - bb' * X'X * bb $
Calc ;List; s2 = ee/(n - Col(X)) $
Matrix
; List ; Var = s2 * <X'X>
; Stat (bb,Var) $
/*
S2
= .45081180048978100D-04
Matrix VAR
has 5 rows and 5 columns.
1
2
3
4
5
+---------------------------------------------------------------------1| .3039062D-02 .1023405D-03 -.3010234D-02 .5599212D-05 -.3207697D-05
2| .1023405D-03 .3887842D-05 -.1017688D-03 -.2884571D-06 -.4257379D-07
3| -.3010234D-02 -.1017688D-03 .3024694D-02 -.7278842D-05 -.2278947D-05
4| .5599212D-05 -.2884571D-06 -.7278842D-05 .1485638D-05 -.7507108D-06
5| -.3207697D-05 -.4257379D-07 -.2278947D-05 -.7507108D-06 .1815703D-05
Matrix statistical results: Coefficients=BB
Variance=VAR
+---------+--------------+----------------+--------+---------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |
+---------+--------------+----------------+--------+---------+
BB
_ 1 -.5090707909
.55127690E-01
-9.234
.0000
BB
_ 2 -.1658039448E-01 .19717611E-02
-8.409
.0000
BB
_ 3 .6703834376
.54997215E-01
12.189
.0000
BB
_ 4 -.2325928344E-02 .12188677E-02
-1.908
.0564
BB
_ 5 -.9401070242E-04 .13474804E-02
-.070
.9444
*/
48
/*==================================================================
Example 6.15. Confidence Interval for the Income
Elasticity of Demand for Gasoline.
*/==================================================================
Read ; Nobs = 36 ; Nvar = 11
; Names =
Year, G,
Pg,
Y,
Pnc,
Puc,
Ppt,
Pd,
Pn,
Ps,
Pop $
<... Data appear in Example 6.3 ...>
?
Create
; lg = Log(100*G/Pop)
; li = Log(Y)
; lpg= Log(Pg)
; lpnc = Log(Pnc)
; lpuc = log(Puc) $
Namelist ; X = One,lpg,li,lpnc,lpuc $
Regress ; Lhs = lg ; Rhs = X $
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -7.736670352
.67489471
-11.464
.0000
LPG
-.5909513203E-01 .32484958E-01
-1.819
.0786 .67409433
LI
1.373399117
.75627675E-01
18.160
.0000 9.1109277
LPNC
-.1267966682
.12699351
-.998
.3258 .44319821
LPUC
-.1187084716
.81337098E-01
-1.459
.1545 .66361224
*/
Wald ; Fn1 = B_li - 1 $
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .3733991166
.75627675E-01
4.937
.0000
*/
/*==================================================================
Example 6.16. Confidence Interval for a Linear Combination of
Coefficients - The Oaxaca Decomposition. This shows the application
to the gasoline demand model of Example 6.15 for the pre- and post1973 embargo. Regression results appear in Example 7.8 and Table 7.3.
*/==================================================================
Read ; Nobs = 36 ; Nvar = 11
; Names =
Year, G,
Pg,
Y,
Pnc,
Puc,
Ppt,
Pd,
Pn,
Ps,
Pop $
<... Data appear in Example 6.3 ...>
?
Create ; lg = Log(100*G/Pop)
; li = Log(Y)
; lpg= Log(Pg)
; lpnc = Log(Pnc)
; lpuc = log(Puc) $
Namelist ; X = One,lpg,li,lpnc,lpuc $
?
? Set first period = post embargo and collect results.
?
Include ; New ; Year > 1973 $ (Post embargo)
Regress ; Lhs = LG ; Rhs = X $
Matrix
; Bpost = b ; Vpost = Varb ; Xpost = Mean(X) $
Calc
; Npost = N ; Ybarpost=ybar$
?
? Set second period = pre embargo. Get same results.
?
Include ; New ; Year <= 1973 $ (Pre embargo)
49
*/
/*==================================================================
Example 6.17. Confidence Interval for sigma squared.
No computations done.
*/==================================================================
50
/*==================================================================
Example 6.18. F Test for the Investment Equation
*/==================================================================
Read ; Nobs = 15 ; Nvar = 5 ; Names = Y,T,G,R,P $
<... Data appear in Example 6.14 ...>
Namelist ; X = One,T,G,R,P $
?
? Test the hypothesis that the last four coefficients
? are zero. There are many ways to do this.
?
Regress
; Lhs = y ; Rhs = X $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = Y
Mean=
.2033333333
, S.D.=
.3417740830E-01 |
| Model size: Observations =
15, Parameters =
5, Deg.Fr.=
10 |
| Residuals: Sum of squares= .4508118005E-03, Std.Dev.=
.00671 |
| Fit:
R-squared= .972433, Adjusted R-squared =
.96141 |
| Model test: F[ 4,
10] =
88.19,
Prob value =
.00000 |
| Diagnostic: Log-L =
56.8098, Restricted(b=0) Log-L =
29.8762 |
|
LogAmemiyaPrCrt.=
-9.719, Akaike Info. Crt.=
-6.908 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -.5090707909
.55127690E-01
-9.234
.0000
T
-.1658039448E-01 .19717611E-02
-8.409
.0000 8.0000000
G
.6703834376
.54997215E-01
12.189
.0000 1.2873333
R
-.2325928344E-02 .12188677E-02
-1.908
.0854 7.4526667
P
-.9401070242E-04 .13474804E-02
-.070
.9458 6.6513333
*/
Calc ; List ; F = (Rsqrd/(Col(X)-1)) / ((1-Rsqrd)/(n-Col(X))) $
/*
F
= .88188250148830110D+02
*/
Regress ; Lhs = y ; Rhs = X
; Cls: b(2)=0, b(3)=0, b(4)=0, b(5)=0 $
/*
+-----------------------------------------------------------------------+
| Linearly restricted regression
|
| Dep. var. = Y
Mean=
.2033333333
, S.D.=
.3417740830E-01 |
| Model size: Observations =
15, Parameters =
1, Deg.Fr.=
14 |
| Residuals: Sum of squares= .1635333333E-01, Std.Dev.=
.03418 |
| Fit:
R-squared= .000000, Adjusted R-squared =
.00000 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Diagnostic: Log-L =
29.8762, Restricted(b=0) Log-L =
29.8762 |
|
LogAmemiyaPrCrt.=
-6.688, Akaike Info. Crt.=
-3.850 |
| Note, when restrictions are imposed, R-squared can be less than zero. |
| F[ 4,
10] for the restrictions =
88.1883, Prob =
.0000
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .2033333333
.88245689E-02
23.042
.0000
T
-.3122502257E-16 .42828688E-09
.000 1.0000 8.0000000
G
.5551115123E-15........(Fixed Parameter)........ 1.2873333
R
.0000000000
........(Fixed Parameter)........ 7.4526667
P
-.5407458335E-17........(Fixed Parameter)........ 6.6513333
*/
/*==================================================================
Example 6.19. Multicollinearity in the Longley Data
*/==================================================================
51
*/
52
53
54
.90
.82
B2
.73
.64
.56
.47
-.025
-.020
-.015
-.010
B1
? ---------------------------------------------------------------------? Example 7.17. Forecast for Investment
? ---------------------------------------------------------------------Matrix
; x0 = [1/16/1.5/10/4] $
Calc ;List ; y0 = x0 ' bb
; s0 = sqr(ss + qfr(x0,Vb))
; upper = y0 + 2.228 * s0
; lower = y0 - 2.228 * s0 $
/*
Y0
= .20758272743002830D+00
S0
= .10232227264123570D-01
UPPER
= .23038012977449560D+00
LOWER
= .18478532508556100D+00
*/
55
.27
V a r ia b l e
.25
Y
YFGNP
YFNOGNP
.22
.20
.17
.15
1967 1969 1971 1973 1975 1977 1979 1981 1983
Year
56
/*==================================================================
Example 7.2. Reparameterizing a Restriction
Results are contained in Ex7_1.lim
*/==================================================================
/*==================================================================
Example 7.3. Restricted Investment Equation
Results are contained in Ex7_1.lim
*/==================================================================
/*==================================================================
Example 7.4. Joint Confidence Region
Results are contained in Ex7_1.lim
*/==================================================================
/*==================================================================
Examples 7.5, 7.6, 7.7. Production Functions
*/==================================================================
Read ; Nobs = 27 ; Nvar = 4 ; Names = 1 $
Obs
ValueAdd
Labor
Capital
1
657.29
162.31
279.99
2
935.93
214.43
542.50
3
1110.65
186.44
721.51
4
1200.89
245.83
1167.68
5
1052.68
211.40
811.77
6
3406.02
690.61
4558.02
7
2427.89
452.79
3069.91
8
4257.46
714.20
5585.01
9
1625.19
320.54
1618.75
10
1272.05
253.17
1562.08
11
1004.45
236.44
662.04
12
598.87
140.73
875.37
13
853.10
145.04
1696.98
14
1165.63
240.27
1078.79
15
1917.55
536.73
2109.34
16
9849.17
1564.83
13989.55
17
1088.27
214.62
884.24
18
8095.63
1083.10
9119.70
19
3175.39
521.74
5686.99
20
1653.38
304.85
1701.06
21
5159.31
835.69
5206.36
22
3378.40
284.00
3288.72
23
592.85
150.77
357.32
24
1601.98
259.91
2031.93
25
2065.85
497.60
2492.98
26
2293.87
275.20
1711.74
27
745.67
137.00
768.59
?
? Set up loglinear production function
?
Create ; lq = Log(Valueadd) ; ll = Log(Labor) ; lk = Log(capital) $
57
58
+---------+--------------+----------------+--------+---------+----------+
Constant .9441968543
2.9107537
.324
.7489
LL
3.613638942
1.5480727
2.334
.0296 5.7636521
LK
-1.893112914
1.0162611
-1.863
.0765 7.4459224
LLL
-.9640522102
.70738483
-1.363
.1874 16.817193
LKK
.8529466466E-01 .29260898
.291
.7735 28.172489
LLLK
.3123870410
.43892721
.712
.4845 43.463191
F
*/
.17677551205521390D+01
/*==================================================================
Example 7.6. Constant Returns to Scale
Results are contained in Ex7_5.lim
*/==================================================================
/*==================================================================
Example 7.7. Translog Production Function
Results are contained in Ex7_5.lim
*/==================================================================
/*==================================================================
Examples 7.8 to 7.13. The U.S. Gasoline Market
*/==================================================================
Read ; Nobs = 36 ; Nvar = 11 ; Names =
Year, G,
Pg,
Y,
Pnc,
Puc,
Ppt,
Pd,
Pn,
Ps,
Pop $
<... Data appear in Example 6.3 ...>
Create ; lg = Log(100*G/Pop)
; li = Log(Y)
; lpg= Log(Pg)
; lpnc = Log(Pnc)
; lpuc = log(Puc) $
? ---------------------------------------------------------------------? Example 7.8. Separate Regressions
? ---------------------------------------------------------------------Namelist ; X = One,li,lpg,lpnc,lpuc,year $
Sample ; 1 - 36 $
Regress; Lhs = lg ; Rhs = X $
Calc
; ee = sumsqdev $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.601461580
, S.D.=
.1516908508
|
| Model size: Observations =
36, Parameters =
6, Deg.Fr.=
30 |
| Residuals: Sum of squares= .2518777147E-01, Std.Dev.=
.02898 |
| Fit:
R-squared= .968725, Adjusted R-squared =
.96351 |
| Model test: F[ 5,
30] = 185.84,
Prob value =
.00000 |
| Diagnostic: Log-L =
79.6867, Restricted(b=0) Log-L =
17.3181 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 24.67179089
10.114642
2.439
.0208
LI
1.954625536
.19285427
10.135
.0000 9.1109277
LPG
-.1155296916
.33479492E-01
-3.451
.0017 .67409433
LPNC
.2052822304
.15201946
1.350
.1870 .44319821
LPUC
-.1292742276
.71411834E-01
-1.810
.0803 .66361224
YEAR
-.1911812699E-01 .59565192E-02
-3.210
.0032 1977.5000
*/
Sample ; 1 - 14 $
Regress; Lhs = lg ; Rhs = X $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
59
| Dep. var. = LG
Mean=
4.466873655
, S.D.=
.1597154523
|
| Model size: Observations =
14, Parameters =
6, Deg.Fr.=
8 |
| Residuals: Sum of squares= .6522709075E-03, Std.Dev.=
.00903 |
| Fit:
R-squared= .998033, Adjusted R-squared =
.99680 |
| Model test: F[ 5,
8] = 811.85,
Prob value =
.00000 |
| Diagnostic: Log-L =
49.9536, Restricted(b=0) Log-L =
6.3347 |
|
LogAmemiyaPrCrt.=
-9.058, Akaike Info. Crt.=
-6.279 |
| Autocorrel: Durbin-Watson Statistic =
2.39104,
Rho =
-.19552 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -51.18115395
18.049912
-2.836
.0220
LI
.4239945140
.35177772
1.205
.2625 8.8955658
LPG
.9454665245E-01 .15051077
.628
.5474 -.68297549E-02
LPNC
.5838963403
.13149307
4.441
.0022 .47207784E-01
LPUC
-.3346187867
.92326477E-01
-3.624
.0067 .72121949E-03
YEAR
.2636647807E-01 .10690348E-01
2.466
.0389 1966.5000
*/
Calc
; ee0 = sumsqdev $
Sample ; 15 - 36 $
Regress; Lhs = lg ; Rhs = X $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.687108442
, S.D.=
.5289858199E-01 |
| Model size: Observations =
22, Parameters =
6, Deg.Fr.=
16 |
| Residuals: Sum of squares= .4662163324E-02, Std.Dev.=
.01707 |
| Fit:
R-squared= .920662, Adjusted R-squared =
.89587 |
| Model test: F[ 5,
16] =
37.13,
Prob value =
.00000 |
| Diagnostic: Log-L =
61.8359, Restricted(b=0) Log-L =
33.9614 |
|
LogAmemiyaPrCrt.=
-7.900, Akaike Info. Crt.=
-5.076 |
| Autocorrel: Durbin-Watson Statistic =
1.42205,
Rho =
.28898 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 20.44635142
6.8393649
2.990
.0087
LI
1.014076422
.28568584
3.550
.0027 9.2479762
LPG
-.2423735704
.40029664E-01
-6.055
.0000 1.1074097
LPNC
.3301675679
.18111744
1.823
.0871 .69519211
LPUC
-.5537415036E-01 .50773921E-01
-1.091
.2916 1.0854520
YEAR
-.1261698901E-01 .37735594E-02
-3.344
.0041 1984.5000
*/
Calc
Calc
/*
; ee1 = sumsqdev $
; List ; F = ((ee - ee0 - ee1)/6) / ((ee0+ee1)/24) $
F
.14958007848150170D+02
*/
60
61
? ---------------------------------------------------------------------Sample ; 1-14,17-20,23-36$
Regress; Lhs = lg ; Rhs = X $
Calc
; List ; F = ((ee-sumsqdev)/4) / (sumsqdev/26) $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.597746553
, S.D.=
.1601823575
|
| Model size: Observations =
32, Parameters =
6, Deg.Fr.=
26 |
| Residuals: Sum of squares= .1968599131E-01, Std.Dev.=
.02752 |
| Fit:
R-squared= .975251, Adjusted R-squared =
.97049 |
| Model test: F[ 5,
26] = 204.91,
Prob value =
.00000 |
| Diagnostic: Log-L =
72.8913, Restricted(b=0) Log-L =
13.7081 |
|
LogAmemiyaPrCrt.=
-7.014, Akaike Info. Crt.=
-4.181 |
| Autocorrel: Durbin-Watson Statistic =
1.06405,
Rho =
.46798 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 27.46893260
10.228911
2.685
.0124
LI
1.999881259
.18827701
10.622
.0000 9.1073579
LPG
-.6707231764E-01 .46024417E-01
-1.457
.1570 .64198804
LPNC
.3338620907
.15487335
2.156
.0405 .44760441
LPUC
-.2355018723
.84892005E-01
-2.774
.0101 .67589832
YEAR
-.2074944302E-01 .59935678E-02
-3.462
.0019 1977.5000
F
= .18165999605094310D+01
*/
? ---------------------------------------------------------------------? Example 7.12. Wald Test for Structural Change
? ---------------------------------------------------------------------Sample ; 1 - 14 $
Regress ; Lhs = lg ; Rhs = X $
Matrix ; b1 = b ; V1 = Varb $
Sample ; 15-36 $
Regress ; Lhs = lg ; Rhs = X $
Matrix ; b2 = b ; V2 = Varb $
Matrix ; d = b1 - b2 ; V = V1 + V2
; List ; WaldTest = d'*<V>*d $
/*
Matrix WALDTEST has 1 rows and 1 columns.
1
+-------------1| .1286673D+03
*/
62
Cusum (x10^01)
1.3
.7
1.0
-.1
.7
usumSqd
-.9
.4
-1.7
.1
-2.5
16
24
32
40
Observ.#
Create
Calc
Matrix
;
;
;
;
;
-.2
16
24
32
40
Observ.#
vt=et*et-sumsqdev/n$
K = Col(X) + 1 ; Nobs = n $
ff=init(k,k,0)
st=[k|0]
ss=ff$
Procedure
Sample
; Obs $
Calc
; ut = vt(obs)
; rt = et(obs) $
Matrix
; ft = rt*x'
; ft = [ut/ft]
; ff = ff+ft*ft'
; st = st+ft
; ss=ss+st*st' $
Endproc
Execute
; obs=1,nobs$
Matrix
; H=1/nobs * <ff>*ss ; list ; trce(H)$
/*
Matrix Result
has 1 rows and 1 columns.
1
+-------------1| .1724912D+01
*/
/*==================================================================
Example 7.9. Change only in the Constant Term
Results are contained in Ex7_8.lim
*/==================================================================
/*==================================================================
Example 7.10. Separate Subset of Coefficients
Results are contained in Ex7_8.lim
*/==================================================================
/*==================================================================
Example 7.11. Inadequate Degrees of Freedom
Results are contained in Ex7_8.lim
*/==================================================================
/*==================================================================
Example 7.12. Wald Test for Structural Change
63
64
65
66
/*==================================================================
Example 7.15. J Test for a Consumption Function
Results are contained in Ex7_14.lim
*/==================================================================
/*==================================================================
Example 7.16. Cox Test for a Consumption Function
Results are contained in Ex7_14.lim
*/==================================================================
/*==================================================================
Example 7.17. Forecast for Investment
Results are contained in Ex7_1.lim
*/==================================================================
/*==================================================================
Example 7.18. Forecasting Performance
Results are contained in Ex7_1.lim
*/==================================================================
67
68
/*==================================================================
Example 8.2. Analysis of Variance
*/==================================================================
Read ; Nobs = 20 ; Nvar = 11 ; Names = 1 $
Type TA TB TC TD TE Y6064 Y6579 Y7074 Y7579 Num
1
1 0 0 0 0
1
0
0
0
0
1
1 0 0 0 0
0
1
0
0
4
1
1 0 0 0 0
0
0
1
0
18
1
1 0 0 0 0
0
0
0
1
11
2
0 1 0 0 0
1
0
0
0
29
2
0 1 0 0 0
0
1
0
0
53
2
0 1 0 0 0
0
0
1
0
44
2
0 1 0 0 0
0
0
0
1
18
3
0 0 1 0 0
1
0
0
0
1
3
0 0 1 0 0
0
1
0
0
1
3
0 0 1 0 0
0
0
1
0
2
3
0 0 1 0 0
0
0
0
1
1
4
0 0 0 1 0
1
0
0
0
0
4
0 0 0 1 0
0
1
0
0
0
4
0 0 0 1 0
0
0
1
0
11
4
0 0 0 1 0
0
0
0
1
4
5
0 0 0 0 1
1
0
0
0
0
5
0 0 0 0 1
0
1
0
0
7
5
0 0 0 0 1
0
0
1
0
12
5
0 0 0 0 1
0
0
0
1
1
Regress ; Lhs = Num ; Rhs = One,Tb,TC,TD,TE,Y6579,Y7074,Y7579 $
Calc
; List ; DFALL = DEGFRDM ; EEAll = Sumsqdev $
Regress ; Lhs = Num ; Rhs = One,
Y6579,Y7074,Y7579 $
Calc
; List ; DFYears = DEGFRDM ; EEYears = Sumsqdev $
Regress ; Lhs = Num ; Rhs = One,Tb,TC,TD,TE
$
Calc
; List ; DFTypes = DEGFRDM ; EETypes = Sumsqdev $
Regress ; Lhs = Num ; Rhs = One
$
Calc
; List ; DFNone = DEGFRDM ; EENone = Sumsqdev $
Calc
; List ; FYears = (EETypes - EEAll)/(DFTypes-DFAll) /
(EEAll / DFAll)
; Ftypes = (EEYears - EEAll)/(DFYears-DFAll) /
(EEAll / DFAll)
; FBoth = (EENone - EEAll)/(DFNone-DFALL) /
(EEAll / DFAll) $
/*
Constant 3.400000000
4.6936127
.724
.4827
TB
27.75000000
5.2476185
5.288
.0002 .20000000
TC
-7.000000000
5.2476185
-1.334
.2070 .20000000
TD
-4.500000000
5.2476185
-.858
.4080 .20000000
TE
-3.250000000
5.2476185
-.619
.5473 .20000000
Y6579
7.000000000
4.6936127
1.491
.1617 .25000000
Y7074
11.40000000
4.6936127
2.429
.0318 .25000000
Y7579
1.000000000
4.6936127
.213
.8349 .25000000
Residuals: Sum of squares= 660.9000000
, Std.Dev.=
7.42125
Fit:
R-squared= .848228, Adjusted R-squared =
.75969
DFALL
= .12000000000000000D+02
EEALL
= .66090000000000010D+03
69
Constant 6.000000000
7.0046413
.857
.4043
Y6579
7.000000000
9.9060588
.707
.4900
Y7074
11.40000000
9.9060588
1.151
.2667
Y7579
1.000000000
9.9060588
.101
.9208
Residuals: Sum of squares= 3925.200000
, Std.Dev.=
Fit:
R-squared= .098598, Adjusted R-squared =
DFYEARS=.16000000000000000D+02
EEYEARS=.39252000000000000D+04
Constant 8.250000000
4.2627260
1.935
.0720
TB
27.75000000
6.0284050
4.603
.0003
TC
-7.000000000
6.0284050
-1.161
.2637
TD
-4.500000000
6.0284050
-.746
.4669
TE
-3.250000000
6.0284050
-.539
.5977
Residuals: Sum of squares= 1090.250000
, Std.Dev.=
Fit:
R-squared= .749630, Adjusted R-squared =
DFTYPES = .15000000000000000D+02
EETYPES = .10902500000000000D+04
Constant 10.85000000
3.3851650
3.205
.0047
Residuals: Sum of squares= 4354.550000
, Std.Dev.=
Fit:
R-squared= .000000, Adjusted R-squared =
DFNONE = .19000000000000000D+02
EENONE = .43545500000000000D+04
FYEARS
FTYPES
FBOTH
.25000000
.25000000
.25000000
15.66285
-.07041
.20000000
.20000000
.20000000
.20000000
8.52545
.68286
15.13892
.00000
= .25985776970797390D+01
= .14817521561507030D+02
= .95808313338953360D+01
/*==================================================================
Example 8.3. Nonlinear Cost Function
No computations done.
*/==================================================================
70
/*==================================================================
Example 8.4. Intrinsically Linear Regression
*/==================================================================
Read ; Nobs=20 ; Nvar=3 ; Names = 1 $
I
Y
X
1
20.5
12
2
31.5
16
3
47.7
18
4
26.2
16
5
44.0
12
6
8.28
12
7
30.8
16
8
17.2
12
9
19.9
10
10
9.96
12
11
55.8
16
12
25.2
20
13
29.0
12
14
85.5
16
15
15.1
10
16
28.5
18
17
21.4
16
18
17.7
20
19
6.42
12
20
84.9
16
?
Regress ; Lhs = Y ; Rhs = One,X ; PrintVC$
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = Y
Mean=
31.27800000
, S.D.=
22.37583367
|
| Model size: Observations =
20, Parameters =
2, Deg.Fr.=
18 |
| Residuals: Sum of squares= 8425.151595
, Std.Dev.=
21.63479 |
| Fit:
R-squared= .114343, Adjusted R-squared =
.06514 |
| Model test: F[ 1,
18] =
2.32,
Prob value =
.14478 |
| Diagnostic: Log-L =
-88.8112, Restricted(b=0) Log-L =
-90.0255 |
|
LogAmemiyaPrCrt.=
6.244, Akaike Info. Crt.=
9.081 |
| Autocorrel: Durbin-Watson Statistic =
1.98091,
Rho =
.00955 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -4.143116883
23.733895
-.175
.8634
X
2.426103896
1.5914816
1.524
.1448 14.600000
Matrix Cov.Mat. has 2 rows and 2 columns.
1
2
+---------------------------1| .5632978D+03 -.3697908D+02
2| -.3697908D+02 .2532814D+01
*/
71
Wald
/*
; Fn1 = b_one/b_x$
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
.03863
|
| Prob. from Chi-squared[ 1] =
.84419
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) -1.707724426
8.6890014
-.197
.8442
*/
Calc
; List ; g1 = 1/b(2) ; g2 = -b(1)/(b(2))^2
; beta = b(1)/b(2)
; v = g1^2*varb(1,1)+g2^2*varb(2,2)+2*g1*g2*varb(1,2)
; se = sqr(v) $
/*
G1
= .41218350195385680D+00
G2
= .70389583423435310D+00
BETA
= -.17077244258872660D+01
V
= .75498746069805050D+02
SE
= .86890014426172740D+01
*/
Nlsq
; Lhs = Y ; Fcn = br*r + r*x ; Labels = Br,r ; start=0,0 ;dfc$
/*
+-----------------------------------------------------------------------+
| User Defined Optimization
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Number of iterations completed =
8
|
| Dep. var. = Y
Mean=
31.27800000
, S.D.=
22.37583367
|
| Model size: Observations =
20, Parameters =
2, Deg.Fr.=
18 |
| Residuals: Sum of squares= 8425.151595
, Std.Dev.=
21.63479 |
| Fit:
R-squared= .114343, Adjusted R-squared =
.06514 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 1,
18] =
2.32,
Prob value =
.14478 |
| Diagnostic: Log-L =
-88.8112, Restricted(b=0) Log-L =
-90.0255 |
|
LogAmemiyaPrCrt.=
6.244, Akaike Info. Crt.=
9.081 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
BR
-1.707724426
8.6890014
-.197
.8442
R
2.426103896
1.5914816
1.524
.1274
*/
/*==================================================================
Example 8.5. CES Production Function
No computations done.
*/==================================================================
72
/*==================================================================
Example 8.6. Omitted Variables
*/==================================================================
Read ; Nobs = 36 ; Nvar = 11
; Names =
Year, G,
Pg,
Y,
Pnc,
Puc,
Ppt,
Pd,
Pn,
Ps,
Pop $
1960 129.7
.925 6036 1.045
.836
.810
.444
.331
.302 180.7
1961 131.3
.914 6113 1.045
.869
.846
.448
.335
.307 183.7
1962 137.1
.919 6271 1.041
.948
.874
.457
.338
.314 186.5
1963 141.6
.918 6378 1.035
.960
.885
.463
.343
.320 189.2
1964 148.8
.914 6727 1.032 1.001
.901
.470
.347
.325 191.9
1965 155.9
.949 7027 1.009
.994
.919
.471
.353
.332 194.3
1966 164.9
.970 7280
.991
.970
.952
.475
.366
.342 196.6
1967 171.0 1.000 7513 1.000 1.000 1.000
.483
.375
.353 198.7
1968 183.4 1.014 7728 1.028 1.028 1.046
.501
.390
.368 200.7
1969 195.8 1.047 7891 1.044 1.031 1.127
.514
.409
.386 202.7
1970 207.4 1.056 8134 1.076 1.043 1.285
.527
.427
.407 205.1
1971 218.3 1.063 8322 1.120 1.102 1.377
.547
.442
.431 207.7
1972 226.8 1.076 8562 1.110 1.105 1.434
.555
.458
.451 209.9
1973 237.9 1.181 9042 1.111 1.176 1.448
.566
.497
.474 211.9
1974 225.8 1.599 8867 1.175 1.226 1.480
.604
.572
.513 213.9
1975 232.4 1.708 8944 1.276 1.464 1.586
.659
.615
.556 216.0
1976 241.7 1.779 9175 1.357 1.679 1.742
.695
.638
.598 218.0
1977 249.2 1.882 9381 1.429 1.828 1.824
.727
.671
.648 220.2
1978 261.3 1.963 9735 1.538 1.865 1.878
.769
.719
.698 222.6
1979 248.9 2.656 9829 1.660 2.010 2.003
.821
.800
.756 225.1
1980 226.8 3.691 9722 1.793 2.081 2.516
.892
.894
.839 227.7
1981 225.6 4.109 9769 1.902 2.569 3.120
.957
.969
.926 230.0
1982 228.8 3.894 9725 1.976 2.964 3.460 1.000 1.000 1.000 232.2
1983 239.6 3.764 9930 2.026 3.297 3.626 1.041 1.021 1.062 234.3
1984 244.7 3.707 10421 2.085 3.757 3.852 1.038 1.050 1.117 236.3
1985 245.8 3.738 10563 2.152 3.797 4.028 1.045 1.075 1.173 238.5
1986 269.4 2.921 10780 2.240 3.632 4.264 1.053 1.069 1.224 240.7
1987 276.8 3.038 10859 2.321 3.776 4.413 1.085 1.111 1.271 242.8
1988 279.9 3.065 11186 2.368 3.939 4.494 1.105 1.152 1.336 245.0
1989 284.1 3.353 11300 2.414 4.019 4.719 1.129 1.213 1.408 247.3
1990 282.0 3.834 11389 2.451 3.926 5.197 1.144 1.285 1.482 249.9
1991 271.8 3.766 11272 2.538 3.942 5.427 1.167 1.332 1.557 252.6
1992 280.2 3.751 11466 2.528 4.113 5.518 1.184 1.358 1.625 255.4
1993 286.7 3.713 11476 2.663 4.470 6.086 1.200 1.379 1.684 258.1
1994 290.2 3.732 11636 2.754 4.730 6.268 1.225 1.396 1.734 260.7
1995 297.8 3.789 11934 2.815 5.224 6.410 1.239 1.419 1.786 263.2
Create ; G = G/POP $
73
-2.85307 +
5.13424PG
4.0
3.5
PG
3.0
2.5
2.0
1.5
1.0
.5
.7
.8
.9
1.0
1.1
1.2
74
.00000 -
6.38505RPG
1.5
RPG
1.0
.5
.0
-.5
-1.0
-1.5
-.10
-.05
.00
.05
.10
.15
RG
75
76
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = G
Mean=
100.6903428
, S.D.=
14.07758311
|
| Model size: Observations =
36, Parameters =
5, Deg.Fr.=
31 |
| Residuals: Sum of squares= 222.7654708
, Std.Dev.=
2.68067 |
| Fit:
R-squared= .967884, Adjusted R-squared =
.96374 |
| Model test: F[ 4,
31] = 233.56,
Prob value =
.00000 |
| Diagnostic: Log-L =
-83.8886, Restricted(b=0) Log-L =
-145.7797 |
|
LogAmemiyaPrCrt.=
2.102, Akaike Info. Crt.=
4.938 |
| Autocorrel: Durbin-Watson Statistic =
.76932,
Rho =
.61534 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -8.981344220
5.0778730
-1.769
.0868
PG
-4.237117549
.98405636
-4.306
.0002 2.3166111
Y
.1587396313E-01 .67782829E-03
23.419
.0000 9232.8611
PNC
-10.13809322
6.1707739
-1.643
.1105 1.6707778
PUC
-4.324964646
2.4144154
-1.791
.0830 2.3436389
*/
Namelist ; x=one,pg,y,pnc,puc$
Calc
; xbk=xbr(y) ; yb = xbr(g)
; list ; hy=b_y * xbk / yb $
/*
HY
= .14555725279065750D+01
*/
Matrix
; gamma = {-hy/yb} * Mean(x)$
Calc
; gamma3 = gamma(3) + xbk/yb $
Matrix
; gamma(3)=gamma3
; list ; vh = gamma'varb*gamma $
Calc
; list;sqr(vh)$
/*
Matrix VH
has 1 rows and 1 columns.
1
+-------------1| .3904817D-02
Result = .62488534246613110D-01
*/
/*==================================================================
Example 9.3. The Consumption Function
No computations done.
/*==================================================================
/*==================================================================
Example 9.4. Income and Education and a Study of Twins
No computations done.
/*==================================================================
77
/*==================================================================
Example 9.5. Hausman Test for the Consumption Functioin
*/==================================================================
Read ; Nobs=36 ; Nvar = 3 ; Names = 1 $
Year
Y
C
1950
791.8
733.2
1951
819.0
748.7
1952
844.3
771.4
1953
880.0
802.5
1954
894.0
822.7
1955
944.5
873.8
1956
989.4
899.8
1957 1012.1
919.7
1958 1028.8
932.9
1959 1067.2
979.4
1960 1091.1 1005.1
1961 1123.2 1025.2
1962 1170.2 1069.0
1963 1207.3 1108.4
1964 1291.0 1170.6
1965 1365.7 1236.4
1966 1431.3 1298.9
1967 1493.2 1337.7
1968 1551.3 1405.9
1969 1599.8 1456.7
1970 1688.1 1492.0
1971 1728.4 1538.8
1972 1797.4 1621.9
1973 1916.3 1689.6
1974 1896.6 1674.0
1975 1931.7 1711.9
1976 2001.0 1803.9
1977 2066.6 1883.8
1978 2167.4 1961.0
1979 2216.2 2004.4
1980 2214.3 2000.4
1981 2248.6 2024.2
1982 2261.5 2050.7
1983 2334.6 2145.9
1984 2468.4 2239.9
1985 2509.0 2312.6
?
? Create lagged values, then set sample for complete data
?
Create
; If(_Obsno > 1) | y1 = y[-1] ; c1 = c[-1] $
Sample
; 2 - 36 $
?
? Define data matrices
?
Namelist ; X = One,y ; Z = One,y1,c1 $
?
? X-hat - by regressions on Z
?
Matrix
; Xh = Z*<Z'Z>*Z'X $
?
? Variance estimator. Only consistent under null hypothesis
?
Calc
; s2 = Ess(X,c)/(n-col(X)) $
?
78
*/
/*==================================================================
Example 9.6. Test Statistics for the Investment
Equation
*/==================================================================
Read ; Nobs = 15 ; Nvar = 5 ; Names = Y,T,G,R,P $
0.161 1 1.058 5.16 4.40
0.172 2 1.088 5.87 5.15
0.158 3 1.086 5.95 5.37
0.173 4 1.122 4.88 4.99
0.195 5 1.186 4.50 4.16
0.217 6 1.254 6.44 5.75
0.199 7 1.246 7.83 8.82
0.163 8 1.232 6.25 9.31
0.195 9 1.298 5.50 5.21
0.231 10 1.370 5.46 5.83
0.257 11 1.439 7.46 7.40
0.259 12 1.479 10.28 8.64
0.225 13 1.474 11.77 9.31
0.241 14 1.503 13.42 9.44
0.204 15 1.475 11.02 5.99
?
? Define two X matrices.
?
Namelist; X = T,G,R,P ; Xall = One,X $
?
79
? Unrestricted Regression
?
Regress ; Lhs = Y ; Rhs = Xall; Res = e $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = Y
Mean=
.2033333333
, S.D.=
.3417740830E-01 |
| Model size: Observations =
15, Parameters =
5, Deg.Fr.=
10 |
| Residuals: Sum of squares= .4508118005E-03, Std.Dev.=
.00671 |
| Fit:
R-squared= .972433, Adjusted R-squared =
.96141 |
| Model test: F[ 4,
10] =
88.19,
Prob value =
.00000 |
| Diagnostic: Log-L =
56.8098, Restricted(b=0) Log-L =
29.8762 |
|
LogAmemiyaPrCrt.=
-9.719, Akaike Info. Crt.=
-6.908 |
| Autocorrel: Durbin-Watson Statistic =
1.96364,
Rho =
.01818 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -.5090707909
.55127690E-01
-9.234
.0000
T
-.1658039448E-01 .19717611E-02
-8.409
.0000 8.0000000
G
.6703834376
.54997215E-01
12.189
.0000 1.2873333
R
-.2325928344E-02 .12188677E-02
-1.908
.0854 7.4526667
P
-.9401070242E-04 .13474804E-02
-.070
.9458 6.6513333
*/
?
? Standard F statistic
?
Calc
; List ; J=Col(X)
; K = Kreg
; F = (Rsqrd/J)/((1-Rsqrd)/(n-Kreg))$
/*
F
= .88188250148830110D+02
*/
?
? Asymptotic equivalents. Note, Wald uses (e'e/n)<X'X>
? so it comes out much larger by this method than by the
? other methods listed below, which use (e'e/(n-K))<X'X>
?
Calc
; List ; LMStat
= n*J*F/((n-K)*(1+J*F/(n-K))) $
/*
LMSTAT = .14586495494857850D+02
*/
Calc
; List ; WaldStat = n*J*F /(n-K) $
/*
WALDSTAT= .52912950089298070D+03
*/
Calc
; List ; LRStat
= n*log(1+J*F/(n-K)) $
/*
LRSTAT = .53867056058035250D+02
*/
80
Matrix
; b2 = b(2:5) ; V2 = Part(Varb,2,5,2,5)
; List ; Wald = b2' * <V2> * b2 $
/*
Matrix WALD
*/
?
Wald
/*
1 columns.
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
352.75300
|
| Prob. from Chi-squared[ 4] =
.00000
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) -.1658039448E-01 .19717611E-02
-8.409
.0000
Fncn( 2) .6703834376
.54997215E-01
12.189
.0000
Fncn( 3) -.2325928344E-02 .12188677E-02
-1.908
.0564
Fncn( 4) -.9401070242E-04 .13474804E-02
-.070
.9444
*/
Regress ; Lhs = Y ; Rhs = One,X ;
cls: b(2)=0,b(3)=0,b(4)=0,b(5)=0 $
/*
+-----------------------------------------------------------------------+
| Linearly restricted regression
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = Y
Mean=
.2033333333
, S.D.=
.3417740830E-01 |
| Model size: Observations =
15, Parameters =
1, Deg.Fr.=
14 |
| Residuals: Sum of squares= .1635333333E-01, Std.Dev.=
.03418 |
| Fit:
R-squared= .000000, Adjusted R-squared =
.00000 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Diagnostic: Log-L =
29.8762, Restricted(b=0) Log-L =
29.8762 |
|
LogAmemiyaPrCrt.=
-6.688, Akaike Info. Crt.=
-3.850 |
| Note, when restrictions are imposed, R-squared can be less than zero. |
| F[ 4,
10] for the restrictions =
88.1883, Prob =
.0000
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .2033333333
.88245689E-02
23.042
.0000
T
-.3122502257E-16 .42828688E-09
.000 1.0000 8.0000000
G
.5551115123E-15........(Fixed Parameter)........ 1.2873333
R
.0000000000
........(Fixed Parameter)........ 7.4526667
P
-.5407458335E-17........(Fixed Parameter)........ 6.6513333
*/
81
/*==================================================================
Example 9.7. The Gamma Regression Model
No computations done.
/*==================================================================
82
/*==================================================================
Example 9.8. Stochastic Frontier Model
*/==================================================================
Read ; Nobs = 25 ; Nvar = 5 ; Names = 1 $
State
ValueAdd
Capital
Labor
NFirm
Alabama
126.148
3.804
31.551
68
California
3201.486
185.446
452.844
1372
Connecticut
690.670
39.712
124.074
154
Florida
56.296
6.547
19.181
292
Georgia
304.531
11.530
45.534
71
Illinois
723.028
58.987
88.391
275
Indiana
992.169
112.884
148.530
260
Iowa
35.796
2.698
8.017
75
Kansas
494.515
10.360
86.189
76
Kentucky
124.948
5.213
12.000
31
Louisiana
73.328
3.763
15.900
115
Maine
29.467
1.967
6.470
81
Maryland
415.262
17.546
69.342
129
Massachusetts
241.530
15.347
39.416
172
Michigan
4079.554
435.105
490.384
568
Missouri
652.085
32.840
84.831
125
NewJersey
667.113
33.292
83.033
247
NewYork
940.430
72.974
190.094
461
Ohio
1611.899
157.978
259.916
363
Pennsylvania
617.579
34.324
98.152
233
Texas
527.413
22.736
109.728
308
Virginia
174.394
7.173
31.301
85
Washington
636.948
30.807
87.963
179
WestVirginia
22.700
1.543
4.063
15
Wisconsin
349.711
22.001
52.818
142
?
Create ; q = log(Valueadd) ; K = log(Capital) ; L = Log(Labor) $
?
? Linear Model
?
Regress ; Lhs = Q ; Rhs = One,K,L $
/*
++
|OrdinaryleastsquaresregressionWeightingvariable=none|
|Dep.var.=QMean=5.812092204,S.D.=1.375303514|
|Modelsize:Observations=25,Parameters=3,Deg.Fr.=22|
|Residuals:Sumofsquares=1.222259953,Std.Dev.=.23571|
|Fit:Rsquared=.973075,AdjustedRsquared=.97063|
|Modeltest:F[2,22]=397.54,Probvalue=.00000|
|Diagnostic:LogL=2.2537,Restricted(b=0)LogL=42.9300|
|LogAmemiyaPrCrt.=2.777,AkaikeInfo.Crt.=.060|
|Autocorrel:DurbinWatsonStatistic=1.95755,Rho=.02123|
++
+++++++
|Variable|Coefficient|StandardError|tratio|P[|T|>t]|MeanofX|
+++++++
Constant1.844415714.233592857.896.0000
K.2454280713.106857432.297.03152.9581994
L.8051829551.126333616.373.00004.0259810
*/
83
?
? Half normal stochastic frontier
?
Frontier ; Lhs = q ; rhs = One,K,L ; Res = Normal$
/*
Normal exit from iterations. Exit status=0.
+---------------------------------------------+
| Limited Dependent Variable Model - FRONTIER |
| Maximum Likelihood Estimates
|
| Dependent variable
Q
|
| Weighting variable
ONE
|
| Number of observations
25
|
| Iterations completed
10
|
| Log likelihood function
2.469522
|
| Variances: Sigma-squared(v)=
.03068
|
|
Sigma-squared(u)=
.04907
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Primary Index Equation for Model
Constant 2.081134710
.42187394
4.933
.0000
K
.2585478087
.14364877
1.800
.0719 2.9581994
L
.7802451298
.16981927
4.595
.0000 4.0259810
Variance parameters for compound error
Lambda
1.264536663
1.6194821
.781
.4349
Sigma
.2823997646
.87253260E-01
3.237
.0012
*/
?
? Exponential Frontier
?
Frontier ; Lhs = q ; rhs = One,K,L ; Model=E ; Res = Expon $$
/*
+---------------------------------------------+
| Limited Dependent Variable Model - FRONTIER |
| Maximum Likelihood Estimates
|
| Dependent variable
Q
|
| Weighting variable
ONE
|
| Number of observations
25
|
| Iterations completed
11
|
| Log likelihood function
2.860489
|
| Exponential frontier model
|
| Variances: Sigma-squared(v)=
.02938
|
|
Sigma-squared(u)=
.01827
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Primary Index Equation for Model
Constant 2.069242444
.29002725
7.135
.0000
K
.2624859319
.12020162
2.184
.0290 2.9581994
L
.7703794735
.13803075
5.581
.0000 4.0259810
Variance parameters for compound error
Theta
7.398138999
3.9306818
1.882
.0598
Sigmav
.1713924807
.54061028E-01
3.170
.0015
*/
84
List ; Normal,Expon $
/*
Listing of raw data (Current sample)
Line Observ.
NORMAL
EXPON
1
1
.20113
.14593
2
2
.14481
.97217E-01
3
3
.19035
.13479
4
4
.51753
.59033
5
5
.10398
.71410E-01
6
6
.12127
.83042E-01
7
7
.21128
.15451
8
8
.24933
.20073
9
9
.10100
.68576E-01
10
10
.56269E-01 .41524E-01
11
11
.20333
.15066
12
12
.22263
.17246
13
13
.13534
.92455E-01
14
14
.15637
.10933
15
15
.15810
.10757
16
16
.10288
.70415E-01
17
17
.95843E-01 .65880E-01
18
18
.27788
.22249
19
19
.22914
.16982
20
20
.15007
.10303
21
21
.20298
.14552
22
22
.14000
.96761E-01
23
23
.11048
.75333E-01
24
24
.15561
.11236
25
25
.14067
.97086E-01
/*==================================================================
Example 9.9. Nonnormal Disturbances
*/==================================================================
Read ; Nobs = 25 ; Nvar = 5 ; Names = 1 $
State
ValueAdd
Capital
Labor
NFirm
<... Data appear in previous example ...>
?
Create ; q = log(Valueadd) ; K = log(Capital) ; L = Log(Labor) $
?
? Normality Test
?
Regress;lhs=q;rhs=one,k,l; Res = e $
?
? Construct Test
?
Create ; e2 = e^2 ; e3 = e^3 ; e4 = e^4 $
Calc
; list
; m2 = xbr(e2)
; m3 = xbr(e3)/(m2^1.5) ; m4 = xbr(e4)/m2^2 - 3 $
/*
M2
= .48890398139161950D-01
M3
= -.31082932096476550D+00
M4
= .22194786523673490D+01
*/
Calc
; List ; Wald = n*( m3^2/6 + m4^2/24 ) $
/*
WALD
= .55339009952083870D+01
*/
85
/*==================================================================
Example 9.10. LAD Estimation of a Cobb-Douglas
Production Function
*/==================================================================
Read ; Nobs = 25 ; Nvar = 5 ; Names = 1 $
State
ValueAdd
Capital
Labor
NFirm
<... Data appear in Example 9.8. ...>
?
Create ; q = log(Valueadd) ; K = log(Capital) ; L = Log(Labor) $
?
? Examine Residuals
?
Regress;lhs=q;rhs=one,k,l ; Standardize ; PlotResiduals$
/*
++
|OrdinaryleastsquaresregressionWeightingvariable=none|
|Dep.var.=QMean=5.812092204,S.D.=1.375303514|
|Modelsize:Observations=25,Parameters=3,Deg.Fr.=22|
|Residuals:Sumofsquares=1.222259953,Std.Dev.=.23571|
|Fit:Rsquared=.973075,AdjustedRsquared=.97063|
|Modeltest:F[2,22]=397.54,Probvalue=.00000|
|Diagnostic:LogL=2.2537,Restricted(b=0)LogL=42.9300|
|LogAmemiyaPrCrt.=2.777,AkaikeInfo.Crt.=.060|
|Autocorrel:DurbinWatsonStatistic=1.95755,Rho=.02123|
++
+++++++
|Variable|Coefficient|StandardError|tratio|P[|T|>t]|MeanofX|
+++++++
Constant1.844415714.233592857.896.0000
K.2454280713.106857432.297.03152.9581994
L.8051829551.126333616.373.00004.0259810
R esidual
2
1
0
-1
-2
-3
-4
12
16
20
24
28
Observ.#
?
86
87
88
?
? Get starting values. Assume gamma=1.
? Save sum of squares for Example 10.8 tests.
?
Sample ; 1 - 36 $
Regress ; Lhs = C ; Rhs = One,Y $
Calc
; EE1 = Sumsqdev $
?
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = C
Mean=
1409.805556
, S.D.=
489.0210115
|
| Model size: Observations =
36, Parameters =
2, Deg.Fr.=
34 |
| Residuals: Sum of squares= 12067.83411
, Std.Dev.=
18.83975 |
| Fit:
R-squared= .998558, Adjusted R-squared =
.99852 |
| Model test: F[ 1,
34] =23547.57,
Prob value =
.00000 |
| Diagnostic: Log-L =
-155.7478, Restricted(b=0) Log-L =
-273.5013 |
|
LogAmemiyaPrCrt.=
5.926, Akaike Info. Crt.=
8.764 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 11.14574302
9.6403233
1.156
.2557
Y
.8985335453
.58554634E-02 153.452
.0000 1556.6028
*/
? Nonlinear Least Squares Regression. (Actually takes more iterations
? to converge, but additional iterations are trivial. If it continues
? to iterate, the parameter values change slightly.)
? Keep sum of squares
Nlsq
; Lhs = c ; fcn = alpha + beta*y^gamma
; labels = alpha,beta,gamma ; start = b,1
; DFC ; output = 1$
Calc
; EE = SumsQdev $
/*
Begin NLSQ iterations. Linearized regression.
Iteration= 1; Sum of squares= 12067.8341
; Gradient= 3547.31832
Iteration= 2; Sum of squares= 227235024.
; Gradient= 227226603.
Iteration= 3; Sum of squares= 351464.117
; Gradient= 343043.020
Iteration= 4; Sum of squares= 9008.28750
; Gradient= 587.614486
Iteration= 5; Sum of squares= 8420.67292
; Gradient= .132517660E-02
Iteration= 6; Sum of squares= 8420.67159
; Gradient= .417021418E-07
Iteration= 7; Sum of squares= 8420.67159
; Gradient= .265749824E-10
+-----------------------------------------------------------------------+
| User Defined Optimization
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Dep. var. = C
Mean=
1409.805556
, S.D.=
489.0210115
|
| Model size: Observations =
36, Parameters =
3, Deg.Fr.=
33 |
| Residuals: Sum of squares= 8420.671589
, Std.Dev.=
15.97410 |
| Fit:
R-squared= .998994, Adjusted R-squared =
.99893 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
33] =16384.12,
Prob value =
.00000 |
| Diagnostic: Log-L =
-149.2705, Restricted(b=0) Log-L =
-273.5013 |
|
LogAmemiyaPrCrt.=
5.622, Akaike Info. Crt.=
8.459 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
ALPHA
187.8989963
40.677226
4.619
.0000
BETA
.2460040329
.82999421E-01
2.964
.0030
GAMMA
1.156396418
.41007251E-01
28.200
.0000
MatrixCov.Mat.has3rowsand3columns.
123
89
+
1|.1654532D+04.3329262D+01.1641340D+01
2|.3329262D+01.6883158D02.3401887D02
3|.1641340D+01.3401887D02.1681777D02
?
? Marginal propensity to consume
?
Wald
; Fn1 = gamma - 1
; Fn2 = beta*gamma*2509^(gamma-1) $
; Fn3 = beta*gamma*2509^(gamma-1) - 1 $
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .1563964183
.41007251E-01
3.814
.0001
Fncn( 3) .9676508712
.19245239E-01
50.280
.0000
Fncn( 3) -.3234912783E-01 .19245239E-01
-1.681
.0928
*/
/*==================================================================
Example 10.4. Multicollinearity in Nonlinear Regression
*/==================================================================
?
? Condition number of the data matrix of pseudo regressors
?
Create ; x20=y^gamma
; x30=beta*x20*log(y) $
Calc
; list ; Cor(x20,x30) $
?
Result = .99986594591977720D+00
?
Namelist ; X = One,x20,x30 $
Matrix
; XX = X'X ; D = Diag(XX) ; D = Isqr(D) ; V = D*XX*D $
?
Matrix
; List ; L = Root(V) $
Calc
; List ; cn = sqr(L(1)/L(3)) $
/*
Matrix L
has 3 rows and 1 columns.
1
+-------------1| .2897766D+01
2| .1022142D+00
3| .1952984D-04
CN
= .38519646674583850D+03
*/
90
/*==================================================================
Example 10.6. Instrumental Variables Estimates of the Consumption
Function
*/==================================================================
Create ; If(_obsno > 1)
c1 = c[-1] $
Create ; If(_obsno > 2) | y1 =y[-1] ; y2 = y[-2] $
Sample ; 3 - 36 $
Regress ; Lhs = C ; Rhs = One,Y $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = C
Mean=
1449.150000
, S.D.=
474.2607359
|
| Model size: Observations =
34, Parameters =
2, Deg.Fr.=
32 |
| Residuals: Sum of squares= 11941.40636
, Std.Dev.=
19.31758 |
| Fit:
R-squared= .998391, Adjusted R-squared =
.99834 |
| Model test: F[ 1,
32] =19858.37,
Prob value =
.00000 |
| Diagnostic: Log-L =
-147.8878, Restricted(b=0) Log-L =
-257.2362 |
|
LogAmemiyaPrCrt.=
5.979, Akaike Info. Crt.=
8.817 |
| Autocorrel: Durbin-Watson Statistic =
.84794,
Rho =
.57603 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 9.033155912
10.742996
.841
.4067
Y
.8996347863
.63840236E-02 140.920
.0000 1600.7794
*/
Matrix ; Bols = b $
Nlsq
; Lhs = c
; fcn = alpha + beta*y^gamma
; labels = alpha,beta,gamma
; start = bols,1
; DFC ; output = 1; table = NLSQ $
/*
+-----------------------------------------------------------------------+
| User Defined Optimization
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Number of iterations completed = 10
|
| Dep. var. = C
Mean=
1449.150000
, S.D.=
474.2607359
|
| Model size: Observations =
34, Parameters =
3, Deg.Fr.=
31 |
| Residuals: Sum of squares= 8034.399111
, Std.Dev.=
16.09889 |
| Fit:
R-squared= .998918, Adjusted R-squared =
.99885 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
31] =14303.96,
Prob value =
.00000 |
| Diagnostic: Log-L =
-141.1511, Restricted(b=0) Log-L =
-257.2362 |
|
LogAmemiyaPrCrt.=
5.642, Akaike Info. Crt.=
8.479 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
ALPHA
214.9680758
45.144186
4.762
.0000
BETA
.2011697535
.76321137E-01
2.636
.0084
GAMMA
1.180567691
.46085907E-01
25.617
.0000
*/
91
Wald
/*
; Fn1 = beta*gamma*2509^(gamma-1)$
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
2208.66113
|
| Prob. from Chi-squared[ 1] =
.00000
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .9760983124
.20769642E-01
46.996
.0000
*/
Nlsq
; Lhs = c
; fcn = alpha + beta*y^gamma
; Inst= one,c1,y1,y2
; labels = alpha,beta,gamma
; start = bols,1
; DFC ; table = NLIV ; Res = u ; Maxit=200$
/*
+-----------------------------------------------------------------------+
| Instrumental Variables (NL2SLS)
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Number of iterations completed = 178
|
| Dep. var. = TA*Y^GL Mean=
1449.150000
, S.D.=
474.2607359
|
| Model size: Observations =
34, Parameters =
3, Deg.Fr.=
31 |
| Residuals: Sum of squares= 10369.51594
, Std.Dev.=
18.28936 |
| Fit:
R-squared= .998603, Adjusted R-squared =
.99851 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
31] =11079.35,
Prob value =
.00000 |
| Diagnostic: Log-L =
-145.4884, Restricted(b=0) Log-L =
-257.2362 |
|
LogAmemiyaPrCrt.=
5.897, Akaike Info. Crt.=
8.735 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
ALPHA
335.7107115
76.408816
4.394
.0000
BETA
.6352351182E-01 .51391310E-01
1.236
.2164
GAMMA
1.321362196
.99258677E-01
13.312
.0000
*/
Wald
; Fn1 = beta*gamma*2509^(gamma-1)$
/*
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
525.65168
|
| Prob. from Chi-squared[ 1] =
.00000
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) 1.038549911
.45297929E-01
22.927
.0000
*/
92
LR=.12962069520649460D+02
*/
?
? Lagrange Multiplier
?
Matrix ; BR = Xlsq(One,Y,C) $
Create ; Er = C - br(1) - br(2)*Y $
Create ; x10 = 1
; x20 = Y
; x30 = br(2)*Y*log(Y) $
Namelis; X0 = x10,x20,x30 $
Matrix ; List ; LM = {n/EE1} * Er'X0*<X0'X0>*X0'Er $
/*
Matrix LM
has 1 rows and 1 columns.
1
+-------------1| .1058214D+02
*/
93
/*==================================================================
Example 10.4. Multicollinearity in Nonlinear Regression.
Computations done in Ex10_3.lim
*/==================================================================
/*==================================================================
Example 10.5. A Generalized Production Function
*/==================================================================
Read ; Nobs = 25 ; Nvar = 5 ; Names = 1 $
State
ValueAdd
Capital
Labor
NFirm
Alabama
126.148
3.804
31.551
68
California
3201.486
185.446
452.844
1372
Connecticut
690.670
39.712
124.074
154
Florida
56.296
6.547
19.181
292
Georgia
304.531
11.530
45.534
71
Illinois
723.028
58.987
88.391
275
Indiana
992.169
112.884
148.530
260
Iowa
35.796
2.698
8.017
75
Kansas
494.515
10.360
86.189
76
Kentucky
124.948
5.213
12.000
31
Louisiana
73.328
3.763
15.900
115
Maine
29.467
1.967
6.470
81
Maryland
415.262
17.546
69.342
129
Massachusetts
241.530
15.347
39.416
172
Michigan
4079.554
435.105
490.384
568
Missouri
652.085
32.840
84.831
125
NewJersey
667.113
33.292
83.033
247
NewYork
940.430
72.974
190.094
461
Ohio
1611.899
157.978
259.916
363
Pennsylvania
617.579
34.324
98.152
233
Texas
527.413
22.736
109.728
308
Virginia
174.394
7.173
31.301
85
Washington
636.948
30.807
87.963
179
WestVirginia
22.700
1.543
4.063
15
Wisconsin
349.711
22.001
52.818
142
?
? Data setup
?
Create
; q=valueadd/nfirm ; k=log(capital/nfirm) ; l=log(labor/nfirm)$
?
? Regression to get starting values
?
Regress ; lhs=log(q);rhs=one,k,l$
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGQ
Mean=
.7717343935
, S.D.=
.8993058288
|
| Model size: Observations =
25, Parameters =
3, Deg.Fr.=
22 |
| Residuals: Sum of squares= .7814030819
, Std.Dev.=
.18846 |
| Fit:
R-squared= .959742, Adjusted R-squared =
.95608 |
| Model test: F[ 2,
22] = 262.24,
Prob value =
.00000 |
| Diagnostic: Log-L =
7.8458, Restricted(b=0) Log-L =
-32.3099 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 2.293263250
.10718278
21.396
.0000
K
.2789823055
.80685784E-01
3.458
.0022 -2.0821584
L
.9273117612
.98322176E-01
9.431
.0000 -1.0143768
*/
94
Matrix
; bols=b$
Calc
; s2 = s*s $
?
? Maximum likelihood estimates.
?
Maximize ;fcn=-.5*log(2*pi) -.5*log(sgsq) +
log(1+t*q) - log(q)
-.5/sgsq* (log(q)+t*q-b0-b1*k-b2*l)^2
;start=bols,.1,s2 ;labels=b0,b1,b2,t,sgsq$
/*
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
25
|
| Iterations completed
12
|
| Log likelihood function
-8.939044
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B0
2.914822411
.44912222
6.490
.0000
B1
.3500676243
.10018605
3.494
.0005
B2
1.092275274
.16070124
6.797
.0000
T
.1066655870
.78702507E-01
1.355
.1753
SGSQ
.4274269499E-01 .15116672E-01
2.828
.0047
*/
?
? Residuals, compute sum of squares, then verify that
? MLE of sigma-squares really is (1/n)*e'e
?
Create
; e = log(q) + t*q -b0 - b1*k - b2*l $
Calc
; List ; ee1 = e'e ; ee2 = n*sgsq$
/*
EE1
= .10685673673024950D+01
EE2
= .10685673747114620D+01
*/
?
? Plot scale economies measure with confidence limits
?
Create
; u=log(q)+t*q - (b0 + b1*k + b2*l)$
Calc
; s2=u'u/n$
Create
; w1=(u/s2)*1 ; w2=(u/s2)*k ;w3=(u/s2)*l
; w4=1/(t+1/q) - u/s2*q
; w5=1/(2*s2)*(u*u/s2-1)$
Namelist ; w=w1,w2,w3,w4,w5 $
Matrix
; v=<w'w>$
Create
; alpha=(b1+b2)/(1+t*q)
; w1=0
;w2=1/(1+t*q)
; w3=w2
; w4=-q*w2*alpha
; w5=0 $
Create
; sdalpha=sqr(qfr(W,v))
; upper=alpha+1.96*sdalpha
; lower=alpha-1.96*sdalpha$
Plot
; lhs=q;rhs=alpha,lower,upper;fill;bars=1
; Yaxis=SclElast ; Title=Measure of Scale Economies$
95
SclElast
1.5
1.3
1.0
.7
.4
Q
?
? Ordinary least squares treating theta as known to get
? conditional (incorrect) standard errors.
?
Create
; yf = log(q) + t*q$
Regress ; Lhs = yf ; rhs = One,K,L $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = YF
Mean=
1.077947507
, S.D.=
1.075785616
|
| Model size: Observations =
25, Parameters =
3, Deg.Fr.=
22 |
| Residuals: Sum of squares= 1.068567367
, Std.Dev.=
.22039 |
| Fit:
R-squared= .961528, Adjusted R-squared =
.95803 |
| Model test: F[ 2,
22] = 274.93,
Prob value =
.00000 |
| Diagnostic: Log-L =
3.9335, Restricted(b=0) Log-L =
-36.7895 |
|
LogAmemiyaPrCrt.=
-2.911, Akaike Info. Crt.=
-.075 |
| Autocorrel: Durbin-Watson Statistic =
1.54685,
Rho =
.22657 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 2.914822412
.12533963
23.255
.0000
K
.3500676253
.94354022E-01
3.710
.0012 -2.0821584
L
1.092275272
.11497803
9.500
.0000 -1.0143768
*/
?
? Nonlinear least squares estimates. Note much smaller sum of
? squares. (Least squares is least squares.)
?
Minimize ; fcn=(log(q)+t*q-b0-b1*k-b2*l)^2
; start=bols,.1
; labels=b0,b1,b2,t$
96
/*
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
25
|
| Iterations completed
5
|
| Log likelihood function
-.7655490
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B0
2.108924948
5.3414125
.395
.6930
B1
.2579002461
2.0766482
.124
.9012
B2
.8783878688
2.2423430
.392
.6953
T
-.3163424243E-01 .84543523
-.037
.9702
*/
/*==================================================================
Example 10.6. Instrumental Variables Estimates of the Consumption Function
Computations done in Ex10_3.lim
*/==================================================================
/*==================================================================
Example 10.7.
Two Step Estimation of a Credit Scoring Model
*/==================================================================
Read ; Nobs = 100 ; Nvar = 7
; Names = Derogs,Card,Age,Income,Exp,OwnRent,SelfEmpl $
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
0
3
0
1
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
1
0
1
0
1
0
1
1
1
1
0
1
0
1
1
1
0
1
1
1
0
1
1
38 4.52
33 2.42
34 4.50
31 2.54
32 9.79
23 2.50
28 3.96
29 2.37
37 3.80
28 3.20
31 3.95
42 1.98
30 1.73
29 2.45
35 1.91
41 3.20
40 4.00
30 3.00
40 10.00
46 3.40
35 2.35
25 1.88
34 2.00
36 4.00
43 5.14
30 4.51
22 3.84
22 1.50
34 2.50
40 5.50
22 2.03
29 3.20
25 3.15
21 2.47
24 3.00
43 3.54
43 2.28
37 5.70
27 3.50
124.98
9.85
15.00
137.87
546.50
92.00
40.83
150.79
777.82
52.58
256.66
0.00
0.00
78.87
42.62
335.43
248.72
0.00
548.03
0.00
43.34
0.00
218.52
170.64
37.58
502.20
0.00
73.18
0.00
1532.77
42.69
417.83
0.00
552.72
222.54
541.30
0.00
568.77
344.47
1
0
1
0
1
0
0
1
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
0
1
0
0
0
1
1
0
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
97
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
2
0
0
0
3
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
3
0
0
0
0
1
2
0
0
4
2
0
1
1
0
0
1
1
1
1
1
1
0
1
0
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
0
0
1
1
0
1
1
1
1
1
1
0
1
1
1
1
0
1
1
1
0
1
0
0
0
0
0
0
1
0
0
1
1
1
1
1
28
26
23
30
30
38
28
36
38
26
28
50
24
21
24
26
33
34
33
45
21
25
27
26
22
27
26
41
42
22
25
31
27
33
37
27
24
24
25
36
33
33
55
20
29
40
41
41
35
24
54
34
45
43
35
36
22
33
25
26
46
4.60
3.00
2.59
1.51
1.85
2.60
1.80
2.00
3.26
2.35
7.00
3.60
2.00
1.70
2.80
2.40
3.00
4.80
3.18
1.80
1.50
3.00
2.28
2.80
2.70
4.90
2.50
6.00
3.90
5.10
3.07
2.46
2.00
3.25
2.72
2.20
4.10
3.75
2.88
3.05
2.55
4.00
2.64
1.65
2.40
3.71
7.24
4.39
3.30
2.30
4.18
2.49
2.81
2.40
1.50
8.40
1.56
6.00
3.60
5.00
5.50
405.35
310.94
53.65
63.92
165.85
9.58
0.00
319.49
0.00
83.08
644.83
0.00
93.20
105.04
34.13
41.19
169.89
1898.03
810.39
0.00
32.78
95.80
27.78
215.07
79.51
0.00
0.00
306.03
104.54
0.00
642.47
308.05
186.35
56.15
129.37
93.11
0.00
292.66
98.46
258.55
101.68
0.00
65.25
108.61
49.56
0.00
235.57
0.00
0.00
0.00
0.00
0.00
0.00
68.38
0.00
0.00
0.00
474.15
234.05
451.20
251.52
1
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
0
0
0
1
0
0
0
0
1
0
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
?
? Setup for two models. W in probability, X in regression
?
Namelist ; W = One,Age,Income,SelfEmpl,OwnRent
; X = One,Age,Income,Expend $
?
? Probability Model, Maximum likelihood. Could use LOGIT
?
Create
; q = 2*Card - 1 $ (see 19-20 to 19-22)
Maximize ; Fcn = Log(Lgp(q*(c1'W)))
98
; Start = 0,0,0,0,0
; Labels= c1,c2,c3,c4,c5 $
/*
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
100
|
| Iterations completed
10
|
| Log likelihood function
-53.92463
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
C1
2.723655716
1.0970066
2.483
.0130
C2
-.7327692237E-01 .29617637E-01
-2.474
.0134
C3
.2192028932
.14925569
1.469
.1419
C4
-1.943879185
1.0126624
-1.920
.0549
C5
.1893680073
.49816937
.380
.7039
*/
?
? Note, VC is the BHHH estimator shown in the text.
?
Matrix
; Gamma = B ; VC = VARB $
Create
; Prob = Lgp(W'Gamma) $
Namelist ; X0 = X,Prob $
?
? 1. Linear Regression Model
?
Regress ; Lhs = Derogs ; Rhs = X0 ; Res = Ei $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = DEROGS
Mean=
.3600000000
, S.D.=
1.010250494
|
| Model size: Observations =
100, Parameters =
5, Deg.Fr.=
95 |
| Residuals: Sum of squares= 95.55064679
, Std.Dev.=
1.00289 |
| Fit:
R-squared= .054329, Adjusted R-squared =
.01451 |
| Model test: F[ 4,
95] =
1.36,
Prob value =
.25213 |
| Diagnostic: Log-L =
-139.6182, Restricted(b=0) Log-L =
-142.4112 |
|
LogAmemiyaPrCrt.=
.055, Akaike Info. Crt.=
2.892 |
| Autocorrel: Durbin-Watson Statistic =
2.05681,
Rho =
-.02841 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -1.062808491
1.2215862
-.870
.3865
AGE
.2166060189E-01 .19243146E-01
1.126
.2632 32.080000
INCOME
.3473139843E-01 .74547884E-01
.466
.6424 3.3693000
EXPEND
-.7873806527E-03 .37619623E-03
-2.093
.0390 189.02310
PROB
1.040752075
1.0929908
.952
.3434 .73000000
*/
?
? Recover e'e/n
?
Calc
; List ; s2 = sqr(sumsqdev/n)
; delta = b(kreg)
; s2sqrd=s2*s2 $
/*
S2
= .97750011147810210D+00
DELTA
= .10407520752603880D+01
S2SQRD = .95550646793970210D+00
99
*/
Matrix
; VB = 1/ssqrd * VARB ; VV=s2sqrd*VB ; Stat(b,VV) $
/*
Matrix statistical results: Coefficients=B
Variance=VV
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B
_ 1 -1.062808491
1.1906549
-.893
.3721
B
_ 2 .2166060189E-01 .18755899E-01
1.155
.2481
B
_ 3 .3473139843E-01 .72660289E-01
.478
.6327
B
_ 4 -.7873806527E-03 .36667073E-03
-2.147
.0318
B
_ 5 1.040752075
1.0653156
.977
.3286
*/
?
? Derivative of regression wrt gamma (* w'). C matrix
?
Create
; Ci = Ei * Ei * delta * Prob * (1-Prob)
?
? Residual * derivative of term in log-L wrt gamma
?
; Gi = Ei * (Card - Lgp(W'gamma)) $
?
? Compute C and R then assemble corrected matrix
?
Matrix
; C = X0'[Ci]W ; R = X0'[Gi]W
; Term = C*VC*C' - C*VC*R' - R*VC*C'
; VBS = Ssqrd*VB + VB * Term * VB
; Stat(B,VBS) $
/*
Matrix statistical results: Coefficients=B
Variance=VBS
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B
_ 1 -1.062808491
1.2681171
-.838
.4020
B
_ 2 .2166060189E-01 .20088641E-01
1.078
.2809
B
_ 3 .3473139843E-01 .82078519E-01
.423
.6722
B
_ 4 -.7873806527E-03 .41257840E-03
-1.908
.0563
B
_ 5 1.040752075
1.1772992
.884
.3767
*/
100
?
? Repeat for nonlinear model. Nonlinear least squares
? diverges for this model if it is allowed to iterate very
? long. We found a moderately good solution by trial and
? error by stopping after 11 iterations.
?
Nlsq
; Lhs = Derogs
; Fcn = Exp(B1'X0)
; Start = 0,0,0,0,0
; maxit=11 ; output=1
; Labels = B1,B2,B3,B4,B5 ; Keep=YFi ; Res = Ei$
/*
Begin NLSQ iterations. Linearized regression.
Iteration= 1; Sum of squares= 142.000000
; Gradient= 46.4493514
Iteration= 2; Sum of squares= 99.7445220
; Gradient= 7.03076074
Iteration= 3; Sum of squares= 92.4280996
; Gradient= 2.41299864
Iteration= 4; Sum of squares= 89.5522233
; Gradient= 1.58178528
Iteration= 5; Sum of squares= 87.2606938
; Gradient= 1.66128707
Iteration= 6; Sum of squares= 84.7721964
; Gradient= 1.58565710
Iteration= 7; Sum of squares= 82.6377628
; Gradient= 1.11446670
Iteration= 8; Sum of squares= 81.3083495
; Gradient= .672406850
Iteration= 9; Sum of squares= 80.6016535
; Gradient= .268266105
Iteration= 10; Sum of squares= 80.3576954
; Gradient= .513063938E-01
Iteration= 11; Sum of squares= 80.3126542
; Gradient= .811534575E-02
Maximum iterations exceeded
+-----------------------------------------------------------------------+
| User Defined Optimization
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Number of iterations completed = 10
|
| Dep. var. = DEROGS
Mean=
.3600000000
, S.D.=
1.010250494
|
| Model size: Observations =
100, Parameters =
5, Deg.Fr.=
95 |
| Residuals: Sum of squares= 80.31265424
, Std.Dev.=
.89617 |
| Fit:
R-squared= .205140, Adjusted R-squared =
.21309 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 4,
95] =
6.13,
Prob value =
.00020 |
| Diagnostic: Log-L =
-130.9317, Restricted(b=0) Log-L =
-142.4112 |
|
LogAmemiyaPrCrt.=
-.170, Akaike Info. Crt.=
2.719 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1
-7.196892992
6.2707629
-1.148
.2511
B2
.7998362187E-01 .81353151E-01
.983
.3255
B3
-.1328069100
.21379593
-.621
.5345
B4
-.2800751224
.96428971
-.290
.7715
B5
6.990980386
5.7978047
1.206
.2279
*/
? Redo for nonlinear. Function=Exp(B'X+delta*Prob)
? Derivative of regression wrt gamma. Construct R and C.
Create
; Ci = Ei * Ei * YFI * YFI * B5 * Prob * (1-Prob)
; Gi = Ei * YFI * (Card - Lgp(W'gamma)) $
? Remaining computations are identical to what we did earlier.
Calc
; List
; s2 = sqr(sumsqdev/n)
; s2sqrd = s2*s2$
/*
S2
= .89617327697944940D+00
S2SQRD = .80312654237208490D+00
*/
Matrix
; VB = 1/s2sqrd * VARB $
Matrix
; C = X0'[Ci]W ; R = X0'[Gi]W
101
+---------------------------------------------+
| Poisson Regression
|
| Maximum Likelihood Estimates
|
| Dependent variable
DEROGS
|
| Weighting variable
ONE
|
| Number of observations
100
|
| Iterations completed
9
|
| Log likelihood function
-78.33099
|
| Restricted log likelihood
-91.93738
|
| Chi-squared
27.21278
|
| Degrees of freedom
4
|
| Significance level
.1800315E-04 |
| Chi- squared =
193.02558 RsqP=
.3123
|
| G - squared =
112.77200 RsqD=
.1944
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -6.319948392
3.9307689
-1.608
.1079
AGE
.7310594941E-01 .54245816E-01
1.348
.1778 32.080000
INCOME
.4523355142E-01 .17411137
.260
.7950 3.3693000
EXPEND
-.6896910011E-02 .20200124E-02
-3.414
.0006 189.02310
PROB
4.632355728
3.6617746
1.265
.2059 .73000000
*/
Create ; Ci = Ei * Ei * b(Kreg) * Prob * (1 - Prob)
; Gi = Ei * (Card - Lgp(q*(Gamma'W))) $
102
?
? Compute
?
Matrix ;
;
;
/*
Matrix statistical results: Coefficients=B
Variance=VBS
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B
_ 1 -6.319948392
8.6212781
-.733
.4635
B
_ 2 .7310594941E-01 .10115676
.723
.4699
B
_ 3 .4523355142E-01 .39056118
.116
.9078
B
_ 4 -.6896910011E-02 .37046155E-02
-1.862
.0626
B
_ 5 4.632355728
9.3355541
.496
.6197
*/
/*==================================================================
Example 10.8. Hypothesis Tests in a Nonlinear Regression Model
Computations done in Ex10_3.lim
*/==================================================================
/*==================================================================
Example 10.9. Money Demand
*/==================================================================
Read ; Nobs = 20 ; Nvar = 4 ; Names = 1 $
Year
r
M
Y
1966
4.5
480.0 2208.3
1967
4.19
524.3 2271.4
1968
5.16
566.3 2365.6
1969
5.87
589.5 2423.3
1970
5.95
628.2 2416.2
1971
4.88
712.8 2484.8
1972
4.50
805.2 2608.5
1973
6.44
861.0 2744.1
1974
7.83
908.4 2729.3
1975
6.25
1023.1 2695.0
1976
5.50
1163.6 2826.7
1977
5.46
1286.6 2958.6
1978
7.46
1388.9 3115.2
1979
10.28
1497.9 3192.4
1980
11.77
1631.4 3187.1
1981
13.42
1794.4 3248.8
1982
11.02
1954.9 3166.0
1983
8.50
2188.8 3277.7
1984
8.80
2371.7 3492.0
1985
7.69
2563.6 3573.5
?
? Data setup
?
Create
; lm = log(M) ; lr = log(r) ; ly = log(y) $
Namelist ; X = one,r,y
; LX = One,lr,ly $
?
? Get predictions from simple regressions
?
Regress ; Lhs = m ; Rhs = X ; Keep = Yf $
Regress ; Lhs = lm ; Rhs = LX ; Keep = Lyf $
/*
+-----------------------------------------------------------------------+
103
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = M
Mean=
1247.030000
, S.D.=
653.2915067
|
| Model size: Observations =
20, Parameters =
3, Deg.Fr.=
17 |
| Residuals: Sum of squares= 525005.9555
, Std.Dev.=
175.73475 |
| Fit:
R-squared= .935256, Adjusted R-squared =
.92764 |
| Model test: F[ 2,
17] = 122.79,
Prob value =
.00000 |
| Diagnostic: Log-L =
-130.1331, Restricted(b=0) Log-L =
-157.5063 |
|
LogAmemiyaPrCrt.=
10.478, Akaike Info. Crt.=
13.313 |
| Autocorrel: Durbin-Watson Statistic =
.44466,
Rho =
.77767 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -3169.418045
310.81726
-10.197
.0000
R
-14.92228419
22.588241
-.661
.5177 7.2735000
Y
1.588145997
.14343298
11.072
.0000 2849.2250
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LM
Mean=
6.995212139
, S.D.=
.5355391345
|
| Model size: Observations =
20, Parameters =
3, Deg.Fr.=
17 |
| Residuals: Sum of squares= .1319566552
, Std.Dev.=
.08810 |
| Fit:
R-squared= .975784, Adjusted R-squared =
.97294 |
| Model test: F[ 2,
17] = 342.51,
Prob value =
.00000 |
| Diagnostic: Log-L =
21.8314, Restricted(b=0) Log-L =
-15.3762 |
|
LogAmemiyaPrCrt.=
-4.719, Akaike Info. Crt.=
-1.883 |
| Autocorrel: Durbin-Watson Statistic =
1.05521,
Rho =
.47239 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -21.99158434
1.6477750
-13.346
.0000
LR
-.3157025606E-01 .96787418E-01
-.326
.7483 1.9265979
LY
3.656275189
.22550430
16.214
.0000 7.9445934
*/
?
? predicted log - log of prediction from linear
?
Create
; dl = lyf - log(yf)
?
? predicted value - exp(predicted log)
?
; d
= yf - exp(lyf) $
?
? PE test for linear model
?
Regress ; Lhs = m ; Rhs = X,dl $
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -3547.816481
281.05383
-12.623
.0000
R
-17.95961432
18.426364
-.975
.3442 7.2735000
Y
1.722803777
.12464630
13.822
.0000 2849.2250
DL
751.2119701
242.21248
3.101
.0069 .22390676E-01
*/
?
? PE test for loglinear model
?
Regress ; Lhs = lm ; Rhs = LX,d $
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
104
+---------+--------------+----------------+--------+---------+----------+
Constant -22.08606298
1.6819831
-13.131
.0000
LR
-.2929830440E-01 .98497905E-01
-.297
.7699 1.9265979
LY
3.667728539
.23000589
15.946
.0000 7.9445934
D
-.1363164163E-03 .20672941E-03
-.659
.5190 6.5341270
*/
/*==================================================================
Example 10.10. Flexible Cost Function
No computations.
*/==================================================================
/*==================================================================
Example 10.11. A Box-Cox Specification for Money
Demand
*/==================================================================
Read ; Nobs = 20 ; Nvar = 4 ; Names = 1 $
Year
r
M
Y
<... Data appear in Example 10.9 ... >
?
? Data setup
?
Create
; lm = log(M) ; lr = log(r) ; ly = log(y) $
Namelist ; X = one,r,y
; LX = One,lr,ly $
/*==========================================================================
First half of application: Transforming independent variables only.
*/==========================================================================
BoxCox
; lhs=LM ; Rhs=r,y,one ;
; Model=2 ; lambda=-.5,.5 ; pts=201 $
/*
+-----------------------------------------------------------------------+
| Box-Cox Nonlinear Regression Model
|
| Dep. var. = LM
Mean=
6.995212139
, S.D.=
.5355391345
|
| Model size: Observations =
20, Parameters =
3, Deg.Fr.=
17 |
| Residuals: Sum of squares= .1272008989
, Std.Dev.=
.07975 |
| Fit:
R-squared= .977824, Adjusted R-squared =
.97893 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
17] = 374.80,
Prob value =
.00000 |
| Diagnostic: Log-L =
22.1984, Restricted(b=0) Log-L =
-15.3762 |
|
LogAmemiyaPrCrt.=
-4.918, Akaike Info. Crt.=
-1.920 |
| Transformations: RHS = Lambda , LHS = ONE
|
| Log-likelihood accounting for the LHS transformation
=
22.19833 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Variables transformed by LAMBDA =
.47500
R
-.5946170688E-02 .33980103E-01
-.175
.8611 7.2735000
Y
.8337778613E-01 .36561885
.228
.8196 2849.2250
Variables that were not transformed
Constant -.4704825331
7.9109939
-.059
.9526
Variance and transformation parameters
Lambda
.4750000000
.55099265
.862
.3886
Sigma-sq .6360044944E-02 .20112228E-02
3.162
.0016
*/
? Internal routine uses second derivatives. Recompute using (10-51)
?
Calc
; Lambda1 = .475 $
Create
; BCM=LM ; BCR=R@Lambda1 ; BCY=Y@Lambda1
; e=BCM - b(3) - b(1)*BCR - B(2)*BCY $
Calc
; s2=e'e/n $
105
Create
106
BoxCox
; lhs=M ; Rhs=r,y,one ; lambda=0$
/*
+-----------------------------------------------------------------------+
| Box-Cox Nonlinear Regression Model
|
| Maximum likelihood estimator
Heteroscedasticity:W(i) = ONE
|
| Number of iterations completed = 10
|
| Dep. var. = M
Mean=
1247.030000
, S.D.=
653.2915067
|
| Model size: Observations =
20, Parameters =
3, Deg.Fr.=
17 |
| Residuals: Sum of squares= .1329505223
, Std.Dev.=
.08153 |
| Fit:
R-squared= 1.000000, Adjusted R-squared =
1.00000 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
17] =********,
Prob value =
.00000 |
| Diagnostic: Log-L =
21.7563, Restricted(b=0) Log-L =
-157.5063 |
|
LogAmemiyaPrCrt.=
-4.874, Akaike Info. Crt.=
-1.876 |
| Transformations: RHS = ONE
, LHS = Lambda
|
| Elasticities have been kept in matrix EPSILON
|
| Log-likelihood accounting for the LHS transformation
=
-118.14801 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
R
.3821882465E-03 .10509205E-01
.036
.9710 7.2735000
Y
.1270563563E-02 .13804284E-02
.920
.3574 2849.2250
Constant 3.372310824
.19258267
17.511
.0000
Variance and transformation parameters
Lambda
.0000000000
.15426026
.000 1.0000
Sigma-sq .6647526115E-02 .14407630E-01
.461
.6445
*/
?
BoxCox
; lhs=M ; Rhs=r,y,one ; lambda=1$
/*
+-----------------------------------------------------------------------+
| Box-Cox Nonlinear Regression Model
|
| Maximum likelihood estimator
Heteroscedasticity:W(i) = ONE
|
| Number of iterations completed = 10
|
| Dep. var. = M
Mean=
1247.030000
, S.D.=
653.2915067
|
| Model size: Observations =
20, Parameters =
3, Deg.Fr.=
17 |
| Residuals: Sum of squares= 525005.9555
, Std.Dev.=
162.01944 |
| Fit:
R-squared= .938494, Adjusted R-squared =
.94157 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
17] = 129.70,
Prob value =
.00000 |
| Diagnostic: Log-L =
-130.1331, Restricted(b=0) Log-L =
-157.5063 |
|
LogAmemiyaPrCrt.=
10.315, Akaike Info. Crt.=
13.313 |
| Transformations: RHS = ONE
, LHS = Lambda
|
| Elasticities have been kept in matrix EPSILON
|
| Log-likelihood accounting for the LHS transformation
=
-130.13320 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
R
-14.92228419
40.084453
-.372
.7097 7.2735000
Y
1.588145997
2.7126656
.585
.5582 2849.2250
Constant -3170.418045
5628.1851
-.563
.5732
Variance and transformation parameters
Lambda
1.000000000
.23928458
4.179
.0000
Sigma-sq 26250.29778
93464.349
.281
.7788
*/
107
108
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
317.60
391.80
410.60
257.70
330.80
461.20
512.00
448.00
499.60
547.50
561.20
688.10
568.90
529.20
555.10
642.90
755.90
891.20
1304.40
1486.70
40.29
72.76
66.26
51.60
52.41
69.41
68.35
46.80
47.40
59.57
88.78
74.12
62.68
89.36
78.98
100.66
160.62
145.00
174.93
3078.50
4661.70
5387.10
2792.20
4313.20
4643.90
4551.20
3244.10
4053.70
4379.30
4840.90
4900.90
3526.50
3254.70
3700.20
3755.60
4833.00
4924.90
6241.70
5593.60
417.50
837.80
883.90
437.90
679.70
727.80
643.60
410.90
588.40
698.40
846.40
893.80
579.00
694.60
590.30
693.50
809.00
727.00
1001.50
2.80
52.60
156.90
209.20
203.40
207.20
255.20
303.70
264.10
201.60
265.00
402.20
761.50
922.40
1020.10
1099.00
1207.70
1430.50
1777.30
2226.30
10.50
10.20
34.70
51.80
64.30
67.10
75.20
71.40
67.10
60.50
54.60
84.80
96.80
110.20
147.40
163.20
203.50
290.60
346.10
109
1954
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
172.49
33.10
45.00
77.20
44.60
48.10
74.40
113.00
91.90
61.30
56.80
93.60
159.90
147.20
146.30
98.30
93.50
135.20
157.30
179.50
189.60
12.93
25.90
35.05
22.89
18.84
28.57
48.51
43.34
37.02
37.81
39.27
53.46
55.56
49.56
32.04
32.24
54.38
71.78
90.08
68.60
209.90
355.30
469.90
262.30
230.40
261.60
472.80
445.60
361.60
288.20
258.70
420.30
420.50
494.50
405.10
418.80
588.20
645.20
641.00
459.30
703.20
1170.60
2015.80
2803.30
2039.70
2256.20
2132.20
1834.10
1588.00
1749.40
1687.20
2007.70
2208.30
1656.70
1604.40
1431.80
1610.50
1819.40
2079.70
2371.60
2759.90
191.50
516.00
729.00
560.40
519.90
628.50
537.10
561.20
617.20
626.70
737.20
760.50
581.40
662.30
583.80
635.20
723.80
864.10
1193.50
1188.90
1362.40
1807.10
2676.30
1801.90
1957.30
2202.90
2380.50
2168.60
1985.10
1813.90
1850.20
2067.70
1796.70
1625.80
1667.00
1677.40
2289.50
2159.40
2031.30
2115.50
414.90
97.80
104.40
118.00
156.20
172.60
186.60
220.90
287.80
319.90
321.30
319.60
346.00
456.40
543.40
618.30
647.40
671.30
726.10
800.30
888.90
1.80
.80
7.40
18.10
23.50
26.50
36.20
60.80
84.40
91.20
92.40
86.00
111.10
130.60
141.80
136.70
129.70
145.50
174.80
213.50
53.80
50.50
118.10
260.20
312.70
254.20
261.40
298.70
301.80
279.10
213.80
232.60
264.80
306.90
351.10
357.80
342.10
444.20
623.60
669.70
?
? Variables specific to this problem.
?
Create ; y=i ; i=firm $
Namelist ; X=one,f,c $
?------------------------------------------------? The general procedure.
?------------------------------------------------? Step 1. Get starting values by pooled OLS
?
110
Sample ; All $
Regress ; Lhs = y ; Rhs = X ; Res = e $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = Y
Mean=
248.9570000
, S.D.=
267.8654462
|
| Model size: Observations =
100, Parameters =
3, Deg.Fr.=
97 |
| Residuals: Sum of squares= 1570883.687
, Std.Dev.=
127.25831 |
| Fit:
R-squared= .778856, Adjusted R-squared =
.77430 |
| Model test: F[ 2,
97] = 170.81,
Prob value =
.00000 |
| Diagnostic: Log-L =
-624.9928, Restricted(b=0) Log-L =
-700.4398 |
|
LogAmemiyaPrCrt.=
9.722, Akaike Info. Crt.=
12.560 |
| Autocorrel: Durbin-Watson Statistic =
.35995,
Rho =
.82002 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -48.02973763
21.480165
-2.236
.0276
F
.1050854108
.11377830E-01
9.236
.0000 1922.2230
C
.3053655452
.43507814E-01
7.019
.0000 311.06700
*/
Matrix ; b0 = b $
Calc
; G = max(i) $
Matrix ; Var = Init(G,1,0) $
Calc
; q = 1 $
?
? Step 2. Get group variances
?
Procedure
Calc
; Group = 0 $
Label
; 2 $
Calc
; Group = Group + 1 $
Include ; new ; i = Group $
Calc
; s2i=e'e/n $
Matrix ; Var(group) = s2i $
GoTo
; 2 ; Group < G $
?
? Step 3. Compute GLS
?
Sample ; All $
Create ; Weight = Var(i) $
Matrix ; Bgls = <X'<Weight>X> * X'<Weight>y
; Vgls = <X'<Weight>X>
; d = Bgls - b0 ; b0 = Bgls $
Create ; e = y - X'Bgls ; Logw = Log(Weight) $
Matrix ; Alogl = e'<Weight>e $
Calc
; list ; q = d'd
; Alogl = Alogl -.5*( n*log(2*pi)
+ sum(Logw) + alogl ) $
EndProc $
111
112
/*==================================================================
Example 11.4. GMM Estimation of a gamma distribution.
Example 11.5. Continued
*/==================================================================
read;nobs=20;nvar=3;names=
I,
Y,
X $
1
20.5
12
2
31.5
16
3
47.7
18
4
26.2
16
5
44.0
12
6
8.28
12
7
30.8
16
8
17.2
12
9
19.9
10
10
9.96
12
11
55.8
16
12
25.2
20
13
29.0
12
14
85.5
16
15
15.1
10
16
28.5
18
17
21.4
16
18
17.7
20
19
6.42
12
20
84.9
16
?------------------------------------------------------------? First compute moments. With 'i' = variable, then means.
?------------------------------------------------------------Create ; m1i=y
; m2i=y*y
; mstari=log(y)
; m_1i=1/y$
Calc
; list ; m1=xbr(m1i)
; m2=xbr(m2i)
; mstar=xbr(mstari)
; m_1=xbr(m_1i) $
?------------------------------------------------------------? Starting value for solutions to moment equations. If
? P=1, Lambda = 1/y-bar. Use these as initial guesses.
?------------------------------------------------------------Calc
; l0 = 1/m1$
?------------------------------------------------------------? Start with simple least squares
?------------------------------------------------------------Sample ; 1 $
?
? Obtain starting values by ML. Just use m1 and mstar
?
Minimize
; fcn=( l*m1 - p )^2 + (mstar - psi(p) + log(l))^2
; labels=p,l
; start = 1,l0 ; output=2 $
113
/*
1st derivs.
-.13018D-05
.37090D-04
Itr 9 F= .4244D-12 gtHg= .9641D-06 chg.F=
* Converged
Normal exit from iterations. Exit status=0.
.4236D-08 max|db|=
.1873D-05
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
1
|
| Iterations completed
9
|
| Log likelihood function
-.4243523E-12 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
2.410597740
1.0000000
2.411
.0159
L
.7707008485E-01 1.0000000
.077
.9386
*/
Calc
; p0 = p ; l0 = l $
?
? Now obtain method of moments estimates using all 4.
?
Minimize
; fcn=( l*m1 - p )^2 +
(l*l*m2 - p*(p+1))^2 +
(mstar - psi(p) + log(l))^2 +
((p-1)*m_1 - l) ^2
; labels=p,l
; start = p0,l0 ; output=2 $
/*
1st derivs.
-.37623D-07
.19079D-05
Itr 6 F= .7531D-03 gtHg= .3809D-07 chg.F= .2597D-10 max|db|= .4724D-07
* Converged
Normal exit from iterations. Exit status=0.
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
1
|
| Iterations completed
6
|
| Log likelihood function
-.7530752E-03 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
2.179917312
1.0000000
2.180
.0293
L
.6905767606E-01 1.0000000
.069
.9449
*/
114
?
? Compute W matrix for GMM
?
Sample ; 1 - 20 $
Calc
; P0 = b(1) ; l0 = b(2)
; j1 = l0 ; j2 = l0*l0 ; j3 = 1 ; J4 = P0-1 $
Create ; m10i = m1i - p0/l0
; m20i = m2i - p0*(p0+1)/l0^2
; m30i = mstari - psi(p0) + log(l0)
; m40i = m_1i - l0/(p0-1) $
Namelist ; M0 = m10i,m20i,m30i,m40i $
Matrix
; list ; W0 = .05 * Xvcm(M0) $
Matrix
; J = [j1/0,j2/0,0,j3/0,0,0,j4]
; JWJ = J*W0*J ; JWJi = <JWJ> $
Calc
; w11= JWJi(1,1)
; w12=2*JWJi(1,2) ; w22= JWJi(2,2)
; w13=2*JWJi(1,3) ; w23=2*JWJi(2,3) ; w33= JWJi(3,3)
; w14=2*JWJi(1,4) ; w24=2*JWJi(2,4) ; w34=2*JWJi(3,4) ;
w44=JWJi(4,4)$
Sample
; 1 $
Minimize
; fcn=
e1 = (l*m1-p)
|
e2 = (l*l*m2 - p*(p+1))
|
e3 = (mstar - psi(p) + log(l)) |
e4 = ((p-1)*m_1 - l)
|
e1^2 *w11 +
e1*e2*w12 + e2^2 *w22 +
e1*e3*w13 + e2*e3*w23 + e3^2*w33 +
e1*e4*w14 + e2*e4*w24 + e3*e4*w34 + e4^2 * w44
; labels=p,l
; start = p0,l0; output=2 $
/*
1st derivs.
-.24135D-05
.47747D-04
Itr 7 F= .2222D+01 gtHg= .1749D-06 chg.F= .1336D-11 max|db|=
* Converged
Normal exit from iterations. Exit status=0.
.1266D-07
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
1
|
| Iterations completed
7
|
| Log likelihood function
-2.222237
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
2.567535015
1.0000000
2.568
.0102
L
.7119341825E-01 1.0000000
.071
.9432
*/
115
?
? Obtain
?
Sample ;
Calc
;
;
?
Create ;
;
;
;
Namelist
Matrix
Matrix
/*
Matrix R
*/
Calc
;
;
;
;
;
;
Matrix
/*
Matrix VGMM
1 columns.
116
/*==================================================================
Example 11.5. Conclusion of Example 4.26. The Gamma Distribution
Completed in Ex11_4.lim
*/==================================================================
/*==================================================================
Example 11.6. Linear Models and GMM
No computations
*/==================================================================
/*==================================================================
Example 11.7. Testing for Heteroscedasticity in the Linear Regression Model
No computations
*/==================================================================
117
118
+-----------------------------------------------------------------------+
| Linearly restricted regression
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = EXP
Mean=
262.5320833
, S.D.=
318.0468313
|
| Model size: Observations =
72, Parameters =
3, Deg.Fr.=
69 |
| Residuals: Sum of squares= 6722771.645
, Std.Dev.=
312.14015 |
| Fit:
R-squared= .063931, Adjusted R-squared =
.03680 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
69] =
2.36,
Prob value =
.10236 |
| Diagnostic: Log-L =
-514.1600, Restricted(b=0) Log-L =
-516.5384 |
|
LogAmemiyaPrCrt.=
11.528, Akaike Info. Crt.=
14.366 |
| Note, when restrictions are imposed, R-squared can be less than zero. |
| F[ 2,
67] for the restrictions =
7.9561, Prob =
.0008
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 104.9381522
172.71017
.608
.5455
AGE
3.397084795
5.7618001
.590
.5575 31.277778
OWNRENT
136.9084474
84.534850
1.620
.1100 .37500000
INCOME
.8526512829E-13 .46512507E-05
.000 1.0000 3.4370833
INCOMESQ -.1598721155E-13 .58140634E-06
.000 1.0000 14.661565
*/
Plot of Residuals Against Income
2000
1500
1000
500
0
-500
10
12
INCOME
/*==================================================================
Example 12.2. Inefficiency of Ordinary Least Squares
No computations
*/==================================================================
/*==================================================================
Example 12.3. Heteroscedasticity Due to Grouping
No computations
*/==================================================================
119
/*==================================================================
Example 12.4. Using the White Estimator
*/==================================================================
?
Read ; Nobs = 100 ; Nvar = 7 ; Names =
Derogs,Card,Age,Income,Exp,OwnRent,SelfEmpl $
<... Data appear in Example 10.7 ...>
Sample
; 1-100 $
Create
; Incomesq = Income^2 $
Namelist ; X = One,Age,OwnRent,Income,Incomesq $
Reject
; Exp = 0 $
?
Regress ; Lhs = Exp;Rhs=X ; Hetero
$
(White)
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Results Corrected for heteroskedasticity
|
| Breusch - Pagan chi-squared =
49.0616, with
4 degrees of freedom |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -237.1465136
212.99053
-1.113
.2695
AGE
-3.081814038
3.3016612
-.933
.3540 31.277778
OWNRENT
27.94090839
92.187777
.303
.7628 .37500000
INCOME
234.3470270
88.866352
2.637
.0104 3.4370833
INCOMESQ -14.99684418
6.9445635
-2.160
.0344 14.661565
*/
?
? See if income and square are still significant when the
? White corrected covariance matrix is used. (Yes)
?
Matrix
; bi=b(4:5)
; Vbi=part(varb,4,5,4,5)
; List ; WaldStat = bi'<Vbi>bi$
/*
Matrix WALDSTAT has 1 rows and 1 columns.
1
+-------------1| .2060415D+02
*/
?
? Davidson and MacKinnon recommended corrections
?
Calc
; Scale = N/(N-Col(X)) $
Matrix
; DM1 = Scale * VARB ; Stat(B,DM1) $
Matrix statistical results: Coefficients=B
Variance=DM1
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B
_ 1 -237.1465136
220.79495
-1.074
.2828
B
_ 2 -3.081814038
3.4226411
-.900
.3679
B
_ 3 27.94090839
95.565731
.292
.7700
B
_ 4 234.3470270
92.122602
2.544
.0110
B
_ 5 -14.99684418
7.1990269
-2.083
.0372
*/
120
Matrix
; XXI=<X'X> $
Create
; v = u^2 /(1-qfr(X,XXI))$
Matrix
; DM2=XXI * X'[v]X * XXI $
Matrix
; Stat(b,DM2)$
/*
Matrix statistical results: Coefficients=B
Variance=DM2
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B
_ 1 -237.1465136
221.08893
-1.073
.2834
B
_ 2 -3.081814038
3.4477148
-.894
.3714
B
_ 3 27.94090839
95.672111
.292
.7702
B
_ 4 234.3470270
92.083684
2.545
.0109
B
_ 5 -14.99684418
7.1995375
-2.083
.0372
*/
/*==================================================================
Example 12.5. Testing for Heteroscedasticity
*/==================================================================
Read ; Nobs = 100 ; Nvar = 7
; Names =
Derogs,Card,Age,Income,Exp,OwnRent,SelfEmpl $
<... Data appear in Example 10.7 ...>
?
? Get a set of residuals
?
Regress ; Lhs = Exp ; Rhs = X ; Res = E $
Create
; U = E^2 $
?
? White's test.
?
Create
; Age2=Age^2 ; Income3=Income^3 ; Income4=Income^4
; Agerent=Age*Ownrent ; Ageinc=Age*Income
; Ageinc2=Age*Incomesq ; Rentinc=Ownrent*Income
; Rentinc2=Ownrent*Incomesq$
Namelist ; Z=X,Age2,Agerent,Ageinc,Ageinc2,RentInc,Rentinc2,
income3,income4$
Regr
; Lhs=u ; Rhs=z$
Calc
; List ; White=n * Rsqrd $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = U
Mean=
75452.25046
, S.D.=
279705.5299
|
| Model size: Observations =
72, Parameters = 13, Deg.Fr.=
59 |
| Residuals: Sum of squares= .4449239595E+13, Std.Dev.=
274610.34322 |
| Fit:
R-squared= .199013, Adjusted R-squared =
.03610 |
| Model test: F[ 12,
59] =
1.22,
Prob value =
.29051 |
| Diagnostic: Log-L =
-996.6588, Restricted(b=0) Log-L =
-1004.6475 |
|
LogAmemiyaPrCrt.=
25.212, Akaike Info. Crt.=
28.046 |
+-----------------------------------------------------------------------+
WHITE
= .14328953022237780D+02
*/
121
?
? Goldfeld and Quandt test
?
Sort
; Lhs = Income ; Rhs = * $ (Carry all variables)
Create
; j=trn(1,1)$ (Sequence numbers)
Reject
; j > 36 $
Regress ; Lhs = Exp ; Rhs = X $
Calc
; E1E1 = Sumsqdev $
Sample
;all $
Reject
; Exp = 0 $
Reject
; j <= 36 $
Regress ; Lhs = Exp ; Rhs = X $
Calc
; E2E2 = Sumsqdev ; List ; GQ = e2e2/e1e1 $
/*
GQ
= .15001289822041010D+02
*/
?
? Breusch and Pagan - Godfrey LM test
?
Sample
; All $
Reject
; Exp=0 $
Calc
; een = e'e/n $
Create
; g = u/een - 1$
Namelist ; Z = One,Income,IncomeSQ $
Matrix
; list ; LMtest = .5 * g'Z * <Z'Z> * Z'g $
/*
Matrix LMTEST
has 1 rows and 1 columns.
1
+-------------1| .4192030D+02
*/
?
? Koenker and Bassett variant
?
Create
; devu=u-een $
Calc
; Vdu=Devu'Devu/n $
Matrix
; list ; LMKB=1/Vdu * devu'Z * <Z'Z> * Z'devu $
/*
Matrix LMKB
has 1 rows and 1 columns.
1
+-------------1| .6186868D+01
*/
?
? Glesjer's tests. Uses White VC and tests a=0.
?
Create
; w1=u ; w2=abs(e) ; w3=log(w2)$
Regress ; Lhs=w1 ; Rhs=Z ; het ; cls:b(2)=0,b(3)=0 $
122
/*
+-----------------------------------------------------------------------+
| Linearly restricted regression
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = W1
Mean=
75452.25046
, S.D.=
279705.5299
|
| Model size: Observations =
72, Parameters =
1, Deg.Fr.=
71 |
| Residuals: Sum of squares= .5554698027E+13, Std.Dev.=
279705.52995 |
| Fit:
R-squared= .000000, Adjusted R-squared =
.00000 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Diagnostic: Log-L = -1004.6475, Restricted(b=0) Log-L =
-1004.6475 |
|
LogAmemiyaPrCrt.=
25.097, Akaike Info. Crt.=
27.935 |
| Note, when restrictions are imposed, R-squared can be less than zero. |
| F[ 2,
69] for the restrictions =
3.2432, Prob =
.0451
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 75452.25046
32963.613
2.289
.0251
INCOME
.3492459655E-09 .41679372E-02
.000 1.0000 3.4370833
INCOMESQ -.4001776688E-10........(Fixed Parameter)........ 14.661565
*/
Regress
/*
+-----------------------------------------------------------------------+
| Linearly restricted regression
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = W2
Mean=
164.6520947
, S.D.=
221.4109539
|
| Model size: Observations =
72, Parameters =
1, Deg.Fr.=
71 |
| Residuals: Sum of squares= 3480619.547
, Std.Dev.=
221.41095 |
| Fit:
R-squared= .000000, Adjusted R-squared =
.00000 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Diagnostic: Log-L =
-490.4615, Restricted(b=0) Log-L =
-490.4615 |
|
LogAmemiyaPrCrt.=
10.814, Akaike Info. Crt.=
13.652 |
| Note, when restrictions are imposed, R-squared can be less than zero. |
| F[ 2,
69] for the restrictions =
6.9346, Prob =
.0018
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 164.6520947
26.093531
6.310
.0000
INCOME
-.1421085472E-12 .32992803E-05
.000 1.0000 3.4370833
INCOMESQ .1065814104E-13........(Fixed Parameter)........ 14.661565
*/
123
Regress
/*
+-----------------------------------------------------------------------+
| Linearly restricted regression
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = W3
Mean=
4.545233426
, S.D.=
1.118941476
|
| Model size: Observations =
72, Parameters =
1, Deg.Fr.=
71 |
| Residuals: Sum of squares= 88.89413189
, Std.Dev.=
1.11894 |
| Fit:
R-squared= .000000, Adjusted R-squared =
.00000 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 1,
71] =
.00,
Prob value =
1.00000 |
| Diagnostic: Log-L =
-109.7517, Restricted(b=0) Log-L =
-109.7517 |
|
LogAmemiyaPrCrt.=
.239, Akaike Info. Crt.=
3.076 |
| Note, when restrictions are imposed, R-squared can be less than zero. |
| F[ 2,
69] for the restrictions =
12.0677, Prob =
.0000
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 4.545233426
.13186852
34.468
.0000
INCOME
.1998401444E-14........(Fixed Parameter)........ 3.4370833
INCOMESQ -.1942890293E-15 .14737455E-08
.000 1.0000 14.661565
*/
/*==================================================================
Example 12.6. Groupwise Heteroscedasticity
No Computations
*/==================================================================
/*==================================================================
Example 12.7. Two Step Estimation of a Heteroscedastic Regression
*/==================================================================
Read ; Nobs = 100 ; Nvar = 7
; Names =
Derogs,Card,Age,Income,Exp,OwnRent,SelfEmpl $
<... Data appear in Example 10.7 ...>
?
?---------------------------------------------------------? 1. Unweighted Least Squares
Regress ; Lhs = Exp ; Rhs = X $
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -237.1465136
199.35166
-1.190
.2384
AGE
-3.081814038
5.5147165
-.559
.5781 31.277778
OWNRENT
27.94090839
82.922324
.337
.7372 .37500000
INCOME
234.3470270
80.365950
2.916
.0048 3.4370833
INCOMESQ -14.99684418
7.4693370
-2.008
.0487 14.661565
124
125
?
? 6. Variance proportional to exp(z'alpha)Z=1,Income,IncomeSq
?
Create
; ee=log((abs(e))^2)$
Namelist ; Z=one,income,incomesq$
Matrix
; alpha = <Z'Z>*Z'ee $
Create
; wt = 1/exp(Z'Alpha) $
Regress ; Lhs = Exp ; Rhs = X ; Wts = wt $
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -117.8674510
101.38621
-1.163
.2491
AGE
-1.233682303
2.5511958
-.484
.6303 33.826036
OWNRENT
50.94976258
52.814292
.965
.3382 .71458039
INCOME
145.3044547
46.362697
3.134
.0026 7.1415528
INCOMESQ -7.938279996
3.7367153
-2.124
.0373 64.604359
*/
? ---------------------------------------------------------Two Step Estimation of a Heteroscedastic Regression
? ---------------------------------------------------------Regress ; Lhs = Exp ; Rhs = X ; Res = e $
Create
; loginc=log(income)$
Namelist ; Z=one,loginc$
Procedure
Create ; Logee=log(e*e)$
Matrix ; Bold=B ; Alpha = <Z'Z> * Z'Logee$
Create ; Wt= 1/exp(Z'alpha)$
Regress; Lhs=exp ; Rhs=X ; Wts=wt ; Res=e$
Matrix ; Delta=B-Bold ; Cnv=Delta'Delta$
Endproc
Calc
; Cnv=1$
Execute Procedure ; While Cnv > .00001 $
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -193.3253320
171.08329
-1.130
.2625
AGE
-2.957871315
4.7626896
-.621
.5367 30.295399
OWNRENT
47.35698663
72.138933
.656
.5138 .30875365
INCOME
208.8759353
77.198018
2.706
.0086 2.9683339
INCOMESQ -12.76880393
8.0838301
-1.580
.1189 10.579641
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -130.3854224
145.03664
-.899
.3719
AGE
-2.775374205
3.9817421
-.697
.4882 29.305900
OWNRENT
59.12564268
61.043596
.969
.3362 .25482015
INCOME
169.7372086
76.179924
2.228
.0292 2.5942699
INCOMESQ -8.599603984
9.3133061
-.923
.3591 7.7722505
126
Hreg
/*
+---------------------------------------------+
| Multiplicative Heteroskedastic Regr. Model |
| Maximum Likelihood Estimates
|
| Dependent variable
EXP
|
| Weighting variable
ONE
|
| Number of observations
72
|
| Iterations completed
13
|
| Log likelihood function
-482.3243
|
| Restricted log likelihood
-506.4888
|
| Chi-squared
48.32899
|
| Degrees of freedom
1
|
| Significance level
.0000000
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Regression (mean) function
Constant -19.24884795
113.05739
-.170
.8648
AGE
-1.705823279
2.7581505
-.618
.5363 31.277778
OWNRENT
58.10213435
43.508335
1.335
.1817 .37500000
INCOME
75.97012488
81.039539
.937
.3485 3.4370833
INCOMESQ 4.391516361
13.433286
.327
.7437 14.661565
Variance function (log-linear)
Sigma
24.51179166
5.9326334
4.132
.0000
LOGINC
3.651373863
.39873679
9.157
.0000 1.1397657
*/
127
/*==================================================================
Example 12.8. Maximum Likelihood Estimation
*/==================================================================
Read ; Nobs = 100 ; Nvar = 7
; Names =
Derogs,Card,Age,Income,Exp,OwnRent,SelfEmpl $
<... Data appear in Exasmple 10.7 ...>
?
? This routine produces a plot of the concentrated log
? likelihood
?
Create ; Loginc = Log(Income) $
Calc
; SumL = Sum(Loginc) ; i = 0 $
Matrix ; Alpha = init(101,1,0.); LogLHREG=Alpha$
Procdure
Create ; Wt= 1/income^a$
Matrix ; Bw = <X'[wt]x> * X'[Wt]Exp $
Create ; GSQ=(exp-X'bw)^2 * Wt$
Calc
; Ssw=Sum(GSQ)/n
; loglw=-n/2*(1+log(2*pi)+log(ssw))-(a/2)*SumL
; i=i+1$
Matrix ; Alpha(i)=a ; LogLHREG(i)=loglw$
Endproc
Execute; a=0,5,.05$
?
Mplot ; Lhs=alpha;Rhs=Loglhreg;fill;grid
; Title=Plot of Concentrated Log Likelihood$
LO G LH R EG
-480
-490
-500
-510
-1
ALPHA
128
/*==================================================================
Example 12.9. Multiplicative Heteroscedasticity
*/==================================================================
Read ; Nobs = 100 ; Nvar = 7 ; Names =
Derogs,Card,Age,Income,Exp,OwnRent,SelfEmpl $
<... Data appear in Example 10.7 ...>
Namelist ; X = One,Age,OwnRent,Income,IncomeSq
; Z = One,Income,IncomeSq $
? Collect ordinary least squares results.
Regress ; Lhs = Exp ; Rhs = X ; Res = E $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = EXP
Mean=
262.5320833
, S.D.=
318.0468313
|
| Model size: Observations =
72, Parameters =
5, Deg.Fr.=
67 |
| Residuals: Sum of squares= 5432562.033
, Std.Dev.=
284.75080 |
| Fit:
R-squared= .243578, Adjusted R-squared =
.19842 |
| Model test: F[ 4,
67] =
5.39,
Prob value =
.00080 |
| Diagnostic: Log-L =
-506.4888, Restricted(b=0) Log-L =
-516.5384 |
|
LogAmemiyaPrCrt.=
11.370, Akaike Info. Crt.=
14.208 |
| Autocorrel: Durbin-Watson Statistic =
1.64003,
Rho =
.17998 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -237.1465136
199.35166
-1.190
.2384
AGE
-3.081814038
5.5147165
-.559
.5781 31.277778
OWNRENT
27.94090839
82.922324
.337
.7372 .37500000
INCOME
234.3470270
80.365950
2.916
.0048 3.4370833
INCOMESQ -14.99684418
7.4693370
-2.008
.0487 14.661565
*/
Calc
; LoglR = LogL ; c1 = log(e'e/n) ; Cnv=1 ; iter=0$
Matrix
; c = [c1/0/0] ; beta = b $
Namelist ; Z = One,Income,IncomeSq $
Create
; h=e*e/exp(c1) ; g = h-1
; Wts=1/Exp(Z'c) ; logfi=c1$
Matrix
; List ; LMTest=.5*g'Z*<Z'[h]Z> * Z'g $
/*
Matrix LMTEST
has 1 rows and 1 columns.
1
+-------------1| .1158990D+03
*/
? This is actually unnecessary, as the HREG command
? fits this model. We do it here for illustration.
?
Procedure for iteration for multiplicative model.
Matrix
; Beta = <X'[Wts]X> * X'[Wts]Exp
; delta = <Z'Z> * Z'g ; c=c+Delta $
Create
; E = Exp - X'Beta ; Wts=1/exp(Z'c)
; h = e*e *Wts ; g=h-1 ; logfi=Z'c$
Calc
; LoglU = -n/2*log(2*pi)-1/2*Sum(logfi)-1/2*sum(h)
; List ; Iter=Iter+1 ; Cnv = Delta'Delta $
EndProcedure
Calc
; Cnv = 1 $
Execute ; While Cnv > .0000001$
129
130
Residual
10
0
-10
-20
-30
-40
1963
1967
1971
1975
1979
1983
Year
131
/*======================================================================
Example 13.2. Autocorrelation Induced by Misspecification of the Model
/*======================================================================
Read ; Nobs = 36 ; Nvar = 11 ; Names = 1 $
Year
G
Pg
Y
Pnc
Puc
Ppt
Pd
Pn
Ps
Pop
1960 129.7
.925 6036 1.045
.836
.810
.444
.331
.302 180.7
1961 131.3
.914 6113 1.045
.869
.846
.448
.335
.307 183.7
1962 137.1
.919 6271 1.041
.948
.874
.457
.338
.314 186.5
1963 141.6
.918 6378 1.035
.960
.885
.463
.343
.320 189.2
1964 148.8
.914 6727 1.032 1.001
.901
.470
.347
.325 191.9
1965 155.9
.949 7027 1.009
.994
.919
.471
.353
.332 194.3
1966 164.9
.970 7280
.991
.970
.952
.475
.366
.342 196.6
1967 171.0 1.000 7513 1.000 1.000 1.000
.483
.375
.353 198.7
1968 183.4 1.014 7728 1.028 1.028 1.046
.501
.390
.368 200.7
1969 195.8 1.047 7891 1.044 1.031 1.127
.514
.409
.386 202.7
1970 207.4 1.056 8134 1.076 1.043 1.285
.527
.427
.407 205.1
1971 218.3 1.063 8322 1.120 1.102 1.377
.547
.442
.431 207.7
1972 226.8 1.076 8562 1.110 1.105 1.434
.555
.458
.451 209.9
1973 237.9 1.181 9042 1.111 1.176 1.448
.566
.497
.474 211.9
1974 225.8 1.599 8867 1.175 1.226 1.480
.604
.572
.513 213.9
1975 232.4 1.708 8944 1.276 1.464 1.586
.659
.615
.556 216.0
1976 241.7 1.779 9175 1.357 1.679 1.742
.695
.638
.598 218.0
1977 249.2 1.882 9381 1.429 1.828 1.824
.727
.671
.648 220.2
1978 261.3 1.963 9735 1.538 1.865 1.878
.769
.719
.698 222.6
1979 248.9 2.656 9829 1.660 2.010 2.003
.821
.800
.756 225.1
1980 226.8 3.691 9722 1.793 2.081 2.516
.892
.894
.839 227.7
1981 225.6 4.109 9769 1.902 2.569 3.120
.957
.969
.926 230.0
1982 228.8 3.894 9725 1.976 2.964 3.460 1.000 1.000 1.000 232.2
1983 239.6 3.764 9930 2.026 3.297 3.626 1.041 1.021 1.062 234.3
1984 244.7 3.707 10421 2.085 3.757 3.852 1.038 1.050 1.117 236.3
1985 245.8 3.738 10563 2.152 3.797 4.028 1.045 1.075 1.173 238.5
1986 269.4 2.921 10780 2.240 3.632 4.264 1.053 1.069 1.224 240.7
1987 276.8 3.038 10859 2.321 3.776 4.413 1.085 1.111 1.271 242.8
1988 279.9 3.065 11186 2.368 3.939 4.494 1.105 1.152 1.336 245.0
1989 284.1 3.353 11300 2.414 4.019 4.719 1.129 1.213 1.408 247.3
1990 282.0 3.834 11389 2.451 3.926 5.197 1.144 1.285 1.482 249.9
1991 271.8 3.766 11272 2.538 3.942 5.427 1.167 1.332 1.557 252.6
1992 280.2 3.751 11466 2.528 4.113 5.518 1.184 1.358 1.625 255.4
1993 286.7 3.713 11476 2.663 4.470 6.086 1.200 1.379 1.684 258.1
1994 290.2 3.732 11636 2.754 4.730 6.268 1.225 1.396 1.734 260.7
1995 297.8 3.789 11934 2.815 5.224 6.410 1.239 1.419 1.786 263.2
Create ; G=G/Pop
; lg=log(g) ; lpg=log(pg) ; ly=log(y) ; lpnc=log(pnc)
; lpuc=log(puc) ; lpd=log(pd) ; lpn=log(pn) ; lppt=log(ppt)
; lpd=log(pd)
; lps=log(ps) ; t=year - 1959 $
Date
; 1960 $
Period ; 1960-1995 $
Regress ; lhs = lg ; Rhs = One,lpg ; Plot $
Regress ; lhs = lg ; Rhs = One,lpg,ly ; Plot $
Regress ; lhs = lg ; Rhs = One,lpg,ly,lpnc,lpuc,lppt,lpn,lpd,lps,t ; Plot $
Create ; post=year > 1973
; p1=post*lpg ; p2=post*ly ; p3=post*lpnc ; p4=post*lpuc
; p5=post*lppt ; p6=post*lpn ; p7=post*lpd ;p8=post*lps ; p9=post*t $
Regress ; lhs = lg ; Rhs = One,lpg,ly,lpnc,lpuc,lppt,lpn,lpd,lps,t,
post,p1,p2,p3,p4,p5,p6,p7,p8,p9 ; PlotResiduals $
132
.150
.050
.075
Residual
Residual
.025
.000
.000
-.025
-.075
-.050
-.150
-.075
-.225
1959 1964 1969 1974 1979 1984 1989 1994 1999
-.100
1959 1964 1969 1974 1979 1984 1989 1994 1999
Year
Year
.02
.02
.01
Residual
Residual
.01
.00
-.01
.00
-.01
-.02
-.02
-.03
-.04
1959 1964 1969 1974 1979 1984 1989 1994 1999
Year
-.03
1959 1964 1969 1974 1979 1984 1989 1994 1999
Year
133
/*===============================================================
Example 13.3. Autocorrelation Consistent Covariance Estimation
*/===============================================================
Read ; Nobs = 20 ; Nvar = 5 ; Names = 1 $
<... Data are in Example 13.1 ...>
Create ; If(_Obsno > 1)DP = 100*(Price - Price[-1])/Price[-1] $
Create ; RealInt = Interest - DP
; RealGNP = GNP/Price
; RealNvst= Invest/Price $
Dates ; 1963 $
Period ; 1964 - 1982 $
?
? Uncorrected
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = REALNVST Mean=
192.4258285
, S.D.=
37.62753735
|
| Model size: Observations =
19, Parameters =
3, Deg.Fr.=
16 |
| Residuals: Sum of squares= 4738.626169
, Std.Dev.=
17.20942 |
| Fit:
R-squared= .814062, Adjusted R-squared =
.79082 |
| Model test: F[ 2,
16] =
35.03,
Prob value =
.00000 |
| Diagnostic: Log-L =
-79.3909, Restricted(b=0) Log-L =
-95.3732 |
|
LogAmemiyaPrCrt.=
5.838, Akaike Info. Crt.=
8.673 |
| Autocorrel: Durbin-Watson Statistic =
1.32151,
Rho =
.33924 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -12.53360059
24.915269
-.503
.6218
REALGNP
.1691364542
.20566451E-01
8.224
.0000 1217.5764
REALINT -1.001438013
2.3687491
-.423
.6781 .97572578
*/
?
? Newey-West with 4 periods
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt ;Pds = 4 $
/*
+-----------------------------------------------------------------------+
| Autocorrelation consistent covariance matrix for lags of 4 periods
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -12.53360059
18.958298
-.661
.5179
REALGNP
.1691364542
.16750786E-01
10.097
.0000 1217.5764
REALINT -1.001438013
3.3423754
-.300
.7683 .97572578
*/
134
/*===============================================================
Example 13.4. Durbin-Watson Test
*/===============================================================
Read ; Nobs = 20 ; Nvar = 5 ; Names = 1 $
<... Data are in Example 13.1 ...>
Create ; If(_Obsno > 1)DP = 100*(Price - Price[-1])/Price[-1] $
Create ; RealInt = Interest - DP
; RealGNP = GNP/Price
; RealNvst= Invest/Price $
Dates ; 1963 $
Period ; 1964 - 1982 $
?
? Uncorrected
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = REALNVST Mean=
192.4258285
, S.D.=
37.62753735
|
| Model size: Observations =
19, Parameters =
3, Deg.Fr.=
16 |
| Residuals: Sum of squares= 4738.626169
, Std.Dev.=
17.20942 |
| Fit:
R-squared= .814062, Adjusted R-squared =
.79082 |
| Model test: F[ 2,
16] =
35.03,
Prob value =
.00000 |
| Diagnostic: Log-L =
-79.3909, Restricted(b=0) Log-L =
-95.3732 |
|
LogAmemiyaPrCrt.=
5.838, Akaike Info. Crt.=
8.673 |
| Autocorrel: Durbin-Watson Statistic =
1.32151,
Rho =
.33924 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -12.53360059
24.915269
-.503
.6218
REALGNP
.1691364542
.20566451E-01
8.224
.0000 1217.5764
REALINT -1.001438013
2.3687491
-.423
.6781 .97572578
*/
?
? This is from the earlier regression
?
/*
+-----------------------------------------------------------------------+
| Autocorrel: Durbin-Watson Statistic =
1.32151,
Rho =
.33924 |
+-----------------------------------------------------------------------+
*/
135
/*===============================================================
Example 13.5. Tests of Autocorrelation
*/===============================================================
Read ; Nobs = 20 ; Nvar = 5 ; Names = 1 $
<... Data are in Example 13.1 ...>
Create ; If(_Obsno > 1)DP = 100*(Price - Price[-1])/Price[-1] $
Create ; RealInt = Interest - DP ; RealGNP = GNP/Price
; RealNvst= Invest/Price $
Dates ; 1963 $
Period ; 1964 - 1982 $
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt ; Res = e $
Create ; e1=0 ; e2=0 ; e3=0 ; e4 = 0 $
Create ; If(Year > 1964) e1=e[-1] ; If(Year > 1965) e2=e[-2] $
Create ; If(Year > 1966) e3=e[-3] ; If(Year > 1967) e4=e[-4] $
Regress; Lhs = e ; Rhs = One,RealGNP,RealInt,e1,e2,e3,e4 $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = E
Mean=
.2692582999E-13, S.D.=
16.22519674
|
| Model size: Observations =
19, Parameters =
7, Deg.Fr.=
12 |
| Residuals: Sum of squares= 1728.432029
, Std.Dev.=
12.00150 |
| Fit:
R-squared= .635246, Adjusted R-squared =
.45287 |
| Model test: F[ 6,
12] =
3.48,
Prob value =
.03129 |
| Autocorrel: Durbin-Watson Statistic =
2.14283,
Rho =
-.07142 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -.9840129568
17.570750
-.056
.9563
REALGNP -.2737440451E-03 .14506081E-01
-.019
.9853 1217.5764
REALINT
4.781480338
2.0801228
2.299
.0403 .97572578
E1
-.3866480026
.30834110
-1.254
.2337 1.7543872
E2
-.2851881078
.32520577
-.877
.3977 1.5487491
E3
-.8375322739
.36154515
-2.317
.0390 2.0273388
E4
-.6398668666
.37206559
-1.720
.1111 .82848421
*/
Calc
; List ; LMG_G = n * Rsqrd ; Ctb(.95,5) ; Ctb(.99,4) $
/*
LMG_G
= .12069677290650900D+02
Result = .11070497756249990D+02
Result = .13276704137459990D+02
*/
Period
; 1964-1982 $
Identify ; Rhs = e ; Pds = 4 $
/*
Time series identification for E
Box-Pierce Statistic =
9.5330
Box-Ljung Statistic =
12.4321
Degrees of freedom
=
4
Degrees of freedom
=
4
Significance level
=
.0491
Significance level
=
.0144
* => |coefficient| > 2/sqrt(N) or > 95% significant.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Lag | Autocorrelation Function
|Box/Prc|
Partial Autocorrelations
X
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1 | .222 |
|**
|
.94 | .222 |
|**
X
2 |-.239 |
***|
| 2.02 |-.457 |
***** |
X
3 |-.558*|
******|
| 7.93*|-.699*|
******** |
X
4 |-.291 |
***|
| 9.53*|-.386 |
**** |
X
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*/
/*===============================================================
Example 13.6. Estimation of rho in the AR(1) Model
136
*/===============================================================
Read ; Nobs = 20 ; Nvar = 5 ; Names = 1 $
<... Data are in Example 13.1 ...>
Create ; If(_Obsno > 1)DP = 100*(Price - Price[-1])/Price[-1] $
Create ; RealInt = Interest - DP
; RealGNP = GNP/Price
; RealNvst= Invest/Price $
Dates ; 1963 $
Period ; 1964 - 1982 $
?
? Least Squares
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = REALNVST Mean=
192.4258285
, S.D.=
37.62753735
|
| Model size: Observations =
19, Parameters =
3, Deg.Fr.=
16 |
| Residuals: Sum of squares= 4738.626169
, Std.Dev.=
17.20942 |
| Fit:
R-squared= .814062, Adjusted R-squared =
.79082 |
| Model test: F[ 2,
16] =
35.03,
Prob value =
.00000 |
| Diagnostic: Log-L =
-79.3909, Restricted(b=0) Log-L =
-95.3732 |
|
LogAmemiyaPrCrt.=
5.838, Akaike Info. Crt.=
8.673 |
| Autocorrel: Durbin-Watson Statistic =
1.32151,
Rho =
.33924 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -12.53360059
24.915269
-.503
.6218
REALGNP
.1691364542
.20566451E-01
8.224
.0000 1217.5764
REALINT -1.001438013
2.3687491
-.423
.6781 .97572578
*/
?
? Prais-Winsten, no iteration
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt ; Ar1 ; Maxit=1 $
/*
+---------------------------------------------+
| AR(1) Model:
e(t) = rho * e(t-1) + u(t) |
| Initial value of rho
=
.33924 |
| Iter= 1, SS=
4430.888, Log-L= -78.814170 |
| Final value of Rho
=
.35272 |
| Durbin-Watson:
e(t) =
1.29456 |
| Std. Deviation: e(t) =
17.78423 |
| Std. Deviation: u(t) =
16.64123 |
| Durbin-Watson:
u(t) =
1.83010 |
| Autocorrelation: u(t) =
.08495 |
| N[0,1] used for significance levels
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -15.65512900
33.764549
-.464
.6429
REALGNP
.1707344360
.27905479E-01
6.118
.0000 1217.5764
REALINT -.7039317251
2.8157615
-.250
.8026 .97572578
RHO
.3527183077
.22055357
1.599
.1098
*/
137
?
? Prais-Winsten, iterated
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt ; Ar1 $
/*
+---------------------------------------------+
| AR(1) Model:
e(t) = rho * e(t-1) + u(t) |
| Initial value of rho
=
.33924 |
| Iter= 2, SS=
4434.763, Log-L= -78.827770 |
| Final value of Rho
=
.33924 |
| Durbin-Watson:
e(t) =
1.29125 |
| Std. Deviation: e(t) =
17.69029 |
| Std. Deviation: u(t) =
16.64123 |
| Durbin-Watson:
u(t) =
1.84077 |
| Autocorrelation: u(t) =
.07961 |
| N[0,1] used for significance levels
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -15.65512900
33.764549
-.464
.6429
REALGNP
.1707344360
.27905479E-01
6.118
.0000 1217.5764
REALINT -.7039317251
2.8157615
-.250
.8026 .97572578
RHO
.3392438009
.22172476
1.530
.1260
*/
?
? Cochrane-Orcutt, no iteration
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt ; Ar1 ; Alg = Corc ;
Maxit=1$
/*
+---------------------------------------------+
| AR(1) Model:
e(t) = rho * e(t-1) + u(t) |
| Initial value of rho
=
.33924 |
| Maximum iterations
=
1 |
| Iter= 1, SS=
4428.177, Log-L= -78.808355 |
| Final value of Rho
=
.35592 |
| Durbin-Watson:
e(t) =
1.28816 |
| Std. Deviation: e(t) =
18.38569 |
| Std. Deviation: u(t) =
17.18173 |
| Durbin-Watson:
u(t) =
1.83080 |
| Autocorrelation: u(t) =
.08460 |
| N[0,1] used for significance levels
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -18.35665003
44.832617
-.409
.6822
REALGNP
.1728550839
.36328913E-01
4.758
.0000 1217.5764
REALINT -.8077352213
3.1024426
-.260
.7946 .97572578
RHO
.3559204945
.22026759
1.616
.1061
*/
?
? Cochrane-Orcutt, iterated
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt ; Ar1 ; Alg = Corc $
/*
138
+---------------------------------------------+
| AR(1) Model:
e(t) = rho * e(t-1) + u(t) |
| Initial value of rho
=
.33924 |
| Iter= 2, SS=
4432.635, Log-L= -78.824507 |
| Final value of Rho
=
.33924 |
| Durbin-Watson:
e(t) =
1.28251 |
| Std. Deviation: e(t) =
18.26486 |
| Std. Deviation: u(t) =
17.18173 |
| Durbin-Watson:
u(t) =
1.84420 |
| Autocorrelation: u(t) =
.07790 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -18.35665003
44.832617
-.409
.6822
REALGNP
.1728550839
.36328913E-01
4.758
.0000 1217.5764
REALINT -.8077352213
3.1024426
-.260
.7946 .97572578
RHO
.3392438009
.22172476
1.530
.1260
*/
?
? Maximum Likelihood
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt ; Ar1 ; Alg=MLE $
/*
+---------------------------------------------+
| AR(1) Model:
e(t) = rho * e(t-1) + u(t) |
| Initial value of rho
=
.33924 |
| Iter= 3, SS=
4427.608, Log-L= -78.786810 |
| Final value of Rho
=
.27957 |
| Durbin-Watson:
e(t) =
1.30606 |
| Std. Deviation: e(t) =
17.32595 |
| Std. Deviation: u(t) =
16.63507 |
| Durbin-Watson:
u(t) =
1.78681 |
| Autocorrelation: u(t) =
.10659 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -14.49886226
31.556137
-.459
.6459
REALGNP
.1700598065
.26075834E-01
6.522
.0000 1217.5764
REALINT -.8242123000
2.7180836
-.303
.7617 .97572578
RHO
.2795732015
.22630349
1.235
.2167
*/
? Durbin's estimator. Uses r(Durbin) in Cochrane-Orcutt
? First step to estimate rho
?
Period ; 1965-1982 $
Regress; Lhs = RealNvst ; Rhs = RealNvst[-1],
One,RealGNP,RealInt,RealGNP[-1],RealInt[-1]$
Calc
; Durbin = b(1) $
/*
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
REAL[-1] .6385436366
.12796334
4.990
.0003 191.98517
Constant -32.34674009
13.765052
-2.350
.0367
REALGNP
.6924822569
.61735020E-01
11.217
.0000 1236.5350
REALINT -1.560727766
1.6372713
-.953
.3593 .91797790
REAL[-1] -.6242457613
.64077072E-01
-9.742
.0000 1202.6972
REAL[-1] 1.820487907
2.0286062
.897
.3872 .75194352
*/
? Second step
139
?
Period ; 1964-1982 $
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt ; Ar1 ; Rho=Durbin $
/*
+---------------------------------------------+
| AR(1) Model:
e(t) = rho * e(t-1) + u(t) |
| Initial value of rho
=
.63854 |
| Iter= 1, SS=
4727.374, Log-L= -79.630253 |
| Final value of Rho
=
.63854 |
| Durbin-Watson:
e(t) =
1.08041 |
| Std. Deviation: e(t) =
22.33536 |
| Std. Deviation: u(t) =
17.18898 |
| Durbin-Watson:
u(t) =
1.93870 |
| Autocorrelation: u(t) =
.03065 |
| N[0,1] used for significance levels
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -35.68666732
53.137278
-.672
.5018
REALGNP
.1843982111
.43910331E-01
4.199
.0000 1217.5764
REALINT
.4984430353
3.3725989
.148
.8825 .97572578
RHO
.6385436366
.18139307
3.520
.0004
*/
?
? Hildreth-Lu grid search
?
Regress; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt
; Ar1 ; Alg = Grid(.1,.9,.03) $$
/*
+---------------------------------------------+
| AR(1) Model:
e(t) = rho * e(t-1) + u(t) |
| Initial value of rho
=
.33924 |
| Maximum iterations
=
20 |
| Method = Grid Search over interval
|
| Rho = .1000 to .9000 in steps of
.0300 |
| Iter= 27, SS=
4850.972, Log-L= -80.358033 |
| GLS with optimal rho
|
| Final value of Rho
=
.31000 |
| Durbin-Watson:
e(t) =
.36931 |
| Std. Deviation: e(t) =
17.49469 |
| Std. Deviation: u(t) =
16.63284 |
| Durbin-Watson:
u(t) =
1.80940 |
| Autocorrelation: u(t) =
.09530 |
| N[0,1] used for significance levels
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -15.03194914
32.628853
-.461
.6450
REALGNP
.1703660777
.26964694E-01
6.318
.0000 1217.5764
REALINT -.7678180718
2.7666129
-.278
.7814 .97572578
RHO
.3100000000
.22409076
1.383
.1666
*/
140
/*======================================================================
Example 13.7. Tests for common Factors
/*======================================================================
Read ; Nobs = 36 ; Nvar = 11 ; Names = 1 $
<... Data are in Example 13.2 ...>
Create ; G=G/Pop
; lg=log(g) ; lpg=log(pg) ; ly=log(y) ; lpnc=log(pnc)
; lpuc=log(puc) ; lpd=log(pd) ; lpn=log(pn) ; lppt=log(ppt)
; lpd=log(pd)
; lps=log(ps) ; t=year - 1959 $
Date
; 1960 $
Period ; 1960-1995 $
Period ; 1961-1995 $
?
? Original Model generates starting values for least squares
?
Regress ; Lhs = lg ; Rhs = one,lpg,ly,lpnc,lpuc $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
.5660123001E-02, S.D.=
.1429479464
|
| Model size: Observations =
35, Parameters =
5, Deg.Fr.=
30 |
| Residuals: Sum of squares= .3221515019E-01, Std.Dev.=
.03277 |
| Fit:
R-squared= .953631, Adjusted R-squared =
.94745 |
| Model test: F[ 4,
30] = 154.25,
Prob value =
.00000 |
| Diagnostic: Log-L =
72.6738, Restricted(b=0) Log-L =
18.9290 |
|
LogAmemiyaPrCrt.=
-6.703, Akaike Info. Crt.=
-3.867 |
| Autocorrel: Durbin-Watson Statistic =
.62880,
Rho =
.68560 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -12.59419663
.70019567
-17.987
.0000
LPG
-.5899395539E-01 .32220963E-01
-1.831
.0771 .69558165
LY
1.401655336
.78457513E-01
17.865
.0000 9.1225115
LPNC
-.1849482733
.13455582
-1.375
.1795 .45460339
LPUC
-.8964335606E-01 .84071091E-01
-1.066
.2948 .68769049
*/
?
? AR(1) model with nonlinear restrictions
? First create lagged values
Period ; 1960-1995 $
Create ; lg1=lg[-1]
; lpg1=lpg[-1] ; ly1=ly[-1]
; lpnc1=lpnc[-1] ; lpuc1=lpuc[-1] $
Period ; 1961-1995 $
Mini
; Fcn = (lg-(b1 + b2*(lpg-r*lpg1)
+ b3*(ly-r*ly1)
+ b4*(lpnc-r*lpnc1) + b5*(lpuc-r*lpuc1) + r*lg1))^2
; Labels=b1,b2,b3,b4,b5,r
; Start =b ; output=1 $maxit=500 $
/*
+---------------------------------------------+
| User Defined Optimization
|
| Maximum Likelihood Estimates
|
| Dependent variable
Function
|
| Weighting variable
ONE
|
| Number of observations
35
|
| Iterations completed
82
|
| Log likelihood function
-.1058078E-01 |
+---------------------------------------------+
141
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1
-.4615029339
1689.5382
.000
.9998
B2
-.2237281149
67.802613
-.003
.9974
B3
.8710401765
400.73680
.002
.9983
B4
.8423654168E-01 489.08698
.000
.9999
B5
-.4147907912E-01 136.72685
.000
.9998
R
.9402079240
196.82878
.005
.9962
*/
Calc
; list ; eer = logl $
/*
EER
= .10580776412476630D-01
*/
?
? Unrestricted model
?
Regress ; Lhs = lg ; Rhs=One,lpg,ly,lpnc,lpuc,lg1,lpg1,ly1,lpnc1,lpuc1 $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
.5660123001E-02, S.D.=
.1429479464
|
| Model size: Observations =
35, Parameters = 10, Deg.Fr.=
25 |
| Residuals: Sum of squares= .5681943859E-02, Std.Dev.=
.01508 |
| Fit:
R-squared= .991822, Adjusted R-squared =
.98888 |
| Model test: F[ 9,
25] = 336.88,
Prob value =
.00000 |
| Diagnostic: Log-L =
103.0388, Restricted(b=0) Log-L =
18.9290 |
|
LogAmemiyaPrCrt.=
-8.138, Akaike Info. Crt.=
-5.317 |
| Autocorrel: Durbin-Watson Statistic =
2.46386,
Rho =
-.23193 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -2.767067048
1.1651346
-2.375
.0255
LPG
-.2571382493
.34841096E-01
-7.380
.0000 .69558165
LY
.6945043254
.24726979
2.809
.0095 9.1225115
LPNC
.5271610467E-01 .18304866
.288
.7757 .45460339
LPUC
.8722096439E-01 .76151454E-01
1.145
.2629 .68769049
LG1
.8290331665
.98450499E-01
8.421
.0000 -.73433635E-02
LPG1
.2054211804
.40347106E-01
5.091
.0000 .65529411
LY1
-.3836343685
.23222987
-1.652
.1110 9.1030357
LPNC1
-.1747114895
.16764160
-1.042
.3073 .42629066
LPUC1
-.4688845523E-01 .59265160E-01
-.791
.4363 .63533649
*/
Calc
; List ; eeu = sumsqdev
; F = ((eer-eeu)/5)/(eeu/25)
; Ftb(.95,4,25) $
/*
EEU
= .56819438592170710D-02
F
= .43108772936156550D+01
Result = .27587104697200010D+01
*/
?
? Repeat common factor study for investment data
?
Reset $
Read ; Nobs = 20 ; Nvar = 5 ; Names = 1 $
<... Data are in Example 13.1 ...>
Create ; If(_Obsno > 1)DP = 100*(Price - Price[-1])/Price[-1] $
Create ; RealInt = Interest - DP
142
; RealGNP = GNP/Price
; RealNvst= Invest/Price $
Create ; GNP1 = RealGNP[-1]
; Nvst1= RealNvst[-1]
; Int1 = RealInt[-1] $
Dates ; 1963 $
Period ; 1965 - 1982 $
?
? Original Model generates starting values for least squares
?
Regress ; Lhs = RealNvst ; Rhs = one,RealGNP,RealInt $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = REALNVST Mean=
195.6802431
, S.D.=
35.86147600
|
| Model size: Observations =
18, Parameters =
3, Deg.Fr.=
15 |
| Residuals: Sum of squares= 4738.582002
, Std.Dev.=
17.77373 |
| Fit:
R-squared= .783258, Adjusted R-squared =
.75436 |
| Model test: F[ 2,
15] =
27.10,
Prob value =
.00001 |
| Diagnostic: Log-L =
-75.6990, Restricted(b=0) Log-L =
-89.4604 |
|
LogAmemiyaPrCrt.=
5.910, Akaike Info. Crt.=
8.744 |
| Autocorrel: Durbin-Watson Statistic =
1.30185,
Rho =
.34908 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -12.69630855
29.180604
-.435
.6697
REALGNP
.1692659471
.23897949E-01
7.083
.0000 1236.5350
REALINT -1.009511692
2.5399256
-.397
.6966 .91797790
*/
Nlsq
; Lhs = RealNvst
; Fcn = b1 + b2*(RealGNP - r*GNP1) + b3*(RealInt - r*Int1)
+ r*Nvst1
; labels = b1,b2,b3,r
; Start = b,0 ; maxit=500 $
/*
+-----------------------------------------------------------------------+
| User Defined Optimization
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Number of iterations completed = 10
|
| Dep. var. = REALNVST Mean=
195.6802431
, S.D.=
35.86147600
|
| Model size: Observations =
18, Parameters =
4, Deg.Fr.=
14 |
| Residuals: Sum of squares= 4424.285402
, Std.Dev.=
15.67781 |
| Fit:
R-squared= .797634, Adjusted R-squared =
.80888 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 3,
14] =
18.39,
Prob value =
.00004 |
| Diagnostic: Log-L =
-75.0813, Restricted(b=0) Log-L =
-89.4604 |
|
LogAmemiyaPrCrt.=
5.705, Akaike Info. Crt.=
8.787 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1
-11.82420047
27.501045
-.430
.6672
B2
.1719269810
.31414021E-01
5.473
.0000
B3
-.8627422066
2.7634259
-.312
.7549
R
.3038637095
.26668281
1.139
.2545
*/
Calc
; List ; eer = sumsqdev $
/*
EER
= .44242854020687100D+04
*/
Regress ; Lhs = RealNvst ; Rhs = One,RealGNP,RealInt,GNP1,Int1,Nvst1 $
143
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = REALNVST Mean=
195.6802431
, S.D.=
35.86147600
|
| Model size: Observations =
18, Parameters =
6, Deg.Fr.=
12 |
| Residuals: Sum of squares= 513.1205047
, Std.Dev.=
6.53912 |
| Fit:
R-squared= .976530, Adjusted R-squared =
.96675 |
| Model test: F[ 5,
12] =
99.86,
Prob value =
.00000 |
| Diagnostic: Log-L =
-55.6921, Restricted(b=0) Log-L =
-89.4604 |
|
LogAmemiyaPrCrt.=
4.043, Akaike Info. Crt.=
6.855 |
| Autocorrel: Durbin-Watson Statistic =
2.39017,
Rho =
-.19508 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -32.34674009
13.765052
-2.350
.0367
REALGNP
.6924822569
.61735020E-01
11.217
.0000 1236.5350
REALINT -1.560727766
1.6372713
-.953
.3593 .91797790
GNP1
-.6242457613
.64077072E-01
-9.742
.0000 1202.6972
INT1
1.820487907
2.0286062
.897
.3872 .75194352
NVST1
.6385436366
.12796334
4.990
.0003 191.98517
*/
Calc
; List ; eeu = sumsqdev
; F = ((eer - eeu)/2)/(eeu/12)
; Ftb(.95,2,12) $
/*
EEU
= .51312050469399730D+03
F
= .45733875706726950D+02
Result = .38852938346599990D+01
*/
144
145
4
11
880438
.256505
850418
.611734
4
12
1052020
.249657
1011170
.580884
4
13
1193680
.273923
951934
.572047
4
14
1303390
.371131
881323
.594570
4
15
1436970
.421411
831374
.585525
5
1
91361
.051028
118222
.442875
5
2
95428
.052646
116223
.462473
5
3
98187
.056348
115853
.519118
5
4
115967
.066953
129372
.529331
5
5
138382
.070308
243266
.557797
5
6
156228
.073961
277930
.556181
5
7
183169
.084946
317273
.569327
5
8
210212
.095474
358794
.583465
5
9
274024
.119814
397667
.631818
5
10
356915
.150046
566672
.604723
5
11
432344
.144014
848393
.587921
5
12
524294
.169300
1005740
.616159
5
13
530924
.172761
958231
.605868
5
14
581447
.186670
872924
.594688
5
15
610257
.213279
844622
.635545
6
1
68978
.037682
117112
.448539
6
2
74904
.039784
119420
.475889
6
3
83829
.044331
116087
.500562
6
4
98148
.050245
122997
.500344
6
5
118449
.055046
194309
.528897
6
6
133161
.052462
307923
.495361
6
7
145062
.056977
323595
.510342
6
8
170711
.061490
363081
.518296
6
9
199775
.069027
386422
.546723
6
10
276797
.092749
564867
.554276
6
11
381478
.112640
874818
.517766
6
12
506969
.154154
1013170
.580049
6
13
633388
.186461
930477
.556024
6
14
804388
.246847
851676
.537791
6
15
1009500
.304013
819476
.525775
?
? Data Setup
?
Create ; logc = Log(c) ; logq = log(q) ; logf = log(pf) $
?
? Initial Least Squares Regression
?
Regress ; Lhs = logc ; Rhs = One,logq,logf,lf ; Res = e $
Calc
; list ; eer = sumsqdev ; ssqrd$
146
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGC
Mean=
13.36560930
, S.D.=
1.131971011
|
| Model size: Observations =
90, Parameters =
4, Deg.Fr.=
86 |
| Residuals: Sum of squares= 1.335442194
, Std.Dev.=
.12461 |
| Fit:
R-squared= .988290, Adjusted R-squared =
.98788 |
| Model test: F[ 3,
86] = 2419.34,
Prob value =
.00000 |
| Diagnostic: Log-L =
61.7702, Restricted(b=0) Log-L =
-138.3581 |
|
LogAmemiyaPrCrt.=
-4.122, Akaike Info. Crt.=
-1.284 |
| Autocorrel: Durbin-Watson Statistic =
.38330,
Rho =
.80835 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 9.516921859
.22924451
41.514
.0000
LOGQ
.8827385540
.13254516E-01
66.599
.0000 -1.1743092
LOGF
.4539770541
.20304180E-01
22.359
.0000 12.770359
LF
-1.627510341
.34530204
-4.713
.0000 .56046016
EER
= .13354421939811450D+01
SSQRD=.15528397604431940D01
*/
/*======================================================================
Example 14.2. Cost Equations with Firm and Period Effects
Uses same data as Example 14.1
*/======================================================================
?
Namelist ; X = logq,logf,lf $
?----------------------------------------------------------------------? 1. Least squares with no effects. Restricted sum of squares has all
?
constants constrained to be equal.
? ----------------------------------------------------------------------Regress ; Lhs = logc ; Rhs = one,X $
Calc
; list ; eer = sumsqdev ; ssqrd $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGC
Mean=
13.36560930
, S.D.=
1.131971011
|
| Model size: Observations =
90, Parameters =
4, Deg.Fr.=
86 |
| Residuals: Sum of squares= 1.335442194
, Std.Dev.=
.12461 |
| Fit:
R-squared= .988290, Adjusted R-squared =
.98788 |
| Model test: F[ 3,
86] = 2419.34,
Prob value =
.00000 |
| Diagnostic: Log-L =
61.7702, Restricted(b=0) Log-L =
-138.3581 |
|
LogAmemiyaPrCrt.=
-4.122, Akaike Info. Crt.=
-1.284 |
| Autocorrel: Durbin-Watson Statistic =
.38330,
Rho =
.80835 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 9.516921859
.22924451
41.514
.0000
LOGQ
.8827385540
.13254516E-01
66.599
.0000 -1.1743092
LOGF
.4539770541
.20304180E-01
22.359
.0000 12.770359
LF
-1.627510341
.34530204
-4.713
.0000 .56046016
EER
= .13354421939811450D+01
SSQRD=.15528397604431940D01
*/
147
Regress;Lhs=logc;Rhs=X;Str=i;Panel;Means$
Calc
; list ; ssqrd $
/*
+-----------------------------------------------------------------------+
| Group Means Regression
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = YBAR(i.) Mean=
13.36560930
, S.D.=
.9978687061
|
| Model size: Observations =
6, Parameters =
4, Deg.Fr.=
2 |
| Residuals: Sum of squares= .3167435995E-01, Std.Dev.=
.12585 |
| Fit:
R-squared= .993638, Adjusted R-squared =
.98410 |
| Model test: F[ 3,
2] = 104.12,
Prob value =
.00953 |
| Diagnostic: Log-L =
7.2184, Restricted(b=0) Log-L =
-7.9539 |
|
LogAmemiyaPrCrt.=
-3.635, Akaike Info. Crt.=
-1.073 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 85.81207792
56.481742
1.519
.1287
LOGQ
.7824496503
.10876395
7.194
.0000 .23051463E-11
LOGF
-5.524215185
4.4786958
-1.233
.2174 .18644311
LF
-1.751096777
2.7430775
-.638
.5232 .32540123
SSQRD
= .15837179973004820D-01
*/
?----------------------------------------------------------------------? Firm Effects, and test for firm effects
?-----------------------------------------------------------------------
Regress;Lhs=logc;Rhs=X;Str=i;Panel
;FixedEffects;Output=2$
Calc
; eeu = sumsqdev
; list ; ssqrd
; F = ((eer - eeu)/5)/(eeu/81)
; Ftb(.95,5,81) $
/*
+-----------------------------------------------------------------------+
| Least Squares with Group Dummy Variables
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGC
Mean=
13.36560930
, S.D.=
1.131971011
|
| Model size: Observations =
90, Parameters =
9, Deg.Fr.=
81 |
| Residuals: Sum of squares= .2926127513
, Std.Dev.=
.06010 |
| Fit:
R-squared= .997434, Adjusted R-squared =
.99718 |
| Model test: F[ 8,
81] = 3935.92,
Prob value =
.00000 |
| Diagnostic: Log-L =
130.0877, Restricted(b=0) Log-L =
-138.3581 |
|
LogAmemiyaPrCrt.=
-5.528, Akaike Info. Crt.=
-2.691 |
| Estd. Autocorrelation of e(i,t)
.516200
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LOGQ
.9192931104
.29889750E-01
30.756
.0000 -1.1743092
LOGF
.4174883826
.15198961E-01
27.468
.0000 12.770359
LF
-1.070404704
.20168647
-5.307
.0000 .56046016
148
+------------------------------------------------------------------------+
|
Test Statistics for the Classical Model
|
|
|
|
Model
Log-Likelihood
Sum of Squares
R-squared |
| (1) Constant term only
-138.35810
.1140408949D+03
.0000000 |
| (2) Group effects only
-90.48802
.3936107526D+02
.6548512 |
| (3) X - variables only
61.77016
.1335442193D+01
.9882898 |
| (4) X and group effects
130.08770
.2926127513D+00
.9974341 |
|
|
|
Hypothesis Tests
|
|
Likelihood Ratio Test
F Tests
|
|
Chi-squared
d.f. Prob.
F
num. denom. Prob value |
| (2) vs (1)
95.740
5
.00000
31.875
5
84
.00000 |
| (3) vs (1)
400.257
3
.00000 2419.341
3
86
.00000 |
| (4) vs (1)
536.892
8
.00000 3935.923
8
81
.00000 |
| (4) vs (2)
441.151
3
.00000 3604.930
3
81
.00000 |
| (4) vs (3)
136.635
5
.00000
57.734
5
81
.00000 |
+------------------------------------------------------------------------+
Estimated Fixed Effects
Group
Coefficient
Standard Error
t-ratio
1
9.70599
.19312
50.25843
2
9.66475
.19898
48.57160
3
9.49708
.22496
42.21756
4
9.89056
.24176
40.91056
5
9.73007
.26094
37.28867
6
9.79307
.26366
37.14294
SSQRD
= .36125031024485010D-02
F
= .57734452434158600D+02
Result = .23272689375300000D+01
*/
?----------------------------------------------------------------------?TimeEffects
?----------------------------------------------------------------------Regress ;
;
Calc
;
;
/*
+-----------------------------------------------------------------------+
| Least Squares with Group Dummy Variables
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGC
Mean=
13.36560930
, S.D.=
1.131971011
|
| Model size: Observations =
90, Parameters = 18, Deg.Fr.=
72 |
| Residuals: Sum of squares= 1.088199385
, Std.Dev.=
.12294 |
| Fit:
R-squared= .990458, Adjusted R-squared =
.98820 |
| Model test: F[ 17,
72] = 439.61,
Prob value =
.00000 |
| Diagnostic: Log-L =
70.9834, Restricted(b=0) Log-L =
-138.3581 |
|
LogAmemiyaPrCrt.=
-4.010, Akaike Info. Crt.=
-1.177 |
| Estd. Autocorrelation of e(i,t)
.000000
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LOGQ
.8677271602
.15408346E-01
56.315
.0000 -1.1743092
LOGF
-.4844720940
.36412133
-1.331
.1868 12.770359
LF
-1.954413839
.44237965
-4.418
.0000 .56046016
149
150
/*
+-----------------------------------------------------------------------+
| Least Squares with Group Dummy Variables and Period Effects
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGC
Mean=
13.36560930
, S.D.=
1.131971011
|
| Model size: Observations =
90, Parameters = 24, Deg.Fr.=
66 |
| Residuals: Sum of squares= .1742088068
, Std.Dev.=
.05138 |
| Fit:
R-squared= .998449, Adjusted R-squared =
.99791 |
| Model test: F[ 23,
66] = 1847.57,
Prob value =
.00000 |
| Diagnostic: Log-L =
153.4245, Restricted(b=0) Log-L =
-138.3581 |
|
LogAmemiyaPrCrt.=
-5.701, Akaike Info. Crt.=
-2.876 |
| Estd. Autocorrelation of e(i,t)
.492487
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LOGQ
.8172488392
.31850925E-01
25.659
.0000 -1.1743092
LOGF
.1686107443
.16347803
1.031
.3052 12.770359
LF
-.8828121095
.26173699
-3.373
.0011 .56046016
Constant 12.66687333
2.0810682
6.087
.0000
Estimated Fixed Effects
Group
Coefficient
1
.12833
2
.06549
3
-.18947
4
.13425
5
-.09265
6
-.04595
Estimated Fixed Effects
Period
Coefficient
1
-.37402
2
-.31932
3
-.27669
4
-.22304
5
-.15393
6
-.10809
7
-.07686
8
-.02073
9
.04722
10
.09173
11
.20731
12
.28547
13
.30138
14
.30047
15
.31911
Standard Error
.05383
.04559
.01826
.02143
.04365
.04867
t-ratio
2.38395
1.43666
-10.37535
6.26538
-2.12273
-.94411
Standard Error
.22447
.21770
.21450
.20235
.10112
.05248
.03736
.02392
.03402
.09494
.17448
.20547
.19423
.17972
.17254
t-ratio
-1.66627
-1.46680
-1.28994
-1.10224
-1.52216
-2.05967
-2.05744
-.86653
1.38795
.96618
1.18815
1.38934
1.55162
1.67188
1.84946
151
+------------------------------------------------------------------------+
|
Test Statistics for the Classical Model
|
|
|
|
Model
Log-Likelihood
Sum of Squares
R-squared |
| (1) Constant term only
-138.35810
.1140408949D+03
.0000000 |
| (2) Group effects only
-90.48802
.3936107526D+02
.6548512 |
| (3) X - variables only
61.77016
.1335442193D+01
.9882898 |
| (4) X and group effects
130.08770
.2926127513D+00
.9974341 |
| (5) X ind.&time effects
152.74779
.1768483342D+00
.9984493 |
|
|
|
Hypothesis Tests
|
|
Likelihood Ratio Test
F Tests
|
|
Chi-squared
d.f. Prob.
F
num. denom. Prob value |
| (2) vs (1)
95.740
5
.00000
31.875
5
84
.00000 |
| (3) vs (1)
400.257
3
.00000 2419.341
3
86
.00000 |
| (4) vs (1)
536.892
8
.00000 3935.923
8
81
.00000 |
| (4) vs (2)
441.151
3
.00000 3604.930
3
81
.00000 |
| (4) vs (3)
136.635
5
.00000
57.734
5
81
.00000 |
| (5) vs (4)
45.320
14
.00004
3.133
14
67
.00085 |
| (5) vs (3)
181.955
20
.00000
21.947
20
67
.00000 |
+------------------------------------------------------------------------+
SSQRD
= .36125031024485010D-02
F
= .11938914546569830D+02
Result = .17292065212300000D+01
*/
/*======================================================================
Example 14.3. Testing for Random Effects
Uses same data as Example 14.1
*/======================================================================
?
? There is a built-in test for this, but it is also easy to compute
? from scratch.
?
Namelist ; X = logq,logf,lf $
Regress ; Lhs = logc ; Rhs = one,X ; Res = e $
Matrix
; ebar = Gxbr(e,i) $
Calc
; List
; Npd = Max(T)
; Ng = Max(i)
; LM = (Npd*Ng)/(2*(Npd-1)) * (Npd^2 * ebarebar/ee - 1)^2 $
/*
NPD
= .15000000000000000D+02
NG
= .60000000000000000D+01
LM
= .33485036222298630D+03
*/
152
/*======================================================================
Example 14.4. Random Effects Models
Uses same data as Example 14.1
*/======================================================================
?----------------------------------------------------------------------? 1. Least squares with no effects. Restricted sum of squares has all
?
constants constrained to be equal.
? ----------------------------------------------------------------------Namelist ; X = logq,logf,lf $
Regress ; Lhs = logc ; Rhs = one,X $
Calc
; list ; ssqrd $
/*
+-----------------------------------------------------------------------+
| OLS Without Group Dummy Variables
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGC
Mean=
13.36560930
, S.D.=
1.131971011
|
| Model size: Observations =
90, Parameters =
4, Deg.Fr.=
86 |
| Residuals: Sum of squares= 1.335442193
, Std.Dev.=
.12461 |
| Fit:
R-squared= .988290, Adjusted R-squared =
.98788 |
| Model test: F[ 3,
86] = 2419.34,
Prob value =
.00000 |
| Diagnostic: Log-L =
61.7702, Restricted(b=0) Log-L =
-138.3581 |
|
LogAmemiyaPrCrt.=
-4.122, Akaike Info. Crt.=
-1.284 |
| Panel Data Analysis of LOGC
[ONE way]
|
|
Unconditional ANOVA (No regressors)
|
| Source
Variation
Deg. Free.
Mean Square
|
| Between
37.3068
14.
2.66477
|
| Residual
76.7341
75.
1.02312
|
| Total
114.041
89.
1.28136
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 9.516921859
.22924451
41.514
.0000
LOGQ
.8827385540
.13254516E-01
66.599
.0000 -1.1743092
LOGF
.4539770541
.20304180E-01
22.359
.0000 12.770359
LF
-1.627510341
.34530204
-4.713
.0000 .56046016
SSQRD=.15528397604431940D01
*/
153
154
/*
+-----------------------------------------------------------------------+
| Least Squares with Group Dummy Variables
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGC
Mean=
6.572684944
, S.D.=
.5296754547
|
| Model size: Observations =
84, Parameters =
9, Deg.Fr.=
75 |
| Residuals: Sum of squares= .1475196791
, Std.Dev.=
.04435 |
| Fit:
R-squared= .993665, Adjusted R-squared =
.99299 |
| Model test: F[ 8,
75] = 1470.48,
Prob value =
.00000 |
| Diagnostic: Log-L =
147.2828, Restricted(b=0) Log-L =
-65.3066 |
|
LogAmemiyaPrCrt.=
-6.129, Akaike Info. Crt.=
-3.292 |
| Estd. Autocorrelation of e(i,t)
.516200
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LOGQ
.9280379106
.33111566E-01
28.028
.0000 -.50121574
LOGF
.3919718815
.16910783E-01
23.179
.0000 6.2910182
LF
-1.219320549
.20262070
-6.018
.0000 .27768940
SSQRD
= .19669290544567400D-02
Result = .26814286944733110D-02
*/
?----------------------------------------------------------------------? 4. Random Effects Models, Firm Efects Only
?----------------------------------------------------------------------Regress ; Lhs = logc ; Rhs = X ; Str=i ; Panel $
Regress ; Lhs = logc ; Rhs = X ; Str=i ; Panel ; Ar1$
Calc
; List ; ssqrd ; ssqrd/(1-Rho^2) $
/*
+--------------------------------------------------+
| Random Effects Model: v(i,t) = e(i,t) + u(i)
|
| Estimates: Var[e]
=
.361250D-02 |
|
Var[u]
=
.155963D-01 |
|
Corr[v(i,t),v(i,s)] =
.811935
|
| Lagrange Multiplier Test vs. Model (3) = 334.85 |
| ( 1 df, prob value = .000000)
|
| (High values of LM favor FEM/REM over CR model.) |
| Fixed vs. Random Effects (Hausman)
=
3.26 |
| ( 3 df, prob value = .353428)
|
| (High (low) values of H favor FEM (REM).)
|
| Reestimated using GLS coefficients:
|
| Estimates: Var[e]
=
.362107D-02 |
|
Var[u]
=
.398286D-01 |
|
Sum of Squares
.149540D+01 |
|
R-squared
.988290D+00 |
+--------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LOGQ
.9066810293
.25587383E-01
35.435
.0000 -1.1743092
LOGF
.4227782698
.14004238E-01
30.189
.0000 12.770359
LF
-1.064498999
.19977739
-5.328
.0000 .56046016
Constant 9.627907465
.20985587
45.879
.0000
*/
155
*/
?----------------------------------------------------------------------? 6. Fixed Effects, Firm and Time Effects
?----------------------------------------------------------------------Regress ; Lhs = logc ; Rhs = X ; Str=i ; Period = t
; Panel ; Fixed Effects ; Output = 2 $
Calc
; list ; ssqrd $
/*
+-----------------------------------------------------------------------+
| Least Squares with Group Dummy Variables and Period Effects
|
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LOGC
Mean=
13.36560930
, S.D.=
1.131971011
|
| Model size: Observations =
90, Parameters = 24, Deg.Fr.=
66 |
| Residuals: Sum of squares= .1742088068
, Std.Dev.=
.05138 |
| Fit:
R-squared= .998449, Adjusted R-squared =
.99791 |
| Model test: F[ 23,
66] = 1847.57,
Prob value =
.00000 |
| Diagnostic: Log-L =
153.4245, Restricted(b=0) Log-L =
-138.3581 |
|
LogAmemiyaPrCrt.=
-5.701, Akaike Info. Crt.=
-2.876 |
| Estd. Autocorrelation of e(i,t)
.492487
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LOGQ
.8172488392
.31850925E-01
25.659
.0000 -1.1743092
LOGF
.1686107443
.16347803
1.031
.3052 12.770359
LF
-.8828121095
.26173699
-3.373
.0011 .56046016
Constant 12.66687333
2.0810682
6.087
.0000
SSQRD
= .36125031024485010D-02
*/
156
157
/*======================================================================
Example 14.5. Hausman Test
Uses same data as Example 14.1
*/======================================================================
Namelist ; X = logq,logf,lf $
Regress ; Lhs = logc ; Rhs = X ; str=i ; panel ; FixedEffects $
Matrix
; bfe = b ; list ; Vfe = Varb $
Regress ; Lhs = logc ; Rhs = X ; str=i ; panel $
Matrix
; bre = b(1:3) ; list ; Vre = Part(varb,1,3,1,3) $
Matrix
; d = bfe-bre ; Vd = Vfe - Vre
; List ; Hausman = d<Vd>d $
Calc
; List ; Ctb(.95,3) $
/*
Matrix VFE
has 3 rows and 3 columns.
1
2
3
+-----------------------------------------1| .8933972D-03 -.3178122D-03 -.1884195D-02
2| -.3178122D-03 .2310084D-03 -.7685462D-03
3| -.1884195D-02 -.7685462D-03 .4067743D-01
Matrix VRE
.78147277654400000D+01
158
/*======================================================================
Example 14.6. Heteroscedasticity Consistent Estimation
Uses same data as Example 14.1
*/======================================================================
Namelist ; X = logq,logf,lf $
Regress ; Lhs = logc ; Rhs = One,X ; Str=i ; Panel $
Calc
; List ; s2 = ssqrd ; Npd = Max(t) $
Regress ; Lhs = logc ; Rhs = One,X ; Res = e $
Matrix ; List
; ebari = Gxbr(e,i)
; si = Gsdv(e,i) ; vi = Dirp(si,si)
; vui = vi - s2 $
/*
S2
= .36210700500690940D-02
NPD
= .15000000000000000D+02
Matrix EBARI
has 6 rows and 1 columns.
1
+-------------1| .6886891D-01
2| -.1387804D-01
3| -.1942237D+00
4| .1527257D+00
5| -.2158348D-01
6| .8090588D-02
Matrix SI
has 6 rows and 1 columns.
1
+-------------1| .4023408D-01
2| .6688817D-01
3| .5161303D-01
4| .9523568D-01
5| .4816550D-01
6| .6305873D-01
Matrix VI
has 6 rows and 1 columns.
1
+-------------1| .1618782D-02
2| .4474028D-02
3| .2663905D-02
4| .9069834D-02
5| .2319915D-02
6| .3976403D-02
Matrix VUI
has 6 rows and 1 columns.
1
+-------------1| -.2002288D-02
2| .8529576D-03
3| -.9571652D-03
4| .5448764D-02
5| -.1301155D-02
6| .3553329D-03
*/
159
160
1950
1951
1952
1953
1954
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
3
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
93.50
135.20
157.30
179.50
189.60
12.93
25.90
35.05
22.89
18.84
28.57
48.51
43.34
37.02
37.81
39.27
53.46
55.56
49.56
32.04
32.24
54.38
71.78
90.08
68.60
209.90
355.30
469.90
262.30
230.40
261.60
472.80
445.60
361.60
288.20
258.70
420.30
420.50
494.50
405.10
418.80
588.20
645.20
641.00
459.30
1610.50
1819.40
2079.70
2371.60
2759.90
191.50
516.00
729.00
560.40
519.90
628.50
537.10
561.20
617.20
626.70
737.20
760.50
581.40
662.30
583.80
635.20
723.80
864.10
1193.50
1188.90
1362.40
1807.10
2676.30
1801.90
1957.30
2202.90
2380.50
2168.60
1985.10
1813.90
1850.20
2067.70
1796.70
1625.80
1667.00
1677.40
2289.50
2159.40
2031.30
2115.50
647.40
671.30
726.10
800.30
888.90
1.80
.80
7.40
18.10
23.50
26.50
36.20
60.80
84.40
91.20
92.40
86.00
111.10
130.60
141.80
136.70
129.70
145.50
174.80
213.50
53.80
50.50
118.10
260.20
312.70
254.20
261.40
298.70
301.80
279.10
213.80
232.60
264.80
306.90
351.10
357.80
342.10
444.20
623.60
669.70
?
Namelist ; X = One,F,C $
161
/*=================================================================
Example 15.2. Classical Regression and Least Squares
*/=================================================================
?
? Simple least squares regression
?
Regress ; Lhs = I ; Rhs = X ; Res = e $
Calc
; List
; Nfirm = 5 ; Nperiod = 20
; s2hat = sumsqdev/(nfirm*nperiod) $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = I
Mean=
248.9570000
, S.D.=
267.8654462
|
| Model size: Observations =
100, Parameters =
3, Deg.Fr.=
97 |
| Residuals: Sum of squares= 1570883.687
, Std.Dev.=
127.25831 |
| Fit:
R-squared= .778856, Adjusted R-squared =
.77430 |
| Model test: F[ 2,
97] = 170.81,
Prob value =
.00000 |
| Diagnostic: Log-L =
-624.9928, Restricted(b=0) Log-L =
-700.4398 |
|
LogAmemiyaPrCrt.=
9.722, Akaike Info. Crt.=
12.560 |
| Autocorrel: Durbin-Watson Statistic =
.35995,
Rho =
.82002 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -48.02973763
21.480165
-2.236
.0276
F
.1050854108
.11377830E-01
9.236
.0000 1922.2230
C
.3053655452
.43507814E-01
7.019
.0000 311.06700
NFIRM
= .50000000000000000D+01
NPERIOD = .20000000000000000D+02
S2HAT
= .15708836868581870D+05
*/
162
/*=================================================================
Example 15.3. Testing and Estimation with Groupwise
Heteroscedasticity
*/=================================================================
?-----------------------------------------------------------------? Testing for groupwise heteroscedasticity
? First obtain OLS residuals. (Regression results in Example 15.2)
?-----------------------------------------------------------------Regress ; Lhs = I ; Rhs = X ; Res = e $
?-----------------------------------------------------------------? Lagrange multiplier statistic
?
Create ; esq = e*e $
Calc
; List ; s2 = ee/(Nfirm*Nperiod) $
/*
S2HAT
= .15708836868581870D+05
*/
? Group specific variances based on least squares coefficients
? Then compute statistic
?
Matrix ; s2i = Gxbr(esq,firm)
Calc
; vi = 1/s2 * s2i - 1
; LM = (Nperiod/2)* vivi
; List; Ctb(.95,4) $
/*
Matrix S2I
has 5 rows and 1 columns.
+-------------1| .9410908D+04
2| .7558508D+03
3| .3428849D+05
4| .6334237D+03
5| .3345551D+05
LM
= .46629783728753650D+02
Result = .94877290383399850D+01
*/
? Whites test
?
Create ; FF = F*F ; CC = C*C ; FC = F*C $
Regress ; Lhs = esq ; Rhs = X,FF,CC,FC $
Calc
; List ; Rsqrd ; White = Nfirm*Nperiod*Rsqrd ; Ctb(.95,5) $
/*
RSQRD
= .36853667086878680D+00
WHITE
= .36853667086878680D+02
Result = .11070497756249990D+02
*/
? Likelihood ratio statistic
? We would do this later, so at this point, we just compute it
?
Create ; D2=(Firm=2) ; D3 =(Firm=3) ; D4=(Firm=4) ; D5=(Firm=5) $
Regress; Lhs = i ; Rhs = X
Calc
; List ; LoglR = Logl $
/*
LOGLR
= -.62499278454313890D+03
*/
Hreg
; Lhs = i ; Rhs = X ; Rh2 = D1,D3,D4,D5 $
Calc
; List ; LoglU = LogL ; LR = -2*(LogLR - LogLU) $
/*
LOGLU
= -.56453548456485810D+03
LR
= .12091459995656170D+03
*/
?-----------------------------------------------------------------? Least squares with corrected covariance matrices
163
1 columns.
*/
164
*/
?------------------------------------------------------------------
165
166
/*=================================================================
Example 15.4. Testing and Estimation with Groupwise
Heteroscedasticity and Cross Sectional Correlation
*/=================================================================
?
? There is a single built-in procedure that does all of this, the
? TSCS command. Well use it later. But, for this data set, it is
? also easy to program the computations directly. Well do this to
? illustrate the computations. First, correlations of residuals.
?
Calc
; Nfirm = Max(firm) ; Nperiod = Max(t) $
?
? This procedure takes a column vector of nT residuals and computes
? a correlation matrix from them, n by n.
Proc=Corr(ve,nf,nt) $
Matrix
; em=mvec( ve,nf,nt) ; em = em'
; ebar = 1/nt * em'1 ; ebar=ebar' ; uno = init(nt,1,1)
; ebar=kron(ebar,uno); em=em-ebar $ (deviations)
Matrix
; V = 1/Nperiod*em'em
; DV = Diag(V)
; List ; Rmat = Isqr(DV) * V * Isqr(DV) $
EndProc
?
? First for OLS
?
Regress
; Lhs = i ; Rhs = X ; Res =e$
Exec
; Proc=Corr(e,Nfirm,Nperiod)$
?
? Get GLS, then repeat
?
Create
; esq = e*e $
Matrix
; s2i = Gxbr(esq,firm) $
Create
; wgti = 1/s2i(firm) $
Matrix
; bfgls = <X'[wgti]X>*X'[wgti]i $
Create
; efgls = i - X'bfgls $
Exec
; proc=Corr(efgls,nfirm,nperiod) $
/*
+---------------------------------------------------------------------1| .1000000D+01 -.1852380D+00 -.2591969D+00 -.4688830D+00 -.1545814D01
2| -.1852380D+00 .1000000D+01 .1440353D+00 .1862341D+00 .
2217868D+00
3| -.2591969D+00 .1440353D+00 .1000000D+01 .8813588D+00
-.1215807D+00
4| -.4688830D+00 .1862341D+00 .8813588D+00 .1000000D+01
-.1186488D+00
5| -.1545814D-01 .2217868D+00 -.1215807D+00 -.1186488D+00 .
1000000D+01
Matrix RMAT
has
1
5 rows and
2
5 columns.
3
167
5| -.1208000D+00
1000000D+01
*/
168
?
? Testing for a diagonal Sigma.
? We need 3 sets of estimates for these tests: OLS, Groupwise
? heteroscedasticity, and ML with Full sigma. The following
? gets all 3 coefficients, logLs and residuals using the
? major programmed procedures. We will return to the matrix
? algebra approach later for GLS. We compute maximum likelihood
? estimates for all three specifications.
?
? 1. Linear regression, homoscedastic, no correlation
?
Regress; Lhs = i ; Rhs = X ; Res = eo $
Matrix ; bo = b $
Calc
; List ; loglo = logl $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = I
Mean=
248.9570000
, S.D.=
267.8654462
|
| Model size: Observations =
100, Parameters =
3, Deg.Fr.=
97 |
| Residuals: Sum of squares= 1570883.687
, Std.Dev.=
127.25831 |
| Fit:
R-squared= .778856, Adjusted R-squared =
.77430 |
| Model test: F[ 2,
97] = 170.81,
Prob value =
.00000 |
| Diagnostic: Log-L =
-624.9928, Restricted(b=0) Log-L =
-700.4398 |
|
LogAmemiyaPrCrt.=
9.722, Akaike Info. Crt.=
12.560 |
| Autocorrel: Durbin-Watson Statistic =
.35995,
Rho =
.82002 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -48.02973763
21.480165
-2.236
.0276
F
.1050854108
.11377830E-01
9.236
.0000 1922.2230
C
.3053655452
.43507814E-01
7.019
.0000 311.06700
LOGLO
= -.62499278454313890D+03
*/
? 2. Groupwise heteroscedastic
Create ; D2=firm=2 ; D3=firm=3 ; D4=firm=4 ; D5=Firm=5 $
Hreg
; Lhs = i ; Rhs = X ; Rh2 = D2,D3,D4,D5 ; Res = eh $
Matrix ; bh = b $
Calc
; List ; loglh = Logl $
/*
+---------------------------------------------+
| Multiplicative Heteroskedastic Regr. Model |
| Maximum Likelihood Estimates
|
| Dependent variable
I
|
| Weighting variable
ONE
|
| Number of observations
100
|
| Iterations completed
22
|
| Log likelihood function
-564.5355
|
| Restricted log likelihood
-624.9928
|
| Chi-squared
120.9146
|
| Degrees of freedom
4
|
| Significance level
.0000000
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Regression (mean) function
Constant -23.25855004
4.8151918
-4.830
.0000
F
.9434991252E-01 .62834189E-02
15.016
.0000 1922.2230
C
.3337022939
.22039121E-01
15.141
.0000 311.06700
Variance function (log-linear)
Sigma
93.04742539
14.712090
6.325
.0000
169
D2
-3.896931022
.44721360
-8.714
.0000 .20000000
D3
1.535678914
.44721360
3.434
.0006 .20000000
D4
-1.942561663
.44721360
-4.344
.0000 .20000000
D5
1.236884093
.44721360
2.766
.0057 .20000000
LOGLH
= -.56453548456485810D+03
*/
? 3. Groupwise heteroscedastic and cross grpoup correlated
?
Tscs
; Lhs = i ; Rhs = X ; Pds = Nperiod ; Res = et $
Matrix ; bt = b ; V = Part(Sigma,1,5,1,5)
; logdet=logd(V)$
Calc
; list
; loglt = -nfirm*nperiod/2*(1+log(2*pi)+logdet/nfirm) $
/*
+--------------------------------------------------+
| Groupwise Regression Models
|
| Estimator =
MLE by Iterated GLS |
| Groupwise Het. and Correlated
(S2)
|
| Nonautocorrelated disturbances
(R0)
|
| Test statistics against the correlation
|
| Deg.Fr. =
10 C*(.95) = 18.31 C*(.99) = 23.21 |
| Test statistics against the correlation
|
| Likelihood ratio
statistic
=
88.5256 |
| Log-likelihood function =
-520.272695 |
+--------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 11.50238832
2.4699654
4.657
.0000
F
.5192085034E-01 .42739327E-02
12.148
.0000
C
.3190879957
.15723905E-01
20.293
.0000
Log-likelihood functions for estimated models
+--------------------+
: Log-L
Parameters :
S0 :
-624.993
4
: <--------- OLS
S1 :
-564.535
8
: <--------- Groupwise heteroscedastic
S2 :
-520.273
18
: <--------- Cross group correlation
+--------------------+
LOGLT
= -.52027269550976920D+03
?
? LR test for diagonal sigma, then for scalar sigma
?
Calc
; List ; LR = -2*(loglh - loglt)
; DF = Nfirm*(Nfirm-1)/2
; ctb(.95,DF)
; LR = -2*(loglo - loglt)
; DF = Nfirm*(Nfirm+1)/2 - 1
; ctb(.95,DF) $
/*
LR
= .88525578110177780D+02 <----- Groupwise heteroscedastic
DF
= .10000000000000000D+02
Result = .18307038055350020D+02
LR
= .20944017806673950D+03 <----- Scalar VC (OLS)
DF
= .14000000000000000D+02
Result = .23684791307170030D+02
*/
170
?
? LM test for diagonal sigma
?
Calc
; nt = nfirm * nperiod $
Matrix ; meh = Mvec(eh,nfirm,nperiod) ; meh=meh'
; ebar = 1/nperiod * meh'1 ; ebar=ebar' ; uno = init(nperiod,1,1)
; ebar=kron(ebar,uno); meh=meh-ebar $ (deviations)
Matrix ; V = 1/Nperiod*meh'meh
; DV = Diag(V)
; List ; Rmat = Isqr(DV) * V * Isqr(DV) $
Matrix ; Rmat2 = Dirp(Rmat,Rmat)
; Rmat2 = Rmat2 - Iden(Nfirm)
; uno
= Init(nfirm,1,.5)
; List ; LM = nperiod*uno'Rmat2*uno $
Matrix RMAT
has 5 rows and 5 columns.
1
2
3
4
5
+---------------------------------------------------------------------1| .1000000D+01 .8906432D+00 .8436773D+00 .8843980D+00 .
6305300D+00
2| .8906432D+00 .1000000D+01 .7850437D+00 .8199351D+00 .
7247403D+00
3| .8436773D+00 .7850437D+00 .1000000D+01 .9226896D+00 .
7643978D+00
4| .8843980D+00 .8199351D+00 .9226896D+00 .1000000D+01 .
8200157D+00
5| .6305300D+00 .7247403D+00 .7643978D+00 .8200157D+00 .
1000000D+01
Matrix LM
has 1 rows and 1 columns.
1
+-------------1| .6606686D+02
?
? Estimates of model with heteroscedasticity and correlation.
? We compute the FGLS estimates using matrix algebra, then let
? the built-in program compute the MLE.
? 1. Classical model
Regress ; Lhs = i ; Rhs = X ; Res = e $
/*
These results appear above
*/
? 2. FGLS for correlated disturbances
Matrix ; meh = Mvec(e,Nfirm,Nperiod); meh=meh'
; V = 1/Nperiod * meh'meh
; IT = Iden(Nperiod)
; V = Kron(V,IT)
; Vfgls = <X'<V>X> ; bfgls = Vfgls * X'<V>i
; Stat (bfgls,Vfgls) $
/*
Matrix statistical results: Coefficients=BFGLS
Variance=VFGLS
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
BFGLS_ 1 -38.36127721
5.3448709
-7.177
.0000
BFGLS_ 2 .9618944505E-01 .54751563E-02
17.568
.0000
BFGLS_ 3 .3095320622
.17985085E-01
17.210
.0000
*/
171
? 3.
Tscs
/*
+--------------------------------------------------+
| Groupwise Regression Models
|
| Estimator =
MLE by Iterated GLS |
| Groupwise Het. and Correlated
(S2)
|
| Nonautocorrelated disturbances
(R0)
|
| Test statistics against the correlation
|
| Deg.Fr. =
10 C*(.95) = 18.31 C*(.99) = 23.21 |
| Test statistics against the correlation
|
| Likelihood ratio
statistic
=
88.5256 |
| Log-likelihood function =
-520.272695 |
+--------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 11.50238832
2.4699654
4.657
.0000
F
.5192085034E-01 .42739327E-02
12.148
.0000
C
.3190879957
.15723905E-01
20.293
.0000
*/
? Compute variances and correlations. Use more program tricks.
Matrix ; meh = Mvec(ef,Nfirm,Nperiod); meh=meh'
; List ; V = 1/Nperiod * meh'meh $
/*
Matrix V
has 5 rows and 5 columns.
1
2
3
4
5
+---------------------------------------------------------------------1| .4046439D+05 -.2087012D+03 -.2457998D+05 -.5691272D+04 .
3284091D+05
2| -.2087012D+03 .1656743D+03 -.5968510D+02 .1010513D+02 .
4834731D+03
3| -.2457998D+05 -.5968510D+02 .2149609D+05 .4955445D+04
-.2791468D+05
4| -.5691272D+04 .1010513D+02 .4955445D+04 .1220558D+04
-.5935385D+04
5| .3284091D+05 .4834731D+03 -.2791468D+05 -.5935385D+04 .
4860731D+05
*/
Create ; D1=0 $
Namelist; D = D1,D2,D3,D4,D5 $
Sample ; 1 - Nperiod $
Create ; D = Meh $
Matrix ; List ; Xcor(D) $
Sample ; 1 100 $
/*
Correlation Matrix for Listed Variables
D1
D2
D3
D4
D5
D1
1.00000
-.22518
-.28694
-.46691
-.01507
D2
-.22518
1.00000
.10488
.16610
.24530
D3
-.28694
.10488
1.00000
.88505
-.13902
D4
-.46691
.16610
.88505
1.00000
-.10059
D5
-.01507
.24530
-.13902
-.10059
1.00000
*/
172
/*=================================================================
Example 15.5. Models with Autocorrelation
*/=================================================================
?
? This extension produces a large amount of computation. We let
? LIMDEP do the work, as it is already programmed.
? These estimators are not iterated does not produce MLE because
? of the problem of the first observation.
Tscs ; Lhs = i ; Rhs = X ; Pds = Nperiod ; AR1 ; Res = ear1$
/*
+--------------------------------------------------+
| Homoskedastic Regression
(S0)
|
| Group specific autocorrelation
(R2)
|
| Autocorrelation coefficients:
|
| .478 -.251 .301 .578 .576
|
| Pooled OLS residual variance (SS/nT)
7376.1900 |
| Test statistics for homoscedasticity:
|
| Deg.Fr. =
4 C*(.95) =
9.49 C*(.99) = 13.28 |
+--------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -40.14627721
17.134883
-2.343
.0191
F
.9454669966E-01 .10998587E-01
8.596
.0000
C
.3042601355
.42352462E-01
7.184
.0000
+--------------------------------------------------+
| Groupwise Het. Regression
(S1)
|
| Group specific autocorrelation
(R2)
|
| Autocorrelation coefficients:
|
| .478 -.251 .301 .578 .576
|
| Test statistics for homoscedasticity:
|
| Deg.Fr. =
4 C*(.95) =
9.49 C*(.99) = 13.28 |
| Wald
statistic
=
8718.6355 |
| Likelihood ratio
statistic
=
97.2177 |
| Test statistics against the correlation
|
| Lagrange multiplier statistic
=
42.6069 |
+--------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -23.81058815
7.6937942
-3.095
.0020
F
.8605236132E-01 .95992823E-02
8.964
.0000
C
.3321471206
.35485083E-01
9.360
.0000
+--------------------------------------------------+
| Groupwise Het. and Correlated
(S2)
|
| Group specific autocorrelation
(R2)
|
| Autocorrelation coefficients:
|
| .478 -.251 .301 .578 .576
|
| Test statistics against the correlation
|
| Deg.Fr. =
10 C*(.95) = 18.31 C*(.99) = 23.21 |
| Test statistics against the correlation
|
+--------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -15.42434757
4.5952187
-3.357
.0008
F
.7522097616E-01 .57097182E-02
13.174
.0000
C
.3380684164
.14205476E-01
23.798
.0000
*/
Matrix ; List ; Sigma $
/*
173
Matrix Result
has
1
6 rows and
2
5 columns.
3
has
1
1 rows and
2
5 columns.
3
*/
?Getcorrelationsofresiduals
?
Matrix ;
Create ;
Namelist;
Sample ;
Create ;
Matrix ;
D1
1.00000
-.34911
-.24792
-.35581
-.07157
D2
-.34911
1.00000
.15832
.24587
.24396
D3
-.24792
.15832
1.00000
.89470
-.17585
D4
-.35581
.24587
.89470
1.00000
-.03971
D5
-.07157
.24396
-.17585
-.03971
1.00000
*/
174
/*=================================================================
Example 15.6. A Random Coefficients Model for Investment
*/=================================================================
?
? Individual OLS results and the two weighted averages
?
Matrix ; bbar = Init(3,1,0.)
; btilde = Init(3,1,0.)
; Vtilde = Init(3,3,0.) $
Proc $
Include ; New ; firm = group $
Regress ; Lhs = i ; Rhs = X $
Matrix ; bbar = bbar + 1/nfirm * b
; Vtilde = Vtilde + <Varb>
; btilde = btilde + <Varb>*b $
Matrix ; bi = b' ; Vi = Diag(Varb) ; Vi = Sqrt(Vi)
; Vi = Vecd(Vi) ; Vi = Vi'
; List ; Result = [bi/vi] $
EndProc
Exec
; Group = 1,5 $
Matrix ; List ; bbar = bbar
; btilde = btilde * <Vtilde> $
Sample ; 1 100 $
/*
1
2
3
+-----------------------------------------1| -.1497825D+03 .1192808D+00 .3714448D+00
2| .1058421D+03 .2583417D-01 .3707282D-01
+-----------------------------------------1| -.6189961D+01 .7794782D-01 .3157182D+00
2| .1350648D+02 .1997330D-01 .2881317D-01
+-----------------------------------------1| -.9956306D+01 .2655119D-01 .1516939D+00
2| .3137425D+02 .1556610D-01 .2570408D-01
+-----------------------------------------1| -.5093902D+00 .5289413D-01 .9240649D-01
2| .8015289D+01 .1570650D-01 .5609897D-01
+-----------------------------------------1| -.3036853D+02 .1565708D+00 .4238657D+00
2| .1570477D+03 .7888567D-01 .1552162D+00
Matrix BBAR
has 1 rows and 3 columns.
+-----------------------------------------1| -.3936133D+02 .8664896D-01 .2710258D+00
Matrix BTILDE
has 1 rows and 3 columns.
+-----------------------------------------1| -.2057078D+01 .5357167D-01 .2113642D+00
*/
175
176
/*=================================================================
Example 15.7. Predictions for Random Coefficients Estimates
*/=================================================================
?
? No new commands needed. The predictions are part of the listed
? results generated by the Regress command above. The ;OUTPUT=1
? requests the predictions.
/*
++
| Group specific coefficient estimates
|
| Prediction for group 1
GROUP001
|
| Number of Observations =
20.0
|
| Group Mean of LHS
=
608.02000
|
| Group Std. Dev. of LHS =
309.57463
|
| Fit Measures for the Estimators
|
| (When not OLS, Rsqrd = 1-ee/yy may be < 0!)
|
| Estimator
Sum of Squares
R-squared
|
| OLS
143205.877411
.921354
|
| GLS
445431.561308
.755377
|
| Prediction
148462.926347
.918467
|
+------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -71.62930276
52.281631
-1.370
.1707
F
.1027848068
.51738412E-01
1.987
.0470 4333.8450
C
.3678493144
.14167590
2.596
.0094 648.43500
+------------------------------------------------+
| Group specific coefficient estimates
|
| Prediction for group 2
GROUP002
|
| Number of Observations =
20.0
|
| Group Mean of LHS
=
86.12350
|
| Group Std. Dev. of LHS =
42.72556
|
| Fit Measures for the Estimators
|
| (When not OLS, Rsqrd = 1-ee/yy may be < 0!)
|
| Estimator
Sum of Squares
R-squared
|
| OLS
2997.444362
.913578
|
| GLS
10659.991388
.692654
|
| Prediction
3018.144717
.912982
|
+------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -9.819347284
62.695200
-.157
.8755
F
.8423601873E-01 .51146118E-01
1.647
.0996 693.21000
C
.3092166896
.14196989
2.178
.0294 121.24500
177
+------------------------------------------------+
| Group specific coefficient estimates
|
| Prediction for group 3
GROUP003
|
| Number of Observations =
20.0
|
| Group Mean of LHS
=
102.29000
|
| Group Std. Dev. of LHS =
48.58450
|
| Fit Measures for the Estimators
|
| (When not OLS, Rsqrd = 1-ee/yy may be < 0!)
|
| Estimator
Sum of Squares
R-squared
|
| OLS
13216.587770
.705307
|
| GLS
464947.632192
-9.367045
|
| Prediction
13224.646228
.705127
|
+------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -12.03268753
60.771892
-.198
.8430
F
.2793844128E-01 .51576339E-01
.542
.5880 1941.3250
C
.1508282049
.14209069
1.061
.2885 400.16000
+------------------------------------------------+
| Group specific coefficient estimates
|
| Prediction for group 4
GROUP004
|
| Number of Observations =
20.0
|
| Group Mean of LHS
=
42.89150
|
| Group Std. Dev. of LHS =
19.11019
|
| Fit Measures for the Estimators
|
| (When not OLS, Rsqrd = 1-ee/yy may be < 0!)
|
| Estimator
Sum of Squares
R-squared
|
| OLS
1773.233930
.744446
|
| GLS
10185.684206
-.467934
|
| Prediction
1853.481708
.732881
|
+------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 3.269520950
62.785770
.052
.9585
F
.4110890739E-01 .51698745E-01
.795
.4265 670.91000
C
.1407172262
.14073601
1.000
.3174 85.640000
+------------------------------------------------+
| Group specific coefficient estimates
|
| Prediction for group 5
GROUP005
|
| Number of Observations =
20.0
|
| Group Mean of LHS
=
405.46000
|
| Group Std. Dev. of LHS =
129.35190
|
| Fit Measures for the Estimators
|
| (When not OLS, Rsqrd = 1-ee/yy may be < 0!)
|
| Estimator
Sum of Squares
R-squared
|
| OLS
177928.313637
.440312
|
| GLS
881176.782055
-1.771812
|
| Prediction
179173.969986
.436394
|
+------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -27.70627551
44.857219
-.618
.5368
F
.1477549895
.49187200E-01
3.004
.0027 1971.8250
C
.4513311661
.13119431
3.440
.0006 299.85500
*/
/*=================================================================
Example 15.8. Testing for Random Coefficients
*/=================================================================
178
Sample
Proc $
Matrix
Include
Regress
Matrix
; 1 100 $
;
;
;
;
;
EndProc
Exec
; Group = 1,5 $
Matrix ; List ; Chisq
; DF = Col(X) * (Nfirm-1)
; Ctb(.95,DF) $
/*
CHISQ
= .11292634629447980D+03
DF
= .12000000000000000D+02
Result = .21026069819690030D+02
*/
/*=================================================================
Example 15.9. FGLS Estimates of a Seemingly Unrelated Regressions
Model
*/=================================================================
? First obtain pooled FGLS estimates using TSCS approach and cor? relations of FGLS residuals. GM by OLS, then switch over to
? SUR model.
?
Sample
; 1 - 100 $
TSCS
; Lhs = i ; Rhs = X ; Pds = Nperiod ; Model = S2,R0 ; Res = ef $
Matrix
; mef = Mvec(ef,nfirm,nperiod) ; mef = mef' $
Create
; d1=0;d2=0;d3=0;d4=0;d5=0 $
Sample
; 1-20 $
Namelist ; Dfgls = d1,d2,d3,d4,d5 $
Create
; Dfgls = Mef $
Matrix
; List ; Xcor(Dfgls) $
/*
+--------------------------------------------------+
| Groupwise Regression Models
|
| Estimator =
2 Step GLS
|
+--------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -28.24669393
4.8882380
-5.779
.0000
F
.8910090806E-01 .50722626E-02
17.566
.0000
C
.3340150281
.16712537E-01
19.986
.0000
D1
D2
D3
D4
D5
D1 1.00000 -.34475 -.22325 -.37605 -.09240
D2 -.34475 1.00000
.22015
.29070
.20076
D3 -.22325
.22015 1.00000
.89731 -.15869
D4 -.37605
.29070
.89731 1.00000 -.07575
D5 -.09240
.20076 -.15869 -.07575 1.00000
*/
179
?
? GM by OLS
?
Sample ; 1 - 20 $
Regress ; Lhs = i ; Rhs = X $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = I
Mean=
608.0200000
, S.D.=
309.5746277
|
| Model size: Observations =
20, Parameters =
3, Deg.Fr.=
17 |
| Residuals: Sum of squares= 143205.8774
, Std.Dev.=
91.78167 |
| Fit:
R-squared= .921354, Adjusted R-squared =
.91210 |
| Model test: F[ 2,
17] =
99.58,
Prob value =
.00000 |
| Diagnostic: Log-L =
-117.1418, Restricted(b=0) Log-L =
-142.5698 |
|
LogAmemiyaPrCrt.=
9.179, Akaike Info. Crt.=
12.014 |
| Autocorrel: Durbin-Watson Statistic =
.93745,
Rho =
.53127 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -149.7824533
105.84212
-1.415
.1751
F
.1192808325
.25834169E-01
4.617
.0002 4333.8450
C
.3714448073
.37072824E-01
10.019
.0000 648.43500
*/
?
? Need to set up the data differently for the SUR model.
?
Sample
; 1 - 100 $
Create
; igm=0;ich=0;ige=0;iwe=0;ius=0
; fgm=0;fch=0;fge=0;fwe=0;fus=0
; cgm=0;cch=0;cge=0;cwe=0;cus=0 $
Matrix
; mi = Mvec(i,nfirm,nperiod) ; mi = mi' $
Matrix
; mf = Mvec(f,nfirm,nperiod) ; mf = mf' $
Matrix
; mc = Mvec(c,nfirm,nperiod) ; mc = mc' $
Namelist ; Ivars = igm,ich,ige,iwe,ius
; Fvars = fgm,fch,fge,fwe,fus
; Cvars = cgm,cch,cge,cwe,cus $
Sample
; 1 - 20 $
Create
; Ivars = mi $
Create
; Fvars = mf $
Create
; Cvars = mc $
Namelist ; XGM = One,fgm,cgm
; XCH = One,fch,cch
; XGE = One,fge,cge
; XWE = One,fwe,cwe
; XUS = One,fus,cus $
SURE
; Lhs = igm,ich,ige,ius,iwe
; Eq1=XGM ; Eq2=XCH ; Eq3=XGE ; Eq4=XUS ; Eq5=XWE
; Maxit = 1 $
Matrix
; List ; Sigma $
180
/*
Iteration
0, GLS
=
-463.5217
Iteration
1, GLS
=
-459.4397
+-----------------------------------------------------------------------+
| Estimates for equation: IGM
|
| Dep. var. = IGM
Mean=
608.0200000
, S.D.=
309.5746277
|
| Residuals: Sum of squares= 122672.7450
, Std.Dev.=
84.94730 |
| Fit:
R-squared= .920742, Adjusted R-squared =
.91142 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
17] =
98.74,
Prob value =
.00000 |
| Diagnostic: Log-L =
-115.5942, Restricted(b=0) Log-L =
-142.5698 |
| Durbin-Watson Stat.=
.9365
Autocorrelation
=
.5318 |
| Log-determinant of W
31.7546
Log-likelihood
-459.4397 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -162.3641052
89.459232
-1.815
.0695
FGM
.1204930237
.21629128E-01
5.571
.0000 4333.8450
CGM
.3827461766
.32768033E-01
11.680
.0000 648.43500
+-----------------------------------------------------------------------+
| Estimates for equation: ICH
|
| Dep. var. = ICH
Mean=
86.12350000
, S.D.=
42.72555506
|
| Residuals: Sum of squares= 2598.436843
, Std.Dev.=
12.36322 |
| Fit:
R-squared= .911862, Adjusted R-squared =
.90149 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
17] =
87.94,
Prob value =
.00000 |
| Diagnostic: Log-L =
-77.0481, Restricted(b=0) Log-L =
-102.9618 |
| Log-determinant of W
31.7546
Log-likelihood
-459.4397 |
| Durbin-Watson Stat.=
1.9175
Autocorrelation
=
.0412 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .5043036394
11.512829
.044
.9651
FCH
.6954561271E-01 .16897506E-01
4.116
.0000 693.21000
CCH
.3085445352
.25863550E-01
11.930
.0000 121.24500
+-----------------------------------------------------------------------+
| Estimates for equation: IGE
|
| Dep. var. = IGE
Mean=
102.2900000
, S.D.=
48.58449937
|
| Residuals: Sum of squares= 11907.74782
, Std.Dev.=
26.46612 |
| Fit:
R-squared= .687636, Adjusted R-squared =
.65089 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
17] =
18.71,
Prob value =
.00005 |
| Diagnostic: Log-L =
-92.2709, Restricted(b=0) Log-L =
-105.5319 |
| Log-determinant of W
31.7546
Log-likelihood
-459.4397 |
| Durbin-Watson Stat.=
.9628
Autocorrelation
=
.5186 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -22.43891319
25.518586
-.879
.3792
FGE
.3729143220E-01 .12263143E-01
3.041
.0024 1941.3250
CGE
.1307829957
.22049738E-01
5.931
.0000 400.16000
181
+-----------------------------------------------------------------------+
| Estimates for equation: IUS
|
| Dep. var. = IUS
Mean=
405.4600000
, S.D.=
129.3519043
|
| Residuals: Sum of squares= 156198.5597
, Std.Dev.=
95.85484 |
| Fit:
R-squared= .421959, Adjusted R-squared =
.35395 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
17] =
6.20,
Prob value =
.00948 |
| Diagnostic: Log-L =
-118.0103, Restricted(b=0) Log-L =
-125.1166 |
| Log-determinant of W
31.7546
Log-likelihood
-459.4397 |
| Durbin-Watson Stat.=
1.0180
Autocorrelation
=
.4910 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 85.42325478
111.87742
.764
.4451
FUS
.1014782341
.54783695E-01
1.852
.0640 1971.8250
CUS
.3999914170
.12779459
3.130
.0017 299.85500
+-----------------------------------------------------------------------+
| Estimates for equation: IWE
|
| Dep. var. = IWE
Mean=
42.89150000
, S.D.=
19.11018860
|
| Residuals: Sum of squares= 1613.511711
, Std.Dev.=
9.74230 |
| Fit:
R-squared= .726429, Adjusted R-squared =
.69424 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 2,
17] =
22.57,
Prob value =
.00002 |
| Diagnostic: Log-L =
-72.2831, Restricted(b=0) Log-L =
-86.8703 |
| Log-determinant of W
31.7546
Log-likelihood
-459.4397 |
| Durbin-Watson Stat.=
1.2590
Autocorrelation
=
.3705 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 1.088876997
6.2588045
.174
.8619
FWE
.5700914748E-01 .11362252E-01
5.017
.0000 670.91000
CWE
.4150649070E-01 .41201609E-01
1.007
.3137 85.640000
Matrix SIGMA
has
1
5 rows and
2
5 columns.
3
182
+-------------1| .1291694D+03
*/
?
? Carry out test by sepcifying restricted regression
? Note: This carries out the test correctly, but does not actually
? compute the correct restricted least squares estimator.
?
SURE
; Lhs = igm,ich,ige,ius,iwe
; Eq1=XGM ; Eq2=XCH ; Eq3=XGE ; Eq4=XUS ; Eq5=XWE
; Maxit = 1
; cls:b(1)-b(4)=0,b(1)-b(7)=0,b(1)-b(10)=0,b(1)-b(13)=0,
b(2)-b(5)=0,b(2)-b(8)=0,b(2)-b(11)=0,b(2)-b(14)=0,
b(3)-b(6)=0,b(3)-b(9)=0,b(3)-b(12)=0,b(3)-b(15)=0$
/*
+-----------------------------------------------------------------------+
| Estimates for equation: IWE
|
| Wald test: Chi-squared[12] =
1550.0328, Prob =
.0000
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -14.71208208
1.7747163
-8.290
.0000
FWE
.6367998108E-01 .34176648E-02
18.633
.0000 670.91000
CWE
.1812500076
.12304415E-01
14.730
.0000 85.640000
*/
/*=================================================================
Example 15.10. FGLS Versus SUR Residuals
*/=================================================================
?
Sample ; 1 - 20 $
Regress; Lhs = igm ; Rhs = Xgm ; res = egm $
Regress; Lhs = ich ; Rhs = Xch ; res = ech $
Regress; Lhs = ige ; Rhs = Xge ; res = ege $
Regress; Lhs = iwe ; Rhs = Xwe ; res = ewe $
Regress; Lhs = ius ; Rhs = Xus ; res = eus $
Matrix ; List ; ROLS = Xcor(egm,ech,ege,ewe,eus) $
CorrelationMatrixforListedVariables
EGM
ECH
EGE
EWE
EUS
1.00000 -.27295
.27929
.15836 -.27841
-.27295 1.00000 -.06792
.11544
.36207
.27929 -.06792 1.00000
.72896
.37323
.15836
.11544
.72896 1.00000
.61499
-.27841
.36207
.37323
.61499 1.00000
SURE
; Lhs = igm,ich,ige,ius,iwe
; Eq1=XGM ; Eq2=XCH ; Eq3=XGE ; Eq4=XUS ; Eq5=XWE
; Maxit = 1
Matrix;bf1=b(1:3);bf2=b(4:6);bf3=b(7:9);bf4=b(10:12);bf5=b(13:15)$
Create ; ef1=igm-Xgmbf1
; ef2=ich-Xchbf2
; ef3=ige-Xgebf3
; ef4=iwe-Xwebf4
; ef5=ius-Xusbf5 $
Matrix ; List ; RGLS = Xcor(ef1,ef2,ef3,ef4,ef5) $
Correlation Matrix for Listed Variables
EF1
EF2
EF3
EF4
EF5
EF1 1.00000 -.29870
.26925
.00814 -.26189
EF2 -.29870 1.00000
.00626
.01514
.26934
EF3
.26925
.00626 1.00000
.06778
.42705
EF4
.00814
.01514
.06778 1.00000 -.44053
EGM
ECH
EGE
EWE
EUS
183
EF5 -.26189
.26934
.42705 -.44053 1.00000
?
? Lagrange Multiplier Test based on OLS residuals. To sum the squares
? of the off diagonal elements, first put zeros on the diagonal. Then,
? trace of square gives sum of squares of all elements. Divide by 2 to
? take care of double counting.
?
Matrix ; MLM = ROLS - IDEN(5) ; MLM = MLM*MLM $
Calc
; List ; LM = Nperiod/2 * Trc(MLM)
; Ctb(.99,(nfirm*(nfirm-1)/2)) $
/*
LM
= .29060485555441890D+02
Result = .23209251160820010D+02
*/
/*=================================================================
Example 15.11. ML Estimates of a SUR Model
*/=================================================================
?
? ML estimates are obtained by allowing the procedure to iterate
? to convergence.
?
Sample
; 1 - 100 $
Create
; igm=0;ich=0;ige=0;iwe=0;ius=0
; fgm=0;fch=0;fge=0;fwe=0;fus=0
; cgm=0;cch=0;cge=0;cwe=0;cus=0 $
Matrix
; mi = Mvec(i,nfirm,nperiod) ; mi = mi' $
Matrix
; mf = Mvec(f,nfirm,nperiod) ; mf = mf' $
Matrix
; mc = Mvec(c,nfirm,nperiod) ; mc = mc' $
Namelist ; Ivars = igm,ich,ige,iwe,ius
; Fvars = fgm,fch,fge,fwe,fus
; Cvars = cgm,cch,cge,cwe,cus $
Sample
; 1 - 20 $
Create
; Ivars = mi $
Create
; Fvars = mf $
Create
; Cvars = mc $
Namelist ; XGM = One,fgm,cgm
; XCH = One,fch,cch
; XGE = One,fge,cge
; XWE = One,fwe,cwe
; XUS = One,fus,cus $
SURE
; Lhs = igm,ich,ige,ius,iwe
; Eq1=XGM ; Eq2=XCH ; Eq3=XGE ; Eq4=XUS ; Eq5=XWE
; Maxit = 1 $
Matrix
; List ; Sigma $
Iteration
Iteration
Iteration
Iteration
Iteration
Iteration
GLS
0,
1,
2,
3,
4,
5,
GLS
GLS
GLS
GLS
GLS
GLS
has converged.
=
=
=
=
=
=
-463.5217
-459.4397
-459.1357
-459.0997
-459.0936
-459.0925
184
+-----------------------------------------------------------------------+
| Estimates for equation: IGM
|
| Durbin-Watson Stat.=
.9383
Autocorrelation
=
.5309 |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -173.2176797
84.298124
-2.055
.0399
FGM
.1220404351
.20248193E-01
6.027
.0000 4333.8450
CGM
.3891420883
.31853734E-01
12.217
.0000 648.43500
+-----------------------------------------------------------------------+
| Estimates for equation: ICH
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 2.391102028
11.625129
.206
.8370
FCH
.6740919305E-01 .17092455E-01
3.944
.0001 693.21000
CCH
.3051975031
.26064536E-01
11.709
.0000 121.24500
+-----------------------------------------------------------------------+
| Estimates for equation: IGE
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -16.66234504
24.960767
-.668
.5044
FGE
.3710283977E-01 .11772336E-01
3.152
.0016 1941.3250
CGE
.1172622817
.21732911E-01
5.396
.0000 400.16000
+-----------------------------------------------------------------------+
| Estimates for equation: IUS
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 136.9688969
94.854504
1.444
.1487
FUS
.8864869952E-01 .45421534E-01
1.952
.0510 1971.8250
CUS
.3124556241
.11795591
2.649
.0081 299.85500
+-----------------------------------------------------------------------+
| Estimates for equation: IWE
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 4.373114492
6.0182436
.727
.4674
FWE
.5397459707E-01 .10302642E-01
5.239
.0000 670.91000
CWE
.2693003954E-01 .37075900E-01
.726
.4676 85.640000
Matrix Result
has 5 rows and 5 columns.
1
2
3
4
5
+---------------------------------------------------------------------1| .7307269D+04 -.3305469D+03 .5502720D+03 -.2879089D+04 .
1188285D+03
2| -.3305469D+03 .1550764D+03 .1142935D+02 .4632117D+03 .
1873590D+02
3| .5502720D+03 .1142935D+02 .7412188D+03 .1408133D+04 .
2203347D+03
4| -.2879089D+04 .4632117D+03 .1408133D+04 .9671446D+04 .
7348291D+03
5| .1188285D+03 .1873590D+02 .2203347D+03 .7348291D+03 .
1031261D+03
185
/*=================================================================
Example 15.12. Investment Model
No computations.
*/=================================================================
/*=================================================================
Example 15.13. Likelihood Ratio Test in a SUR Model
*/=================================================================
?
? 1. GET MLE for full SURE model and recover log determinant
?
SURE
; Lhs = igm,ich,ige,ius,iwe
; Eq1=XGM ; Eq2=XCH ; Eq3=XGE ; Eq4=XUS ; Eq5=XWE
; Maxit = 100 $
Matrix
; List ; LogDet = Logd(Sigma) $
/*
Matrix LOGDET
has 1 rows and 1 columns.
1
+-------------1| .3171986D+02
*/
?
? 2. Restricted model is TSCS model with free corelations. Get MLE
?
Tscs
; Lhs = i ; Rhs = X ; Pds = Nperiod ; Model = S2,R0 ; MLE $
Matrix
; V = Part(Sigma,1,5,1,5) ; List ; LogDetR=Logd(V) $
/*
Matrix LOGDETR has 1 rows and 1 columns.
1
+-------------1| .3783788D+02
*/
? 3. Compute log likelihoods, LR statistic, and critical value.
?
Calc
; List ; LoglU = -Nfirm*Nperiod/2*(1+log(2*pi)+logDet/Nfirm)
; LoglR = -Nfirm*Nperiod/2*(1+log(2*pi)+logDetR/Nfirm)
; Chisq = -2*LogLR-LogLU)
; Ctb(.99,((Nfirm-1)*Col(X)))$
/*
LOGLU
= -.45909250041647690D+03
LOGLR
= -.52027269550976920D+03
CHISQ
= .12236039018658460D+03
Result = .26216967307500020D+02
*/
/*=================================================================
Example 15.14. An Application from Financial Econometrics The CAPM Model
No computations.
*/=================================================================
186
/*=================================================================
Example 15.15. Autocorrelation in a SUR Model
*/=================================================================
SURE
; Lhs = igm,ich,ige,ius,iwe
; Eq1=XGM ; Eq2=XCH ; Eq3=XGE ; Eq4=XUS ; Eq5=XWE
; Maxit = 1 ; Model = 1 $
+-----------------------------------------------------------------------+
| Estimates for equation: IGM
|
| Durbin-Watson Stat.=
1.4396
Autocorrelation
=
.2802 |
| RHO used for GLS
.5313
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -51.33436533
80.617258
-.637
.5243
FGM
.9403760635E-01 .17330927E-01
5.426
.0000 4333.8450
CGM
.4072352372
.42611024E-01
9.557
.0000 648.43500
+-----------------------------------------------------------------------+
| Estimates for equation: ICH
|
| Durbin-Watson Stat.=
1.9727
Autocorrelation
=
.0137 |
| RHO used for GLS
.0080
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -.4540053598
11.856027
-.038
.9695
FCH
.6847405793E-01 .17398774E-01
3.936
.0001 693.21000
CCH
.3204153362
.25785542E-01
12.426
.0000 121.24500
+-----------------------------------------------------------------------+
| Estimates for equation: IGE
|
| Durbin-Watson Stat.=
1.2140
Autocorrelation
=
.3930 |
| RHO used for GLS
.4640
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -24.91380819
25.670652
-.971
.3318
FGE
.4271594338E-01 .11335958E-01
3.768
.0002 1941.3250
CGE
.1095435439
.30121429E-01
3.637
.0003 400.16000
+-----------------------------------------------------------------------+
| Estimates for equation: IUS
|
| Durbin-Watson Stat.=
1.3528
Autocorrelation
=
.3236 |
| RHO used for GLS
.5455
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 14.01600097
96.488418
.145
.8845
FUS
.1641474407
.38641329E-01
4.248
.0000 1971.8250
CUS
.2005957422
.14276114
1.405
.1600 299.85500
+-----------------------------------------------------------------------+
| Estimates for equation: IWE
|
| Durbin-Watson Stat.=
1.3790
Autocorrelation
=
.3105 |
| RHO used for GLS
.2935
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 4.708707973
6.5097903
.723
.4695
FWE
.5091142623E-01 .10604759E-01
4.801
.0000 670.91000
CWE
.4284561336E-01 .41272782E-01
1.038
.2992 85.640000
187
Matrix
; List ; Sigma $
/*
Matrix Result
has 5 rows and
1
2
5 columns.
3
188
/*=================================================================
Example 15.17. Cobb-Douglas Cost Function
*/=================================================================
Read ; Nobs = 20 ; Nvar = 9 ; Names = 1 $
Firm
Cost Output Pk
Pl
Pf
Sk
Sl
Sf
1
.423
39
164
2.30
23.6 0.4137 0.1702 0.4161
2
1.130
130
176
1.82
38.9 0.2779 0.1712 0.6049
3
1.565
197
183
2.19
29.1 0.4151 0.0692 0.5157
4
2.382
338
163
1.85
24.6 0.4799 0.0616 0.4585
5
4.580
484
176
1.75
42.8 0.2828 0.1009 0.6162
6
5.535
719
174
1.70
26.9 0.4946 0.0703 0.4351
7
6.754
984
158
1.76
26.9 0.2435 0.1083 0.6482
8
7.743
1122
162
2.19
29.1 0.3744 0.0977 0.5279
9
8.488
1215
164
2.19
29.1 0.4390 0.0695 0.4915
10
11.320
2870
167
1.76
10.3 0.5822 0.1333 0.2845
11
10.879
1649
177
2.32
31.9 0.3991 0.0974 0.5035
12
12.905
2341
183
2.04
20.7 0.4165 0.0945 0.4890
13
15.437
2023
163
2.11
24.4 0.3989 0.0808 0.5203
14
19.035
3202
170
2.30
23.6 0.4974 0.0983 0.4043
15
21.988
5283
159
2.04
20.7 0.4491 0.0630 0.4879
16
29.845
4764
195
2.19
29.1 0.3530 0.1328 0.5142
17
33.354
7886
178
1.61
17.8 0.5835 0.0587 0.3578
18
40.594
7193
162
2.12
28.6 0.3550 0.0729 0.5721
19
67.120 11477
151
2.24
26.5 0.3458 0.0670 0.5872
20 119.939 16719
162
2.30
23.6 0.4340 0.0906 0.4754
?
? Data setup. Loglinear models
?
Create ; lq=log(output) ; lq2 = lq*lq
; lc=log(cost)
; lk=log(pk) ; ll=log(pl) ; lf=log(pf) $
?
? Least squares, not imposing restriction that bk+bl+bf=1
?
Regress; lhs=lc ; Rhs = one,lq,lk,ll,lf $
Regress; lhs=lc ; Rhs = one,lq,lq2,lk,ll,lf $
?
? ML SURE, imposes restriction
?
Create ; lc=lc-lf ; lk=lk-lf ; ll=ll-lf $
Sure
; Lhs = lc,sk,sl
; Rhs = one,lq,ll,lf
; Labels = b0,bq,bk,bl
; pattern = b0,bq,bk,bl,
bk,0,0,0,
bl,0,0,0 $
Wald
; fn1=1-bk-bl ; Start=b ; Var=Varb ; Labels=b0,bq,bk,bl $
Sure
; Lhs = lc,sk,sl
; Rhs = one,lq,lq2,ll,lf
; Labels = b0,bq,bq2,bk,bl
; pattern = b0,bq,bq2,bk,bl,
bk,0,0,0,0,
bl,0,0,0,0 $
Wald
; fn1=1-bk-bl ; Start=b ; Var=Varb ; Labels=b0,bq,bk,bl,bf $
189
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LC
Mean=
2.282543663
, S.D.=
1.398724766
|
| Model size: Observations =
20, Parameters =
5, Deg.Fr.=
15 |
| Residuals: Sum of squares= .2775097730
, Std.Dev.=
.13602 |
| Fit:
R-squared= .992534, Adjusted R-squared =
.99054 |
| Model test: F[ 4,
15] = 498.56,
Prob value =
.00000 |
| Diagnostic: Log-L =
14.3975, Restricted(b=0) Log-L =
-34.5771 |
|
LogAmemiyaPrCrt.=
-3.767, Akaike Info. Crt.=
-.940 |
| Autocorrel: Durbin-Watson Statistic =
1.58555,
Rho =
.20722 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -4.175882556
2.6896858
-1.553
.1414
LQ
.9028154938
.21635888E-01
41.728
.0000 7.3096840
LK
-.3509099345
.51860696
-.677
.5089 5.1301261
LL
.3588604772
.27471845
1.306
.2111 .70587541
LF
.4344258321
.11747325
3.698
.0021 3.2365287
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LC
Mean=
2.282543663
, S.D.=
1.398724766
|
| Model size: Observations =
20, Parameters =
6, Deg.Fr.=
14 |
| Residuals: Sum of squares= .2467995300
, Std.Dev.=
.13277 |
| Fit:
R-squared= .993361, Adjusted R-squared =
.99099 |
| Model test: F[ 5,
14] = 418.93,
Prob value =
.00000 |
| Diagnostic: Log-L =
15.5703, Restricted(b=0) Log-L =
-34.5771 |
|
LogAmemiyaPrCrt.=
-3.776, Akaike Info. Crt.=
-.957 |
| Autocorrel: Durbin-Watson Statistic =
1.64831,
Rho =
.17585 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -4.107356204
2.6260384
-1.564
.1401
LQ
.6986019036
.15615647
4.474
.0005 7.3096840
LQ2
.1511281290E-01 .11450167E-01
1.320
.2081 55.788906
LK
-.2370860301
.51352884
-.462
.6514 5.1301261
LL
.2358712078
.28389354
.831
.4200 .70587541
LF
.4603694543
.11634346
3.957
.0014 3.2365287
+-------------------------------------------------------------------------+
| Constrained MLE for Multivariate Regression Model
|
| First iteration: 0 F=
-9.9936 log|W|= -7.51427 gtinv(H)g=
1.7212 |
| Last iteration: 5 F=
74.4511 log|W|= -15.95874 gtinv(H)g=
.0001 |
| Number of observations used in estimation =
20
|
| Model:
ONE
LQ
LL
LF
|
| LC
B0
BQ
BK
BL
|
| SK
BK
|
| SL
BL
|
+-------------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B0
-6.969372925
.15682188
-44.441
.0000
BQ
.9245741247
.18215422E-01
50.758
.0000
BK
.4143856284
.19320827E-01
21.448
.0000
BL
.9472428129E-01 .72711459E-02
13.027
.0000
190
Matrix SIGMA
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
701.69632
|
| Prob. from Chi-squared[ 1] =
.00000
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .4908900903
.18531461E-01
26.490
.0000
+-------------------------------------------------------------------------+
| Constrained MLE for Multivariate Regression Model
|
| First iteration: 0 F=
-9.9936 log|W|= -7.51427 gtinv(H)g=
1.7532 |
| Last iteration: 6 F=
75.1869 log|W|= -16.03232 gtinv(H)g=
.0001 |
| Number of observations used in estimation =
20
|
| Model:
ONE
LQ
LQ2
LL
LF
|
| LC
B0
BQ
BQ2
BK
BL
|
| SK
BK
|
| SL
BL
|
+-------------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B0
-6.367355211
.44937811
-14.169
.0000
BQ
.7441834328
.13221618
5.629
.0000
BQ2
.1283330275E-01 .95383070E-02
1.345
.1785
BK
.4141143388
.19310400E-01
21.445
.0000
BL
.9470678052E-01 .72686792E-02
13.029
.0000
Matrix SIGMA
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
735.54112
|
| Prob. from Chi-squared[ 1] =
.00000
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .5730523585
.21129578E-01
27.121
.0000
*/
/*=================================================================
Example 15.18. A Cost Function for U.S. Manufacturing
*/=================================================================
191
Cost
182.373
183.161
186.533
221.710
255.945
264.699
291.160
274.457
308.908
328.286
338.633
323.318
358.435
366.251
366.162
390.668
412.188
433.768
474.969
521.291
540.941
585.447
630.450
623.466
658.235
K
0.05107
0.05817
0.04602
0.04991
0.05039
0.04916
0.04728
0.05635
0.05258
0.04604
0.05033
0.06015
0.06185
0.05788
0.05903
0.05578
0.05601
0.05452
0.05467
0.05460
0.05443
0.05758
0.05410
0.05255
0.04675
L
0.24727
0.27716
0.25911
0.24794
0.25487
0.26655
0.26832
0.27167
0.26465
0.26880
0.27184
0.27283
0.27303
0.27738
0.27839
0.28280
0.27968
0.28343
0.27996
0.28363
0.28646
0.28883
0.29031
0.29755
0.28905
E
0.04253
0.05127
0.05075
0.04606
0.04482
0.04460
0.04369
0.04787
0.04517
0.04576
0.04820
0.04836
0.04563
0.04585
0.04640
0.04530
0.04470
0.04392
0.04114
0.04014
0.04074
0.03971
0.03963
0.04348
0.04479
M
0.65913
0.61340
0.64411
0.65609
0.64992
0.63969
0.64071
0.62411
0.63760
0.63940
0.62962
0.61886
0.61948
0.61889
0.61617
0.61613
0.61962
0.61814
0.62423
0.62163
0.61837
0.61388
0.61597
0.60642
0.61940
Pk
1.00000
1.00270
0.74371
0.92497
1.04877
0.99744
1.00653
1.08757
1.10315
0.99606
1.06321
1.15619
1.30758
1.25413
1.26328
1.26525
1.32294
1.32798
1.40659
1.45100
1.38617
1.49901
1.44957
1.32464
1.20177
Pl
1.00000
1.15457
1.15584
1.23535
1.33784
1.37949
1.43458
1.45362
1.51120
1.58186
1.64641
1.67389
1.73430
1.78280
1.81977
1.88531
1.93379
2.00998
2.05539
2.13441
2.20616
2.33869
2.46412
2.60532
2.76025
Pe
1.00000
1.30258
1.19663
1.12442
1.25179
1.27919
1.27505
1.30356
1.34277
1.37154
1.38010
1.39338
1.36756
1.38025
1.37630
1.37689
1.34737
1.38969
1.38635
1.40102
1.39197
1.43388
1.46481
1.45907
1.64689
Pm
1.00000
1.05525
1.06625
1.12430
1.21694
1.19961
1.19044
1.20612
1.23835
1.29336
1.30703
1.32699
1.30774
1.33946
1.34319
1.34745
1.33143
1.35197
1.37542
1.41878
1.42428
1.43481
1.53356
1.54758
1.54978
?
? Initial Data Setup
?
Create ; lc=log(cost/pm) ; lk=log(pk/pm) ; ll=log(pl/pm) ; le=log(pe/pm)
; lkk=lk*lk/2 ; lll=ll*ll/2 ; lee=le*le/2
; lkl=ll*lk
; lke=lk*le
; lle=ll*le $
Create ; lpk=log(pk) ; lpl=log(pl) ; lpe=log(pe) ; lpm=log(pm) $
?
? SURE model, ML with all symmetry and adding up restrictions
?
Sure
; Lhs = k,l,e ; Rhs = One,lk,ll,le
; Labels = bk,bl,be,dkk,dkl,dke,dll,dle,dee
; Pattern = bk,dkk,dkl,dke, bl,dkl,dll,dle, be,dke,dle,dee $
?
? Estimate remaining parameters, then gather in matrices for elasticities
?
Wald
; Start = b ; Var = Varb ; Labels = bk,bl,be,dkk,dkl,dke,dll,dle,dee
; fn1 = 1-bk-bl-be
? This is betam
; fn2 = -dkk-dkl-dke
? delta km
; fn3 = -dkl-dll-dle
? delta lm
; fn4 = -dke-dle-dee
? delta em
; fn5 = -fn2-fn3-fn4 $
? delta mm
Calc
; bm=waldfns(1) ; dkm=waldfns(2) ; dlm=waldfns(3)
; dem=waldfns(4) ; dmm=waldfns(5)
; bk=b(1) ; bl=b(2) ; be=b(3)
; dkk=b(4) ; dkl=b(5) ; dke=b(6) ; dll=b(7) ; dle=b(8) ; dee=b(9) $
Matrix ; beta = [bk/bl/be/bm]
; delta= [dkk,dkl,dke,dkm /
dkl,dll,dle,dlm /
dke,dle,dee,dem /
dkm,dlm,dem,dmm] $
192
193
Matrix SIGMA
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .6452534391
.32994003E-02 195.567
.0000
Fncn( 2) -.1879519464E-01 .97098906E-02
-1.936
.0529
Fncn( 3) -.7061270629E-01 .10594548E-01
-6.665
.0000
Fncn( 4) -.2966628719E-02 .79953601E-02
-.371
.7106
Fncn( 5) .9237452965E-01 .22468890E-01
4.111
.0000
Fitted Shares
Matrix Result
194
195
/*=================================================================
Example 16.2. A Small Macroeconomic Model
No computations
*/=================================================================
/*=================================================================
Example 16.3. Kleins Model I
No Computations
*/=================================================================
/*=================================================================
Example 16.4. Cobweb Model
No computations
*/=================================================================
/*=================================================================
Example 16.5. Structure and Reduced Form
No computations
*/=================================================================
/*=================================================================
Example 16.6. Observational Equivalence
No computations
*/=================================================================
/*=================================================================
Example 16.7. Identification
No computations
*/=================================================================
/*=================================================================
Example 16.8. An Identified Model
No computations
*/=================================================================
/*=================================================================
Example 16.9. Rank and Order Conditions
No computations
*/=================================================================
/*=================================================================
Example 16.10. Identification of Kleins Model I
No computations
*/=================================================================
/*=================================================================
Example 16.11. Identification with Linear Restrictions
No computations
*/=================================================================
/*=================================================================
Example 16.12. The Fully Recursive Model
No computations
*/=================================================================
/*=================================================================
Example 16.13. A Model of Industry Structure
No computations
*/=================================================================
/*=================================================================
Example 16.14. Regression Function
196
No computations
*/=================================================================
/*=================================================================
Example 16.15. Limited Information Estimation of Kleins
Consumption Function
*/=================================================================
Read ; Nobs = 22 ; Nvar = 10 ; Names = 1 $
Year C
P
Wp
I
Klag
X
Wg
G
T
1920 39.8 12.7 28.8 2.7 180.1 44.9 2.2 2.4 3.4
1921 41.9 12.4 25.5 -0.2 182.8 45.6 2.7 3.9 7.7
1922 45.0 16.9 29.3 1.9 182.6 50.1 2.9 3.2 3.9
1923 49.2 18.4 34.1 5.2 184.5 57.2 2.9 2.8 4.7
1924 50.6 19.4 33.9 3.0 189.7 57.1 3.1 3.5 3.8
1925 52.6 20.1 35.4 5.1 192.7 61.0 3.2 3.3 5.5
1926 55.1 19.6 37.4 5.6 197.8 64.0 3.3 3.3 7.0
1927 56.2 19.8 37.9 4.2 203.4 64.4 3.6 4.0 6.7
1928 57.3 21.1 39.2 3.0 207.6 64.5 3.7 4.2 4.2
1929 57.8 21.7 41.3 5.1 210.6 67.0 4.0 4.1 4.0
1930 55.0 15.6 37.9 1.0 215.7 61.2 4.2 5.2 7.7
1931 50.9 11.4 34.5 -3.4 216.7 53.4 4.8 5.9 7.5
1932 45.6 7.0 29.0 -6.2 213.3 44.3 5.3 4.9 8.3
1933 46.5 11.2 28.5 -5.1 207.1 45.1 5.6 3.7 5.4
1934 48.7 12.3 30.6 -3.0 202.0 49.7 6.0 4.0 6.8
1935 51.3 14.0 33.2 -1.3 199.0 54.4 6.1 4.4 7.2
1936 57.7 17.6 36.8 2.1 197.7 62.7 7.4 2.9 8.3
1937 58.7 17.3 41.0 2.0 199.8 65.0 6.7 4.3 6.7
1938 57.5 15.3 38.2 -1.9 201.8 60.9 7.7 5.3 7.4
1939 61.6 19.0 41.6 1.3 199.9 69.5 7.8 6.6 8.9
1940 65.0 21.1 45.0 3.3 201.2 75.7 8.0 7.4 9.6
1941 69.7 23.5 53.3 4.9 204.5 88.4 8.5 13.8 11.6
?
? Data preparation for examples
?
Create ; If(_Obsno > 1) Plag = P[-1] $
Create ; If(_Obsno > 1) Xlag = X[-1] $
Create ; W = Wp + Wg $
Create ; A = Year - 1931 $
Date
; 1920 $
Period ; 1921 - 1941 $
Namelist ; ZC = One,P,Plag,W
; ZI = One,P,Plag,Klag
; ZWp = One,X,Xlag,A
; Xc = One,Plag
; allX= One,G,T,A,Wg,Plag,Klag,Xlag
; Yc = C,P,W
; Yic = P,W $
?
197
198
| Two stage
least squares regression
Weighting variable = none
|
| Dep. var. = C
Mean=
53.99523810
, S.D.=
6.860865557
|
| Model size: Observations =
21, Parameters =
4, Deg.Fr.=
17 |
| Residuals: Sum of squares= 17.74900975
, Std.Dev.=
1.02179 |
| Fit:
R-squared= .976711, Adjusted R-squared =
.97260 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 3,
17] = 237.65,
Prob value =
.00000 |
| Diagnostic: Log-L =
-28.0317, Restricted(b=0) Log-L =
-69.7279 |
|
LogAmemiyaPrCrt.=
.217, Akaike Info. Crt.=
3.051 |
| Autocorrel: Durbin-Watson Statistic =
1.48507,
Rho =
.25746 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 16.55475577
1.3207924
12.534
.0000
P
.1730221194E-01 .11804941
.147
.8835 16.890476
PLAG
.2162340404
.10726796
2.016
.0438 16.376190
W
.8101826976
.40249714E-01
20.129
.0000 41.480952
+---------------------------------------------+
| Instrumental Variables (NL2SLS)
|
| GMM Estimator - Lags
= 0 Periods
|
| Value of the GMM criterion:
|
| e(b)tZ inv(ZtWZ) Zte(b)
=
4.835800
|
| Sum of functions f(x,b)
=
.6479525
|
| Sample size is
21 observations.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1
14.74432887
1.1596099
12.715
.0000
C1
.7579169049E-01 .93571242E-01
.810
.4179
B2
.1662685044
.82477615E-01
2.016
.0438
C2
.8493652466
.35606173E-01
23.854
.0000
+---------------------------------------------+
| Instrumental Variables (NL2SLS)
|
| GMM Estimator - Lags
= 0 Periods
|
| Value of the GMM criterion:
|
| e(b)tZ inv(ZtWZ) Zte(b)
=
3.742084
|
| Sum of functions f(x,b)
=
-1.337299
|
| Sample size is
21 observations.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1
14.31901808
.89660570
15.970
.0000
C1
.9024320093E-01 .61598126E-01
1.465
.1429
B2
.1433282337
.65493259E-01
2.188
.0286
C2
.8639300042
.29249909E-01
29.536
.0000
LC
= .14987455068361610D+01
Matrix statistical results: Coefficients=DELTAC
Variance=ASYVC
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
DELTA_ 1 -.2225130663
.20174780
-1.103
.2701
DELTA_ 2 .8225586646
.55378199E-01
14.853
.0000
DELTA_ 3 17.14765463
1.8402953
9.318
.0000
DELTA_ 4 .3960272891
.17359775
2.281
.0225
199
/*=================================================================
Example 16.16. Nonlinear Two Stage Least Squares
No computations
*/=================================================================
/*=================================================================
Example 16.17. Estimates of Kleins Model I
These are the entries in Table 16.5. Note, LIMDEP does not
contain a FIML estimator for linear simultaneous equations models.
The values in the text are from Julian Silks 1998 survey in the
Journal of Applied Econometrics.
*/=================================================================
?-----------------------------------------------------------------? Limited Information Estimates of the Consumption Function
?-----------------------------------------------------------------Namelist ; ZC = P,W,One,Plag
; Xc = One,Plag
; allX= One,G,T,A,Wg,Plag,Klag,Xlag
; Yc = C,P,W
; Yic = P,W $
?
? Ordinary Least Squares
?
Regress
; lhs=c;rhs=zc $
?
? Two Stage Least Squares
?
2SLS
; lhs=c;rhs=zc;inst=allx $
?
? GMM (Heteroscedastic 2SLS) in two steps
?
Minimize ; fcn=(c-c1*p-c2*w-b1-b2*plag) ;labels=b1,b2,c1,c2
; start=b;inst=allx ;pds=0 $ (Requests White estimator.)
Minimize ; fcn=(c-c1*p-c2*w-b1-b2*plag) ;labels=b1,b2,c1,c2
; start=b;inst=allx ;pds=0 $
?
? Limited Information Maximum Likelihood
?
Matrix
; w0=rcpm(xc,yc) ; w1=rcpm(allx,yc) ; w1iw0=<w1>*w0$
Matrix
; roots=cxrt(w1iw0) $
Calc
; List ; lc=roots(3,1) $ LC = lambda_1
Matrix
; w0c=part(w0,2,3,2,3)- lc*part(w1,2,3,2,3)
; dc =part(w0,2,3,1,1)- lc*part(w1,2,3,1,1)$
Matrix
; gammac=<w0c>*dc$
Matrix
; betac=<Xc'Xc>*Xc'c - <Xc'Xc>*Xc'Yic*Gammac $
Matrix
; deltac=[gammac/betac] $
Create
; ec=c-zc'deltac $
Calc
; scc = 1/n * ec'ec $
Matrix
; vv=yic'yic-yic'allx * <allx'allx> * allx'yic
; q11=yic'yic - lc*vv ; q21=xc'yic ; q22=xc'xc
; Q=[q11/q21,q22]
; AsyVC = scc * <Q> $
Matrix
; Stat(deltac,asyvc)$
200
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 16.23660027
1.3026983
12.464
.0000
P
.1929343813
.91210168E-01
2.115
.0495 16.890476
PLAG
.8988489781E-01 .90647938E-01
.992
.3353 16.376190
W
.7962187497
.39943920E-01
19.933
.0000 41.480952
+-----------------------------------------------------------------------+
| Two stage
least squares regression
Weighting variable = none
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 16.55475577
1.3207924
12.534
.0000
P
.1730221194E-01 .11804941
.147
.8835 16.890476
PLAG
.2162340404
.10726796
2.016
.0438 16.376190
W
.8101826976
.40249714E-01
20.129
.0000 41.480952
+---------------------------------------------+
| Instrumental Variables (NL2SLS)
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1
14.74432887
1.1596099
12.715
.0000
C1
.7579169049E-01 .93571242E-01
.810
.4179
B2
.1662685044
.82477615E-01
2.016
.0438
C2
.8493652466
.35606173E-01
23.854
.0000
+---------------------------------------------+
| Instrumental Variables (NL2SLS)
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1
14.31901808
.89660570
15.970
.0000
C1
.9024320093E-01 .61598126E-01
1.465
.1429
B2
.1433282337
.65493259E-01
2.188
.0286
C2
.8639300042
.29249909E-01
29.536
.0000
+---------------------------------------------+
| Limited Information Maximum Likelihood
|
+---------------------------------------------+
LC
= .14987455068361610D+01
Matrix statistical results: Coefficients=DELTAC
Variance=ASYVC
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
DELTA_ 1 -.2225130663
.20174780
-1.103
.2701
DELTA_ 2 .8225586646
.55378199E-01
14.853
.0000
DELTA_ 3 17.14765463
1.8402953
9.318
.0000
DELTA_ 4 .3960272891
.17359775
2.281
.0225
*/
201
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
.4796356446
.97114565E-01
4.939
.0001 16.890476
Constant 10.12578854
5.4655465
1.853
.0814
PLAG
.3330387135
.10085923
3.302
.0042 16.376190
KLAG
-.1117946837
.26727563E-01
-4.183
.0006 200.49524
+-----------------------------------------------------------------------+
| Two stage
least squares regression
Weighting variable = none
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
.1502218238
.17322929
.867
.3858 16.890476
Constant 20.27820894
7.5427059
2.688
.0072
PLAG
.6159435775
.16278539
3.784
.0002 16.376190
KLAG
-.1577876366
.36126239E-01
-4.368
.0000 200.49524
+---------------------------------------------+
| Instrumental Variables (NL2SLS)
|
+---------------------------------------------+
202
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
C1
.1858604203
.12989159
1.431
.1525
B1
21.40696309
6.3295608
3.382
.0007
B2
.5513081166
.12529953
4.400
.0000
B3
-.1605617059
.30488292E-01
-5.266
.0000
+---------------------------------------------+
| Instrumental Variables (NL2SLS)
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
C1
.1456261147
.12918005
1.127
.2596
B1
23.45972356
6.3989474
3.666
.0002
B2
.5905688424
.12021221
4.913
.0000
B3
-.1705127999
.30659198E-01
-5.562
.0000
+---------------------------------------------+
| Limited Information Maximum Likelihood
|
+---------------------------------------------+
LI
= .10859528454002810D+01
Matrix statistical results: Coefficients=DELTAI
Variance=ASYVI
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
DELTA_ 1 .7518475798E-01 .21852742
.344
.7308
DELTA_ 2 22.59082544
9.2367486
2.446
.0145
DELTA_ 3 .6803863833
.20338880
3.345
.0008
DELTA_ 4 -.1682643562
.44096598E-01
-3.816
.0001
*/
203
204
+---------------------------------------------+
| Instrumental Variables (NL2SLS)
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
C1
.4558023506
.29975507E-01
15.206
.0000
B1
2.674614797
.79150468
3.379
.0007
B2
.1107652011
.32325545E-01
3.427
.0006
B3
.1306003395
.23711758E-01
5.508
.0000
+---------------------------------------------+
| Instrumental Variables (NL2SLS)
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
C1
.4549711244
.27742069E-01
16.400
.0000
B1
3.056885791
.64409650
4.746
.0000
B2
.1058094977
.29645884E-01
3.569
.0004
B3
.1304310746
.21732485E-01
6.002
.0000
+---------------------------------------------+
| Limited Information Maximum Likelihood
|
+---------------------------------------------+
LW
= .24685825448762760D+01
Matrix statistical results: Coefficients=DELTAW
Variance=ASYVW
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
DELTA_ 1 .4339413998
.13721657
3.162
.0016
DELTA_ 2 1.526186685
2.4003056
.636
.5249
DELTA_ 3 .1513206752
.13543451
1.117
.2639
DELTA_ 4 .1315931213
.65413164E-01
2.012
.0442
205
/*
Iteration
Iteration
0, 3SLS
1, 3SLS
=
=
1.000000
6.218180
206
+-----------------------------------------------------------------------+
| Estimates for equation: C
|
| InstVar/GLS least squares regression
Weighting variable = none
|
| Dep. var. = C
Mean=
53.99523810
, S.D.=
6.860865557
|
| Model size: Observations =
21, Parameters =
4, Deg.Fr.=
17 |
| Residuals: Sum of squares= 15.15991704
, Std.Dev.=
.94433 |
| Fit:
R-squared= .980108, Adjusted R-squared =
.97660 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
.1248904748
.10812905
1.155
.2481 16.890476
Constant 16.44079006
1.3045488
12.603
.0000
PLAG
.1631440928
.10043819
1.624
.1043 16.376190
W
.7900809364
.37937905E-01
20.826
.0000 41.480952
+-----------------------------------------------------------------------+
| Estimates for equation: I
|
| InstVar/GLS least squares regression
Weighting variable = none
|
| Dep. var. = I
Mean=
1.266666667
, S.D.=
3.551947822
|
| Model size: Observations =
21, Parameters =
4, Deg.Fr.=
17 |
| Residuals: Sum of squares= 35.58179232
, Std.Dev.=
1.44674 |
| Fit:
R-squared= .825805, Adjusted R-squared =
.79507 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
-.1307918242E-01 .16189624
-.081
.9356 16.890476
Constant 28.17784687
6.7937702
4.148
.0000
PLAG
.7557239621
.15293313
4.942
.0000 16.376190
KLAG
-.1948482493
.32530695E-01
-5.990
.0000 200.49524
+-----------------------------------------------------------------------+
| Estimates for equation: WP
|
| InstVar/GLS least squares regression
Weighting variable = none
|
| Dep. var. = WP
Mean=
36.36190476
, S.D.=
6.304401335
|
| Model size: Observations =
21, Parameters =
4, Deg.Fr.=
17 |
| Residuals: Sum of squares= 8.840453075
, Std.Dev.=
.72113 |
| Fit:
R-squared= .986262, Adjusted R-squared =
.98384 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
X
.4004918798
.31813414E-01
12.589
.0000 60.057143
Constant 1.797217728
1.1158550
1.611
.1073
XLAG
.1812910150
.34158776E-01
5.307
.0000 57.985714
A
.1496741151
.27935236E-01
5.358
.0000 .00000000
207
Iteration
0, 3SLS
=
1.000000
Iteration
1, 3SLS
=
6.218180
Iteration
2, 3SLS
=
10.48822
Iteration
3, 3SLS
=
.5763712
Iteration
4, 3SLS
=
.2171606
Iteration
5, 3SLS
=
.1027887
Iteration
6, 3SLS
=
.5286157E-01
Iteration
7, 3SLS
=
.2829082E-01
Iteration
8, 3SLS
=
.1549538E-01
Iteration
9, 3SLS
=
.8618531E-02
Iteration
10, 3SLS
=
.4845825E-02
Iteration
11, 3SLS
=
.2745297E-02
Iteration
12, 3SLS
=
.1563106E-02
Iteration
13, 3SLS
=
.8927143E-03
Iteration
14, 3SLS
=
.5106840E-03
Iteration
15, 3SLS
=
.2923557E-03
Iteration
16, 3SLS
=
.1674028E-03
Iteration
17, 3SLS
=
.9585057E-04
Iteration
18, 3SLS
=
.5487439E-04
Iteration
19, 3SLS
=
.3141145E-04
Iteration
20, 3SLS
=
.1797896E-04
Iteration
21, 3SLS
=
.1029008E-04
Iteration
22, 3SLS
=
.5889308E-05
3SLS
has converged.
+-----------------------------------------------------------------------+
| Estimates for equation: C
|
| Dep. var. = C
Mean=
53.99523810
, S.D.=
6.860865557
|
| Residuals: Sum of squares= 15.55344524
, Std.Dev.=
.95651 |
| Fit:
R-squared= .979592, Adjusted R-squared =
.97599 |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
.1645094601
.96197848E-01
1.710
.0872 16.890476
Constant 16.55898395
1.2244009
13.524
.0000
PLAG
.1765639840
.90100112E-01
1.960
.0500 16.376190
W
.7658012598
.34759924E-01
22.031
.0000 41.480952
+-----------------------------------------------------------------------+
| Estimates for equation: I
|
| Dep. var. = I
Mean=
1.266666667
, S.D.=
3.551947822
|
| Residuals: Sum of squares= 77.44061536
, Std.Dev.=
2.13432 |
| Fit:
R-squared= .620881, Adjusted R-squared =
.55398 |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
P
-.3565294667
.26015597
-1.370
.1705 16.890476
Constant 42.89618287
10.593827
4.049
.0001
PLAG
1.011297438
.24877372
4.065
.0000 16.376190
KLAG
-.2601995125
.50869239E-01
-5.115
.0000 200.49524
+-----------------------------------------------------------------------+
| Estimates for equation: WP
|
| Dep. var. = WP
Mean=
36.36190476
, S.D.=
6.304401335
|
| Residuals: Sum of squares= 10.29600960
, Std.Dev.=
.77823 |
| Fit:
R-squared= .984000, Adjusted R-squared =
.98118 |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
X
.3747792799
.31102726E-01
12.050
.0000 60.057143
Constant 2.624763189
1.1955595
2.195
.0281
XLAG
.1936506079
.32401819E-01
5.977
.0000 57.985714
A
.1679261514
.28929060E-01
5.805
.0000 .00000000
208
+---------------------------------------------+
| Instrumental Variables (NLGMM)
|
| GMM Estimator - Lags
= 0 Periods
|
| Value of the GMM criterion:
|
| e(b)tZ inv(ZtWZ) Zte(b)
=
7.606920
|
| Criterion is computed with 2 moments.
|
| Sample size is
21 observations.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1C
14.30534796
.79434267
18.009
.0000
B2C
.1433584920
.58608748E-01
2.446
.0144
C1C
.8602401610E-01 .56340585E-01
1.527
.1268
C2C
.8653025338
.27820114E-01
31.103
.0000
C1I
.1351102595
.94264741E-01
1.433
.1518
B1I
25.34841841
5.6448443
4.491
.0000
B2I
.5927664696
.93616894E-01
6.332
.0000
B3I
-.1796698395
.27689550E-01
-6.489
.0000
+----------------------------------------------------------------------+
| __ Equation
Mean of LHS
S.D. of LHS
R-squared
Sum of squares |
| 1 C
53.995238
6.860866
.976663 .2197005865D+02 |
| 2 I
1.266667
3.551948
.874902 .3156545749D+02 |
| Note, R-squared can be negative if not using unconstrained OLS.
|
+----------------------------------------------------------------------+
+---------------------------------------------+
| Instrumental Variables (NLGMM)
|
| GMM Estimator - Lags
= 0 Periods
|
| Value of the GMM criterion:
|
| e(b)tZ inv(ZtWZ) Zte(b)
=
8.071095
|
| Criterion is computed with 2 moments.
|
| Sample size is
21 observations.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1C
14.12059142
.78436693
18.003
.0000
B2C
.1334184814
.53436985E-01
2.497
.0125
C1C
.8955986166E-01 .51408927E-01
1.742
.0815
C2C
.8718406315
.27353986E-01
31.873
.0000
C1I
.1172631998
.10486278
1.118
.2635
B1I
27.30187323
6.0641470
4.502
.0000
B2I
.6015143664
.10075260
5.970
.0000
B3I
-.1886236665
.29346365E-01
-6.427
.0000
+----------------------------------------------------------------------+
| __ Equation
Mean of LHS
S.D. of LHS
R-squared
Sum of squares |
| 1 C
53.995238
6.860866
.976123 .2247893030D+02 |
| 2 I
1.266667
3.551948
.866117 .3378217615D+02 |
| Note, R-squared can be negative if not using unconstrained OLS.
|
+----------------------------------------------------------------------+
209
+---------------------------------------------+
| Instrumental Variables (NLGMM)
|
| GMM Estimator - Lags
= 0 Periods
|
| Value of the GMM criterion:
|
| e(b)tZ inv(ZtWZ) Zte(b)
=
7.971118
|
| Criterion is computed with 2 moments.
|
| Sample size is
21 observations.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1C
13.99930343
.76149035
18.384
.0000
B2C
.1423333720
.52555043E-01
2.708
.0068
C1C
.7337067766E-01 .52604141E-01
1.395
.1631
C2C
.8761416931
.23485747E-01
37.305
.0000
C1W
.4422673046
.14333438E-01
30.856
.0000
B1W
2.923427871
.46922831
6.230
.0000
B2W
.1215364067
.17476163E-01
6.954
.0000
B3W
.1147426472
.17274603E-01
6.642
.0000
+----------------------------------------------------------------------+
| __ Equation
Mean of LHS
S.D. of LHS
R-squared
Sum of squares |
| 1 C
53.995238
6.860866
.975305 .2324854015D+02 |
| 2 WP
36.361905
6.304401
.985064 .1187286539D+02 |
| Note, R-squared can be negative if not using unconstrained OLS.
|
+----------------------------------------------------------------------+
+---------------------------------------------+
| Instrumental Variables (NLGMM)
|
| GMM Estimator - Lags
= 0 Periods
|
| Value of the GMM criterion:
|
| e(b)tZ inv(ZtWZ) Zte(b)
=
8.013053
|
| Criterion is computed with 2 moments.
|
| Sample size is
21 observations.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1C
13.51841390
.67388799
20.060
.0000
B2C
.1318749567
.46910978E-01
2.811
.0049
C1C
.7646941379E-01 .42668300E-01
1.792
.0731
C2C
.8904279576
.20572940E-01
43.282
.0000
C1W
.4374349195
.15241824E-01
28.700
.0000
B1W
3.063836038
.36507811
8.392
.0000
B2W
.1242708219
.16776962E-01
7.407
.0000
B3W
.1057929779
.18491324E-01
5.721
.0000
+----------------------------------------------------------------------+
| __ Equation
Mean of LHS
S.D. of LHS
R-squared
Sum of squares |
| 1 C
53.995238
6.860866
.973504 .2494418734D+02 |
| 2 WP
36.361905
6.304401
.984094 .1264344970D+02 |
| Note, R-squared can be negative if not using unconstrained OLS.
|
+----------------------------------------------------------------------+
*/
210
/*=================================================================
Example 16.18. Testing Overidentifying Restrictions
*/=================================================================
? Critical Values from the chi-squared tables
?
Calc
; List ; Ctb(.95,2) ; Ctb(.95,3) ; Ctb(.95,8)
; Ctb(.99,2) ; Ctb(.99,3) ; Ctb(.99,8) $
Result = .59914645483899940D+01 Result = .78147277654400000D+01
Result = .15507313057789990D+02
Result = .92103403732599900D+01 Result = .11344866676609990D+02
Result = .20090235031410010D+02
?
? Consumption Function
?
Namelist ; ZC = P,W,One,Plag ; Xc = One,Plag
; allX= One,G,T,A,Wg,Plag,Klag,Xlag
; Yc = C,P,W
; Yic = P,W $
Matrix
; w0=rcpm(xc,yc) ; w1=rcpm(allx,yc) ; w1iw0=<w1>*w0$
Matrix
; roots=cxrt(w1iw0) $
Calc
; List ; lc=roots(3,1)
; LRC = n*(lc-1) $ LC = lambda_1
Matrix
; w0c=part(w0,2,3,2,3)- lc*part(w1,2,3,2,3)
; dc =part(w0,2,3,1,1)- lc*part(w1,2,3,1,1)$
Matrix
; gammac=<w0c>*dc$
Matrix
; betac=<Xc'Xc>*Xc'c - <Xc'Xc>*Xc'Yic*Gammac $
Matrix
; deltac=[gammac/betac] $
Create
; ec=c-zc'deltac $
Calc
; List ; TRsqML = n * Rsq(allX,ec) $
2sls
; Lhs = c ; Rhs = Zc ; Inst = allX $
Calc
; List ; TRsq2S = n * Rsq(allX,ec) $
/*
LC
= .14987455068361610D+01
LRC
= .10473655643559380D+02
TRSQML = .69882815854773230D+01
TRSQ2S = .87715071877722210D+01
*/
? Investment Equation
?
Namelist ; Zi = P,One,Plag,Klag ; Xi = One,Plag,Klag
; allX= One,G,T,A,Wg,Plag,Klag,Xlag
; Yi = I,P
; Yii = P $
Matrix
; w0=rcpm(xi,yi) ; w1=rcpm(allx,yi) ; w1iw0=<w1>*w0$
Matrix
; roots=cxrt(w1iw0) $
Calc
; List ; li=roots(2,1)
; LRI = n*(li-1) $ LC = lambda_1
Matrix
; w0i=part(w0,2,2,2,2)- li*part(w1,2,2,2,2)
; di =part(w0,2,2,1,1)- li*part(w1,2,2,1,1)$
Matrix
; gammai=<w0i>*di$
Matrix
; betai=<Xi'Xi>*Xi'i - <Xi'Xi>*Xi'Yii*Gammai $
Matrix
; deltai=[gammai/betai] $
Create
; ei=i-zi'deltai $
Calc
; List ; TRsqML = n * Rsq(allX,ei) $
2sls
; Lhs = i ; Rhs = Zi ; Inst = allX ; res=ei $
Calc
; List ; TRsq2S = n * Rsq(allX,ei) $
/*
LI
= .10859528454002810D+01
LRI
= .18050097534059040D+01
TRSQML = .16621437671853260D+01
TRSQ2S = .18149654746484310D+01
*/
Namelist ; Zw = X,One,Xlag,A
; Xw = One,Xlag,A
211
Matrix
Matrix
Calc
Matrix
Matrix
Matrix
Matrix
Create
Calc
2sls
Calc
/*
LW
LRW
TRSQML
TRSQ2S
*/
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
allX= One,G,T,A,Wg,Plag,Klag,Xlag
Yw = Wp,X
Yww =
X $
w0=rcpm(xw,yw) ; w1=rcpm(allx,yw) ; w1iw0=<w1>*w0$
roots=cxrt(w1iw0) $
List ; lw=roots(2,1)
; LRW = n*(lw-1) $ Lw = lambda_i
w0w=part(w0,2,2,2,2)- lw*part(w1,2,2,2,2)
dw =part(w0,2,2,1,1)- lw*part(w1,2,2,1,1)$
gammaw=<w0w>*dw$
betaw=<Xw'Xw>*Xw'Wp - <Xw'Xw>*Xw'Yww*Gammaw $
deltaw=[gammaw/betaw] $
ew=w-zw'deltaw $
List ; TRsqML = n * Rsq(allX,ew) $
Lhs = wp ; Rhs = Zi ; Inst = allX ; res=ew $
List ; TRsq2S = n * Rsq(allX,ew) $
=
=
=
=
.24685825448762760D+01
.30840233442401800D+02
.19967143547399120D+02
.12495220104086450D+02
/*=================================================================
Example 16.19. Exogeneity Text
*/=================================================================
Namelist ; Zc = P,One,Plag,W ; allX= One,G,T,A,Wg,Plag,Klag,Xlag $
2sls
; Lhs = wp ; Rhs = Zw ; Inst = allX $
Matrix
; b2sls = b ; v2sls = varb $
2sls
; Lhs = wp ; Rhs = Zw ; Inst = One,G,T,A,Wg,Plag,Klag $
Matrix
; biv
= b ; viv
= varb $
Matrix
; d = b2sls - biv ; vd = viv - v2sls ; list ; d<vd>d $
/*
+-----------------------------------------------------------------------+
| Two stage
least squares regression
Weighting variable = none
+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
X
.4388590651
.35631917E-01
12.316
.0000 60.057143
Constant 1.500296886
1.1477802
1.307
.1912
XLAG
.1466738215
.38836133E-01
3.777
.0002 57.985714
A
.1303956872
.29140980E-01
4.475
.0000 .00000000
+-----------------------------------------------------------------------+
| Two stage
least squares regression
Weighting variable = none
+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
X
.4227689087
.38241699E-01
11.055
.0000 60.057143
Constant 1.252388099
1.1761293
1.065
.2869
XLAG
.1676141104
.42685758E-01
3.927
.0001 57.985714
A
.1306215540
.29428573E-01
4.439
.0000 .00000000
Matrix Result
has 1 rows and 1 columns.
1
+-------------1| .1397709D+01
*/
212
/*=================================================================
Example 16.20. Dynamic Model
*/=================================================================
Namelist ; Zc = P,One,Plag,W
; Zi = P,One,Plag,Klag
; Zw = X,One,Xlag,A
; allX= One,G,T,A,Wg,Plag,Klag,Xlag $
?
? Two stage least squares
?
2sls
; Lhs = C ; Rhs = Zc ; Inst = allX $
Matrix
; deltac = -b $
2sls
; Lhs = I ; Rhs = Zi ; Inst = allX $
Matrix
; deltai = -b $
2sls
; Lhs = Wp; Rhs = Zw ; Inst = allX $
Matrix
; deltaw = -b $
?
Matrix
; List
; Gamma=[ 1,0,0,-1,0,0 /
0,1,0,-1,0,-1 /
deltac(4) ,0,1,0,1,0 /
0,0,deltaw(1) ,1,-1,0 /
deltac(1) ,deltai(1) ,0,0,1,0 /
0,0,0,0,0,1 ]
; Beta =[deltac(2),deltai(2),deltaw(2),0,0,0 /
deltac(4),0,0,0,0,0 /
0,0,0,0,1,0 /
0,0,0,-1,0,0 /
0,0,deltaw(4),0,0,0 ]
; Phi = [0,0,0,0,0,0 /
0,0,0,0,0,0 /
0,0,0,0,0,0 /
0,0,deltaw(3),0,0,0 /
deltac(3),deltai(3),0,0,0,0 /
0,deltai(4),0,0,0,-1]
; Pie = -Beta * <Gamma>
; Delta = -Phi * <Gamma> $
Matrix
; Impact = Pie
; ID = Iden(6)-Delta
; Final = Pie * <ID>
; List ; Impact ; Final $
213
Gamma
C
I
Wp
X
P
K
C
1
0
-0.810183
0
-0.0173022
0
I
0
1
0
0
-0.150222
0
X
-1
-1
0
1
0
0
P
0
0
1
-1
1
0
K
0
-1
0
0
0
1
Beta
1
Wg
T
G
A
-16.5548
-0.810183
0
0
0
-20.2782
-1.5003
0
0
0
0
0
0
0
-0.130396
0
0
0
-1
0
0
0
1
0
0
0
0
0
0
0
Phi
Clag
Ilag
Wplag
Xlag
Plag
Klag
0
0
0
0
0
0
0
0
-0.216234
-0.615944
0
0.157788
0
0
0
-0.146674
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
25.8412
0.124073
-0.175877
0.153142
-0.00675496
31.6355
0.645949
-0.133565
0.797289
0.197208
68.6672
1.47188
-0.304346
1.81673
0.152242
37.0317
25.8412
0.825934 0.124073
-1.17078 -0.175877
1.01944
0.153142
-0.0449665 .
0
0
0
0.178845
0.768457
-0.104706
0
0
0
-0.00759822
0.743385
-0.181952
0
0
0
0.221827
0.663486
-0.125802
0
0
0
0.171247
1.51184
-0.286658
0
0
0
0
0
0
-0.05058 -0.00759822
0.848357 0.743385
-0.160855 0.818048
Impact
1
42.826
Wg
1.34781
T
-0.128469
G
0.663588
A
0.158997
-0.00675496
25.8412
0.124073
-0.175877
0.153142
-0.00675496
31.6355
0.645949
-0.133565
0.797289
0.197208
68.6672
1.47188
-0.304346
1.81673
0.152242
37.0317
0.825934
-1.17078
1.01944
-0.0449665
25.8412
0.124073
-0.175877
0.153142
Final
1
Wg
T
G
A
*/
-3.55271e-015 25.2864
-9.71445e-017 1.10627
1.66533e-016 -0.318884
-1.11022e-016 1.36546
7.80626e-018 0.233067
40.623
1.88934
-0.544604
2.33199
0.175347
15.3366
0.783068
-1.22572
0.966533
-0.0577199
202.985
3.80233
-5.9517
4.69317
-0.280269
Pie
1
42.826
Wg
1.34781
T
-0.128469
G
0.663588
A
0.158997
00675496
Delta
Clag
Ilag
Wplag
Xlag
Plag
Klag
40.623
1.88934
-0.544604
1.33199
0.175347
Wp
0
0
1
-0.438859
0
0
214
/*=================================================================
Example 16.21. Dynamic Multipliers
This example uses the results of the previous example.
*/=================================================================
Matrix
; TGMults = Init(21,2,0)
; Mults
= Init(5,6,0)
; Power
= Iden(6) $
Proc
Matrix
; Mults = Pie * Power
; Power = Power * Delta
; policy = Part(Mults,3,4,4,4) ; policy = policy'
; TGMults(pd,*) = Policy $
EndProc
Exec
; pd=1,21 $
Matrix
; Lag = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
; Taxes = Part(TGMults,1,21,1,1)
; Spending = Part(TGMults,1,21,2,2) $
?
? Note, multipliers for T and G are in rows 3 and 4.
? X equation is 4th column.
?
Mplot
; Lhs = Lag ; Rhs = Taxes,Spending
; Yaxis=ImplsRsp
; Title=Policy Multipliers
; Fill ; Limits=-2,2 ; Endpoints=0,20 ; Bars = 0 $
/*
POLICY MULTIPLIERS
2.0
TAXES
SPENDING
IMPLSRSP
1.2
.4
-.4
-1.2
-2.0
12
16
20
LAG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-0.304346
-1.77174
-1.44891
-0.648659
0.131132
0.693882
0.983324
1.02081
0.869783
0.609822
0.317264
0.0525235
-0.146023
-0.262493
-0.299883
-0.274167
-0.207813
1.81673
1.80845
1.19185
0.454813
-0.177949
-0.607156
-0.810247
-0.81446
-0.675201
-0.457538
-0.221828
-0.0144296
0.136441
0.220487
0.242033
0.215105
0.158215
215
18
19
20
21
*/
-0.123998
-0.0423556
0.023451
0.0664187
0.0898461
0.0252261
-0.025408
-0.057181
/*=================================================================
Example 16.22. Model Stability
*/=================================================================
Matrix ; Delta1 = Part(Delta,4,6,4,6) ; List ; Cxrt(Delta1) $
/*
+---------------------------1| .7701737D+00 -.3494454D+00
2| .7701737D+00 .3494454D+00
3| .2973049D+00 .0000000D+00
*/
216
/*=================================================================
Example 16.23. Adjustment of Kleins Model I
*/=================================================================
Matrix ; Sim = Init(32,6,0) $
Matrix ; y0=[69.7,4.9,53.3,88.4,23.5,209.4] $
Matrix ; ye=[70.5, 0,52.2,84.3,20.5,227.7] $
Matrix ; dy = y0-ye $
Matrix ; id = iden(6)$
Proc
Matrix ; dev=dy*id ; id=id*delta ; Sim(pd,*)=dev $
EndProc
Exec
; pd=1,60$
Matrix ; Date =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]
;date=date+1940 $
Matrix ; DevC=Part(Sim,1,32,1,1)
; DevK=Part(sim,1,32,6,6)$
Mplot ; Lhs=date
; Rhs=Devc,Devk
; Fill ; bars=0$
.8
Variable (x10^01)
DEVC
DEVK
.3
-.3
-.8
-1.4
-1.9
1940 1945
1950
1955
DATE
217
129.7
131.3
137.1
141.6
148.8
155.9
164.9
171.0
183.4
195.8
207.4
218.3
226.8
237.9
225.8
232.4
241.7
249.2
261.3
248.9
226.8
225.6
228.8
239.6
244.7
245.8
269.4
276.8
279.9
284.1
282.0
271.8
280.2
286.7
290.2
297.8
Create ;
;
;
;
;
;
;
Create ;
;
;
.925
.914
.919
.918
.914
.949
.970
1.000
1.014
1.047
1.056
1.063
1.076
1.181
1.599
1.708
1.779
1.882
1.963
2.656
3.691
4.109
3.894
3.764
3.707
3.738
2.921
3.038
3.065
3.353
3.834
3.766
3.751
3.713
3.732
3.789
6036
6113
6271
6378
6727
7027
7280
7513
7728
7891
8134
8322
8562
9042
8867
8944
9175
9381
9735
9829
9722
9769
9725
9930
10421
10563
10780
10859
11186
11300
11389
11272
11466
11476
11636
11934
1.045
1.045
1.041
1.035
1.032
1.009
.991
1.000
1.028
1.044
1.076
1.120
1.110
1.111
1.175
1.276
1.357
1.429
1.538
1.660
1.793
1.902
1.976
2.026
2.085
2.152
2.240
2.321
2.368
2.414
2.451
2.538
2.528
2.663
2.754
2.815
.836
.869
.948
.960
1.001
.994
.970
1.000
1.028
1.031
1.043
1.102
1.105
1.176
1.226
1.464
1.679
1.828
1.865
2.010
2.081
2.569
2.964
3.297
3.757
3.797
3.632
3.776
3.939
4.019
3.926
3.942
4.113
4.470
4.730
5.224
.810
.846
.874
.885
.901
.919
.952
1.000
1.046
1.127
1.285
1.377
1.434
1.448
1.480
1.586
1.742
1.824
1.878
2.003
2.516
3.120
3.460
3.626
3.852
4.028
4.264
4.413
4.494
4.719
5.197
5.427
5.518
6.086
6.268
6.410
.444
.448
.457
.463
.470
.471
.475
.483
.501
.514
.527
.547
.555
.566
.604
.659
.695
.727
.769
.821
.892
.957
1.000
1.041
1.038
1.045
1.053
1.085
1.105
1.129
1.144
1.167
1.184
1.200
1.225
1.239
.331
.335
.338
.343
.347
.353
.366
.375
.390
.409
.427
.442
.458
.497
.572
.615
.638
.671
.719
.800
.894
.969
1.000
1.021
1.050
1.075
1.069
1.111
1.152
1.213
1.285
1.332
1.358
1.379
1.396
1.419
.302
.307
.314
.320
.325
.332
.342
.353
.368
.386
.407
.431
.451
.474
.513
.556
.598
.648
.698
.756
.839
.926
1.000
1.062
1.117
1.173
1.224
1.271
1.336
1.408
1.482
1.557
1.625
1.684
1.734
1.786
180.7
183.7
186.5
189.2
191.9
194.3
196.6
198.7
200.7
202.7
205.1
207.7
209.9
211.9
213.9
216.0
218.0
220.2
222.6
225.1
227.7
230.0
232.2
234.3
236.3
238.5
240.7
242.8
245.0
247.3
249.9
252.6
255.4
258.1
260.7
263.2
lg = Log(100*G/Pop)
ly = Log(Y)
lpg= Log(Pg)
lpnc = Log(Pnc)
lpuc = log(Puc)
lppt = log(Ppt)
t=trn(1,1) $
lg1=lg[-1]
ly1=ly[-1] ; ly2=ly[-2] ; ly3=ly[-3] ; ly4=ly[-4] ; ly5=ly[-5]
lp1=lpg[-1] ; lp2=lpg[-2] ; lp3=lpg[-3] ; lp4=lpg[-4] ; lp5=lpg[-5] $
218
?
? Models are fit to 31 observations, using 5 lagged values
?
Sample ; 6 - 36 $
?
? Unrestricted Least Squares
?
Regress ; Lhs = lg ; Rhs = one,lpnc,lpuc,lppt,t,
lpg,lp1,lp2,lp3,lp4,lp5,ly$
Calc
; List ; eeols = sumsqdev
; dfols = degfrdm $
?
? 2nd order polynomial, without then with AR1 correction
?
Sample ; 1 - 36 $
Create ; lpg=pdl(5,2) $
Sample ; 6 - 36 $
Regress ; Lhs= lg ; Rhs = one,lpnc,lpuc,lppt,t,lpgpdl,ly$
Calc
; List ; eepdl2=sumsqdev
; dfpdl2=degfrdm$
Regress ; Lhs= lg ; Rhs = one,lpnc,lpuc,lppt,t,lpgpdl,ly;AR1$
?
? 3rd order polynomial
?
Sample ; 1 - 36 $
Create ; lpg=pdl(5,3) $
Sample ; 6 - 36 $
Regress ; Lhs= lg ; Rhs = one,lpnc,lpuc,lppt,t,lpgpdl,ly$
Calc
; List ; eepdl3=sumsqdev
; dfpdl3=degfrdm$
?
? F tests, second vs. third order polynomial, then 3rd order
? as a restriction on 2nd order.
?
Calc
; List ; F23 = ((eepdl2-eepdl3)/1)/(eepdl3/dfpdl3)
; Ftb(.95,1,dfpdl3) $
Calc
; List ; Fpdl = ((eepdl3-eeols)/2)/(eeols/dfols)
; Ftb(.95,2,dfols) $
219
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.649873861
, S.D.=
.9622470146E-01 |
| Model size: Observations =
31, Parameters = 12, Deg.Fr.=
19 |
| Residuals: Sum of squares= .8303207771E-02, Std.Dev.=
.02090 |
| Fit:
R-squared= .970108, Adjusted R-squared =
.95280 |
| Model test: F[ 11,
19] =
56.06,
Prob value =
.00000 |
| Diagnostic: Log-L =
83.5020, Restricted(b=0) Log-L =
29.0943 |
|
LogAmemiyaPrCrt.=
-7.408, Akaike Info. Crt.=
-4.613 |
| Autocorrel: Durbin-Watson Statistic =
1.74444,
Rho =
.12778 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -17.08775284
1.5611540
-10.946
.0000
LPNC
.2198037154
.17335206
1.268
.2201 .50841999
LPUC
-.9241180560E-03 .99053319E-01
-.009
.9927 .78396138
LPPT
.2640625178E-01 .93288799E-01
.283
.7802 .92045241
T
-.2770071860E-01 .90740536E-02
-3.053
.0065 21.000000
LPG
-.1737208060
.48044800E-01
-3.616
.0018 .79662045
LP1
-.3687630289E-01 .76569919E-01
-.482
.6356 .75074862
LP2
.8680206340E-01 .74127029E-01
1.171
.2561 .70550661
LP3
-.3733949993E-02 .70820378E-01
-.053
.9585 .66046438
LP4
-.8936895355E-01 .69289926E-01
-1.290
.2126 .61491769
LP5
-.6328003655E-01 .50299863E-01
-1.258
.2236 .56962818
LY
2.440977433
.18013091
13.551
.0000 9.1694046
EEOLS
= .83032077708087690D-02
DFOLS
= .19000000000000000D+02
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.649873861
, S.D.=
.9622470146E-01 |
| Model size: Observations =
31, Parameters =
9, Deg.Fr.=
22 |
| Residuals: Sum of squares= .9631976462E-02, Std.Dev.=
.02092 |
| Fit:
R-squared= .965325, Adjusted R-squared =
.95272 |
| Model test: F[ 8,
22] =
76.56,
Prob value =
.00000 |
| Diagnostic: Log-L =
81.2010, Restricted(b=0) Log-L =
29.0943 |
|
LogAmemiyaPrCrt.=
-7.479, Akaike Info. Crt.=
-4.658 |
| Autocorrel: Durbin-Watson Statistic =
1.74520,
Rho =
.12740 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -16.91150020
1.5575025
-10.858
.0000
LPNC
.2262608275
.17344777
1.304
.2055 .50841999
LPUC
.3549823408E-01 .95933337E-01
.370
.7149 .78396138
LPPT
.9240455060E-01 .80601607E-01
1.146
.2639 .92045241
T
-.3138697432E-01 .86656653E-02
-3.622
.0015 21.000000
LPG000
-.1543160936
.29511864E-01
-5.229
.0000 4.0978859
LPG001
.1323144319
.30976075E-01
4.272
.0003 9.4509666
LPG002
-.2535430454E-01 .60348694E-02
-4.201
.0004 33.596342
LY
2.423959361
.17986157
13.477
.0000 9.1694046
EEPDL2
DFPDL2
=
=
.96319764618999180D-02
.22000000000000000D+02
220
221
=
=
.85588726828253890D-02
.21000000000000000D+02
222
2072.0
2077.0
2078.0
2043.0
2062.0
2067.0
1964.0
1981.0
1914.0
1991.0
2129.0
2309.0
2614.0
2896.0
3058.0
3309.0
3446.0
3466.0
3435.0
3183.0
2697.0
2338.0
2140.0
2012.0
2071.0
2192.0
2240.0
2421.0
2639.0
2733.0
2721.0
2640.0
2513.0
2448.0
2429.0
2516.0
2534.0
2494.0
2596.0
2572.0
2601.0
2648.0
2840.0
2937.0
3136.0
3299.0
3514.0
3815.0
4093.0
4262.0
4531.0
4825.0
5160.0
5319.0
5574.0
5749.0
5715.0
5637.0
5383.0
5467.0
1660.0
1926.0
2181.0
1897.0
1695.0
1705.0
1731.0
2151.0
2556.0
3152.0
3763.0
3903.0
3912.0
3571.0
3199.0
3262.0
3476.0
2993.0
2262.0
2011.0
1511.0
1631.0
1990.0
1993.0
2520.0
2804.0
2919.0
3024.0
2725.0
2321.0
2131.0
2552.0
2234.0
2282.0
2533.0
2517.0
2772.0
2380.0
2568.0
2944.0
2629.0
3133.0
3449.0
3764.0
3983.0
4381.0
4786.0
4094.0
4870.0
5344.0
5433.0
5911.0
6109.0
6542.0
5785.0
5707.0
5412.0
5465.0
5550.0
5465.0
?
? Data Setup. Create lagged variables
?
Create ; q1=dmy(4,1) ; q2=dmy(4,2)
; q3=dmy(4,3) ; q4=dmy(4,4) $
Create ; x1=x[-1] ; x2=x[-2] ; x3=x[-3] ; x4=x[-4]
; x5=x[-5] ; x6=x[-6] ; x7=x[-7] ; x0=x $
223
?
? Data set includes some extra observations. Results use only Almons
? Original data set, 1953 to 1961.
?
Sample ; 8-36 $
?----------------------------------------------------------------------? Unrestricted, by OLS, quarterly dummies sum to 0.
? Wald command displays 4 th quarter dummy coefficient
?----------------------------------------------------------------------Regress; Lhs = Y ; Rhs = q1,q2,q3,q4,x0,x1,x2,x3,x4,x5,x6,x7
; cls: b(1)+b(2)+b(3)+b(4) = 0 ; Res = u $
Calc
; List ; EE0=Sumsqdev ; DF0=Degfrdm $
Create ; du = u-u[-1] $
Create ; If(_Obsno = 1)du=0 $
Calc
; List ; DW = du'du/u'u $
Wald
; Fn1 = b0+b1+b2+b3+b4+b5+b6+b7
; Start = b ; var=Varb ; Labels=c1,c2,c3,c4,b0,b1,b2,b3,b4,b5,b6,b7 $
?----------------------------------------------------------------------? Unrestricted, by MLE for AR(1) model, quarterly dummies sum to 0.
?----------------------------------------------------------------------Create ; dq1=q1-q4;dq2=q2-q4;dq3=q3-q4 $
Regress; Lhs = Y
; Rhs = dq1,dq2,dq3,x0,x1,x2,x3,x4,x5,x6,x7
; AR1 ; Alg=MLE $
Wald
; Fn1 = b0+b1+b2+b3+b4+b5+b6+b7
; Fn2 = -c1-c2-c3
; Start = b ; var=Varb ; Labels=c1,c2,c3,b0,b1,b2,b3,b4,b5,b6,b7 $
?----------------------------------------------------------------------? 7 lags, 4th order PDL, OLS dummies sum to zero. Wald shows 4th
? quarterly dummy, F test tests restrictions of the PDL
? Also displays number of restrictions and critical value for test
?----------------------------------------------------------------------Sample ; 1 - 36 $
Create ; X=PDL(7,4) $
Sample ; 8-36 $
Regress; Lhs=Y ; Rhs = dq1,dq2,dq3,xpdl ; Res=updl $
Wald
; Fn1 = -c1-c2-c3
; Start = b ; var=Varb ; Labels=c1,c2,c3,b0,b1,b2,b3,b4$
Calc
; List ; EEPDL=Sumsqdev ; DFPDL=Degfrdm
; Ftest = ((eepdl-ee0)/(dfpdl-df0))/(ee0/df0) $
Calc
; List ; rstpdl=dfpdl-df0
; ftb(.95,rstpdl,df0)$
/*
224
?----------------------------------------------------------------------? PDL, MLE, dummies sum to zero. Repeats previous, using MLE for AR(1)
?----------------------------------------------------------------------Regress; Lhs=Y ; Rhs = dq1,dq2,dq3,xpdl ;AR1;ALG=MLE $
Wald
; Fn1 = -c1-c2-c3
; Start = b ; var=Varb ; Labels=c1,c2,c3,b0,b1,b2,b3,b4$
?----------------------------------------------------------------------? PDL OLS with endpoint constraints. Adds two restrictions to previous.
? Computes Durbin Watson statistic on the side.
? F test is for endpoint restrictions+PDL, vs. unrestricted
?----------------------------------------------------------------------Regress; Lhs=Y ; Rhs = dq1,dq2,dq3,xpdl ;
; cls:b(4)- b(5)+ b(6)b(7)+
b(8)=0,
b(4)+8b(5)+64b(6)+512b(7)+4096b(8)=0 ; res=ue $
Create ; due = ue-ue[-1] $
Create ; If(_Obsno = 1)due=0 $
Calc
; List ; DW = due'due/ue'ue
; eeend=sumsqdev ; dfend= degfrdm $
; Ftest = ((eeend-ee0)/(dfend-df0))/(ee0/df0) $
; rstend=dfend-df0
; ftb(.95,rstend,df0)$
?----------------------------------------------------------------------? ML, force dummies to sum to 0 and endpoint constraints. Same as
? previous model. Not actually the full maximum, as it takes the
? unrestricted MLE and does the constrained LS manipulation. Not quite
? the same answer that would be obtained by maximizing the log
? likelihood subject to the constraints.
?----------------------------------------------------------------------Regress ; Lhs=y ; Rhs=dq1,dq2,dq3,xpdl
; Cls:b(4)- b(5)+ b(6)b(7)+
b(8)=0,
b(4)+8b(5)+64b(6)+512b(7)+4096b(8)=0
; Alg=mle;ar1$
Wald
; Fn1 = -c1-c2-c3
; Start = b ; var=Varb ; Labels=c1,c2,c3,b0,b1,b2,b3,b4$
225
=
=
=
.40639566470201790D+00
.49852283195910020D+06
.18000000000000000D+02
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
|for nonlinear functions
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .9816934704
.11812112E-01
83.109
.0000
226
227
?----------------------------------------------------------------------? 7 lags, 4th order PDL, OLS dummies sum to zero. Wald shows 4th
? quarterly dummy, F test tests restrictions of the PDL
? Also displays number of restrictions and critical value for test
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = Y
Mean=
2568.310345
, S.D.=
468.6928711
|
| Model size: Observations =
29, Parameters =
8, Deg.Fr.=
21 |
| Residuals: Sum of squares= 506077.3496
, Std.Dev.=
155.23827 |
| Fit:
R-squared= .917722, Adjusted R-squared =
.89030 |
| Diagnostic: Log-L =
-182.7729, Restricted(b=0) Log-L =
-218.9889 |
| Autocorrel: Durbin-Watson Statistic =
.44507,
Rho =
.77747 |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
DQ1
-6.982987739
50.756514
-.138
.8919 -.34482759E-01
DQ2
-8.758911609
51.630040
-.170
.8669 -.34482759E-01
DQ3
-15.70362673
50.940622
-.308
.7609 -.34482759E-01
X000
.2653100214E-01 .84772538E-01
.313
.7574 20905.069
X001
.1656054044
.36738667
.451
.6568 72438.655
X002
-.5138057795E-01 .25260637
-.203
.8408 360974.38
X003
.3495534355E-02 .56925288E-01
.061
.9516 2017427.6
X004
.1251824118E-03 .40451237E-02
.031
.9756 12016510.
Polynomial Distributed Lag for X
Lag
Weights
Std. Err. t-ratio Prob. Distribution of Weights (about 0.0)
-----------------------------------------+----------------+----------------+
0 .2653E-01 .8477E-01
.31
.7574|
|**
|
1 .1444
.9287E-01
1.55
.1350|
|*************
|
2 .1822
.4856E-01
3.75
.0012|
|********
|
3 .1654
.5711E-01
2.90
.0086|
|*****
|
4 .1226
.5829E-01
2.10
.0476|
|***
|
5 .8522E-01 .4648E-01
1.83
.0809|
|**
|
6 .8773E-01 .9065E-01
.97
.3441|
|**
|
7 .1677
.8214E-01
2.04
.0540|
|***
|
Lag
Sum Wts
Std. Err. t-ratio Prob. Distribution of Sum Wts (about 0.0)
-----------------------------------------+----------------+----------------+
0 .2653E-01 .8477E-01
.31
.7574|
|*
|
1 .1709
.4924E-01
3.47
.0023|
|***
|
2 .3531
.6340E-01
5.57
.0000|
|******
|
3 .5185
.4131E-01
12.55
.0000|
|********
|
4 .6412
.6237E-01
10.28
.0000|
|**********
|
5 .7264
.4995E-01
14.54
.0000|
|************
|
6 .8141
.8127E-01
10.02
.0000|
|*************
|
7 .9818
.1100E-01
89.26
.0000|
|****************|
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) 31.44552608
50.203278
.626
.5311
FTEST
= .10449316411388680D+00
EEPDL= .50607734960866870D+06
DFPDL = .21000000000000000D+02
FTEST
= .90922828387383210D-01
RSTPDL = .30000000000000040D+01
Result = .31599075898100000D+01
228
?----------------------------------------------------------------------? PDL, MLE, dummies sum to zero. Repeats previous, using MLE for AR(1)
?----------------------------------------------------------------------+---------------------------------------------+
| AR(1) Model:
e(t) = rho * e(t-1) + u(t) |
| Initial value of rho
=
.77747 |
| Maximum iterations
=
20 |
| Iter= 3, SS= 195356.806, Log-L=-169.488160 |
| Final value of Rho
=
.80296 |
| Durbin-Watson:
e(t) =
.38316 |
| Std. Deviation: e(t) =
161.82063 |
| Std. Deviation: u(t) =
96.45053 |
| Durbin-Watson:
u(t) =
1.18194 |
| Autocorrelation: u(t) =
.40903 |
| N[0,1] used for significance levels
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
DQ1
-5.948621996
22.594018
-.263
.7923 -.34482759E-01
DQ2
-3.002142403
23.089429
-.130
.8965 -.34482759E-01
DQ3
-6.406661309
22.679601
-.282
.7776 -.34482759E-01
X000
.5876761171E-01 .57750452E-01
1.018
.3089 20905.069
X001
.8394877499E-01 .19870950
.422
.6727 72438.655
X002
-.8972580989E-02 .13356822
-.067
.9464 360974.38
X003
-.3720177038E-02 .30081841E-01
-.124
.9016 2017427.6
X004
.5007799951E-03 .21487163E-02
.233
.8157 12016510.
RHO
.8029595037
.11263976
7.129
.0000
Polynomial Distributed Lag for X
Lag
Weights
Std. Err. t-ratio Prob. Distribution of Weights (about 0.0)
-----------------------------------------+----------------+----------------+
0 .5877E-01 .5775E-01
1.02
.3089|
|******
|
1 .1305
.5073E-01
2.57
.0101|
|***********
|
2 .1690
.3207E-01
5.27
.0000|
|********
|
3 .1700
.3470E-01
4.90
.0000|
|*****
|
4 .1411
.3371E-01
4.19
.0000|
|***
|
5 .1022
.3218E-01
3.17
.0015|
|**
|
6 .8490E-01 .5087E-01
1.67
.0952|
|**
|
7 .1331
.6008E-01
2.22
.0267|
|**
|
+----------------+----------------+
Lag
Sum Wts
Std. Err. t-ratio Prob. Distribution of Sum Wts (about 0.0)
-----------------------------------------+----------------+----------------+
0 .5877E-01 .5775E-01
1.02
.3089|
|*
|
1 .1893
.5000E-01
3.79
.0002|
|***
|
2 .3583
.5247E-01
6.83
.0000|
|******
|
3 .5283
.4638E-01
11.39
.0000|
|*********
|
4 .6694
.5268E-01
12.71
.0000|
|***********
|
5 .7716
.5127E-01
15.05
.0000|
|************
|
6 .8565
.6339E-01
13.51
.0000|
|************** |
7 .9896
.3072E-01
32.21
.0000|
|****************|
+----------------+----------------+
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) 15.35742571
23.325011
.658
.5103
?----------------------------------------------------------------------? PDL OLS with endpoint constraints. Adds two restrictions to previous.
229
230
231
+-----------------------------------------------------------------------+
| Linearly restricted regression
|
| Generalized least squares regression
Weighting variable = none
|
| Dep. var. = Y
Mean=
2568.310345
, S.D.=
468.6928711
|
| Model size: Observations =
29, Parameters =
6, Deg.Fr.=
23 |
| Residuals: Sum of squares= 600399.1491
, Std.Dev.=
161.56829 |
| Fit:
R-squared= .902388, Adjusted R-squared =
.88117 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 5,
23] =
42.53,
Prob value =
.00000 |
| Diagnostic: Log-L =
-185.2510, Restricted(b=0) Log-L =
-218.9889 |
|
LogAmemiyaPrCrt.=
10.358, Akaike Info. Crt.=
13.190 |
| Note, when restrictions are imposed, R-squared can be less than zero. |
| F[ 2,
21] for the restrictions =
.6857, Prob =
.5146
|
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
DQ1
-7.957061800
22.513739
-.353
.7273 -.34482759E-01
DQ2
-3.353494482
22.455568
-.149
.8827 -.34482759E-01
DQ3
-4.152770819
22.500234
-.185
.8553 -.34482759E-01
X000
.9021824328E-01 .23341667E-01
3.865
.0009 20905.069
X001
.6242829710E-01 .73869286E-02
8.451
.0000 72438.655
X002
-.2364934860E-01 .15137359E-01
-1.562
.1332 360974.38
X003
.3881033284E-02 .41058500E-02
.945
.3553 2017427.6
X004
-.2595642947E-03 .29168922E-03
-.890
.3836 12016510.
Lag
Weights
Std. Err. t-ratio Prob. Distribution of Weights (about 0.0)
-----------------------------------------+----------------+----------------+
0 .9022E-01 .2334E-01
3.87
.0009|
|**********
|
1 .1326
.1858E-01
7.14
.0000|
|**********
|
2 .1474
.1464E-01
10.06
.0000|
|******
|
3 .1484
.2130E-01
6.97
.0000|
|*****
|
4 .1435
.2133E-01
6.73
.0000|
|***
|
5 .1340
.1479E-01
9.06
.0000|
|***
|
6 .1153
.1874E-01
6.16
.0000|
|**
|
7 .7638E-01 .2342E-01
3.26
.0037|
|*
|
+----------------+----------------+
Lag
Sum Wts
Std. Err. t-ratio Prob. Distribution of Sum Wts (about 0.0)
-----------------------------------------+----------------+----------------+
0 .9022E-01 .2334E-01
3.87
.0009|
|*
|
1 .2228
.4095E-01
5.44
.0000|
|****
|
2 .3702
.4584E-01
8.08
.0000|
|******
|
3 .5186
.4553E-01
11.39
.0000|
|********
|
4 .6621
.4703E-01
14.08
.0000|
|***********
|
5 .7961
.4459E-01
17.86
.0000|
|*************
|
6 .9115
.3420E-01
26.65
.0000|
|*************** |
7 .9878
.3065E-01
32.22
.0000|
|****************|
+----------------+----------------+
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
.47824
|
| Prob. from Chi-squared[ 1] =
.48922
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) 15.46332710
22.360467
.692
.4892
232
/*=================================================================
Example 17.3. Price and Income Elasticities of Demand for Gasoline
*/=================================================================
?
? Data setup is in Example 17.2.
?
?--------------------------------------------------------------------------? Unrestricted model
?--------------------------------------------------------------------------Sample ; 6 - 36 $
Regress ; Lhs = lg
; Rhs = One,lpnc,lpuc,lppt,t,
lpg,lp1,lp2,lp3,lp4,lp5,ly,ly1,ly2,ly3,ly4,ly5 $
Calc
; List ; N ; Sumsqdev $
Wald
; Fn1=b6+b7+b8+b9+b10+b11
; Fn2=b12+b13+b14+b15+b16+b17;
; Start=b ; Var=Varb ; Labels=17_b$
?--------------------------------------------------------------------------?NonlinearLeastSquaresEstimationforExpectationsModel.
?--------------------------------------------------------------------------Sample;136$
Namelist;Xdl=one,LPnc,LPuc,LPpt,t$
Matrix;EE=0.0[99,1];LL=EE$
Calc;J=0;Smallee=1000000$
Procedure
Create;If(_obsno=1)|ztp=lpg/(1lambda);zty=ly/(1lambda)
;dtp=ztp/(1lambda);dty=zty/(1lambda)$
Create;If(_obsno>1)|ztp=lpg+lambda*ztp[1]
;zty=ly+lambda*zty[1]
;dtp=ztp[1]+lambda*dtp[1]
;dty=zty[1]+lambda*dty[1]$
Calc;Sume2=Ess(XDL,ZtP,ZtY,LG);j=j+1
;If(Sume2<Smallee)|Smallee=sume2;Best=lambda$
Matrix;EE(j)=Sume2;LL(j)=Lambda$
Endproc
Execute;Lambda=.01,.99,.01$
Mplot;Lhs=LL;Rhs=EE;Fill;Grid;Endpoints=0,1$
Calc;j=1;List;N;Smallee$
Execute;Lambda=Best$
Namelist;X=Xdl,ztp,zty$
Matrix;Beta=<XX>*XLg$
Create;dt=Beta(6)*dtp+Beta(7)*dty$
Namelist;X0=X,dt$
Matrix;Beta=[Beta/Lambda];V=ssqrd*<X0X0>;Stat(Beta,V)$
Wald;Start=Beta;Var=V;Labels=b1,b2,b3,b4,b5,b6,b7,Lm
;Fn1=b6/(1Lm);Fn2=b7/(1Lm)$
?--------------------------------------------------------------------------? Partial Adjustment Model
?--------------------------------------------------------------------------Sample ; 2 - 36 $
Regress ; Lhs = Lg ; Rhs = One,lpnc,lpuc,lppt,t,lpg,ly,lg1 $
Calc
; List ; N ; Sumsqdev $
Wald
; Fn1 = b6/(1-b8) ; fn2=b7/(1-b8)
; Start = b ; Var = Varb ; Labels = 8_b $
/*
233
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.649873861
, S.D.=
.9622470146E-01 |
| Model size: Observations =
31, Parameters = 17, Deg.Fr.=
14 |
| Residuals: Sum of squares= .1649508460E-02, Std.Dev.=
.01085 |
| Fit:
R-squared= .994062, Adjusted R-squared =
.98728 |
| Model test: F[ 16,
14] = 146.47,
Prob value =
.00000 |
| Diagnostic: Log-L =
108.5525, Restricted(b=0) Log-L =
29.0943 |
|
LogAmemiyaPrCrt.=
-8.609, Akaike Info. Crt.=
-5.907 |
| Autocorrel: Durbin-Watson Statistic =
1.41757,
Rho =
.29121 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -18.16520769
.94287398
-19.266
.0000
LPNC
.1869545562
.93945297E-01
1.990
.0665 .50841999
LPUC
.8002558141E-01 .78781503E-01
1.016
.3270 .78396138
LPPT
-.7537782793E-01 .74139645E-01
-1.017
.3265 .92045241
T
-.3359358417E-01 .64073728E-02
-5.243
.0001 21.000000
LPG
-.2086637792
.30323252E-01
-6.881
.0000 .79662045
LP1
-.1325136220
.55849246E-01
-2.373
.0325 .75074862
LP2
.8196540286E-01 .48010410E-01
1.707
.1098 .70550661
LP3
.2578197557E-02 .49143648E-01
.052
.9589 .66046438
LP4
-.5847635591E-01 .45473147E-01
-1.286
.2193 .61491769
LP5
.4547743059E-01 .51710643E-01
.879
.3940 .56962818
LY
.7851237820
.25909796
3.030
.0090 9.1694046
LY1
-.1384356575E-01 .28699331
-.048
.9622 9.1509123
LY2
.6963302390
.25887627
2.690
.0176 9.1315171
LY3
.8757028834E-01 .29113384
.301
.7680 9.1120229
LY4
.2586348681
.24466791
1.057
.3084 9.0917336
LY5
.7791365084
.20573492
3.787
.0020 9.0715858
SampleN=.31000000000000000D+02
SUMSQDEV=.16495084603249600D02
++
|WALDprocedure.Estimatesandstandarderrors|
|fornonlinearfunctions|
++
+++++++
|Variable|Coefficient|StandardError|b/St.Er.|P[|Z|>z]|MeanofX|
+++++++
Fncn(1).2696327261.89234076E013.022.0025
Fncn(2)2.592952120.1089407323.801.0000
234
.050
.045
.040
.035
EE
.030
.025
.020
.015
.010
.005
.0
.2
.4
.6
.8
1.0
LL
235
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.610830309
, S.D.=
.1429479464
|
| Model size: Observations =
35, Parameters =
8, Deg.Fr.=
27 |
| Residuals: Sum of squares= .1250433996E-01, Std.Dev.=
.02152 |
| Fit:
R-squared= .982002, Adjusted R-squared =
.97734 |
| Model test: F[ 7,
27] = 210.45,
Prob value =
.00000 |
| Diagnostic: Log-L =
89.2351, Restricted(b=0) Log-L =
18.9290 |
|
LogAmemiyaPrCrt.=
-7.472, Akaike Info. Crt.=
-4.642 |
| Autocorrel: Durbin-Watson Statistic =
1.63910,
Rho =
.18045 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -5.133074868
1.9252433
-2.666
.0128
LPNC
-.1385850117
.13860763
-1.000
.3263 .45460339
LPUC
.1262311395
.73788044E-01
1.711
.0986 .68769049
LPPT
.5086530758E-01 .64897450E-01
.784
.4400 .80016275
T
-.1056855906E-01 .54108460E-02
-1.953
.0612 19.000000
LPG
-.1181728771
.25249203E-01
-4.680
.0001 .69558165
LY
.7717496814
.26878032
2.871
.0079 9.1225115
LG1
.6355402720
.12455748
5.102
.0000 4.5978268
Sample N= .35000000000000000D+02
SUMSQDEV= .12504339955516810D-01
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) -.3242412481
.13403797
-2.419
.0156
Fncn( 2) 2.117517032
.41434438
5.111
.0000
*/
236
/*=================================================================
Example 17.4. Lag Weights in a Rational Lag Model
*/=================================================================
Read ; Nobs = 128 ; Nvar = 3 ; Names = 1 $
Quarter
C
Y
1953.1
1953.2
1953.3
1953.4
1954.1
1954.2
1954.3
1954.4
1955.1
1955.2
1955.3
1955.4
1956.1
1956.2
1956.3
1956.4
1957.1
1957.2
1957.3
1957.4
1958.1
1958.2
1958.3
1958.4
1959.1
1959.2
1959.3
1959.4
1960.1
1960.2
1960.3
1960.4
1961.1
1961.2
1961.3
1961.4
1962.1
1962.2
1962.3
1962.4
1963.1
1963.2
1963.3
1963.4
1964.1
1964.2
1964.3
1964.4
1965.1
1965.2
1965.3
1965.4
1966.1
1966.2
1966.3
1966.4
1967.1
1967.2
1967.3
1967.4
1968.1
1968.2
1968.3
1968.4
1969.1
1969.2
1969.3
362.8
364.6
363.6
362.6
363.5
366.2
371.8
378.6
385.2
392.2
396.4
402.6
403.2
403.9
405.1
409.3
411.7
412.4
415.2
416.0
411.0
414.7
420.9
425.2
424.1
439.7
443.3
444.6
448.1
454.1
452.7
453.2
454.0
459.9
461.4
470.3
474.5
479.8
483.7
490.0
493.1
497.4
503.9
507.5
516.6
525.6
534.3
535.3
546.0
550.7
559.2
573.9
581.2
582.3
588.6
590.5
594.8
602.4
605.2
608.2
620.7
629.9
642.3
644.7
651.9
656.2
659.6
395.5
401.0
399.7
400.2
399.7
397.3
403.8
411.8
414.7
423.8
430.8
437.6
441.2
444.7
446.6
452.7
452.6
455.4
457.9
456.0
452.1
455.1
464.6
471.3
474.5
482.2
479.0
483.1
487.8
490.7
491.0
488.8
493.4
500.7
505.5
514.8
519.5
523.9
526.7
529.0
533.3
538.9
544.4
552.5
563.6
579.4
586.4
593.0
599.7
607.8
623.6
634.6
639.7
642.0
649.2
700.7
665.0
671.3
676.5
682.0
690.4
701.9
703.6
708.7
710.4
717.0
730.1
237
1969.4
1970.1
1970.2
1970.3
1970.4
1971.1
1971.2
1971.3
1971.4
1972.1
1972.2
1972.3
1972.4
1973.1
1973.2
1973.3
1973.4
1974.1
1974.2
1974.3
1974.4
1975.1
1975.2
1975.3
1975.4
1976.1
1976.2
1976.3
1976.4
1977.1
1977.2
1977.3
1977.4
1978.1
1978.2
1978.3
1978.4
1979.1
1979.2
1979.3
1979.4
1980.1
1980.2
1980.3
1980.4
1981.1
1981.2
1981.3
1981.4
1982.1
1982.2
1982.3
1982.4
1983.1
1983.2
1983.3
1983.4
1984.1
1984.2
1984.3
1984.4
663.9
667.4
670.5
676.5
673.9
687.0
693.3
698.2
708.6
718.6
731.1
741.3
757.1
768.8
766.3
769.7
766.7
761.2
764.1
769.4
756.5
763.3
775.6
785.4
793.3
809.9
817.1
826.5
838.9
851.7
858.0
867.3
880.4
883.8
901.1
908.6
919.2
921.2
919.5
930.9
938.6
938.3
919.6
929.4
940.0
950.2
949.1
955.7
946.8
953.7
958.9
964.2
976.3
982.5
1006.2
1015.6
1032.4
1044.1
1064.2
1065.9
1075.4
733.2
737.1
752.6
759.7
756.1
771.3
779.7
781.0
785.5
791.7
798.5
842.2
838.1
855.0
862.1
868.0
873.4
859.9
859.7
859.7
851.1
845.1
891.3
878.4
884.9
899.3
904.1
908.8
914.9
919.6
934.1
951.9
965.9
973.5
982.6
994.2
1005.0
1011.1
1011.8
1019.7
1020.2
1025.9
1011.8
1019.3
1030.2
1044.0
1041.0
1058.4
1056.0
1052.8
1054.7
1057.7
1067.5
1073.3
1082.2
1102.1
1124.4
1147.8
1165.3
1176.7
1186.9
238
Calc
Calc
;
;
;
;
;
;
;
;
;
;
;
;
;
g1=b(1);g2=b(2);g3=b(3);b0=b(4);b1=b(5);b2=b(6);b3=b(7) $
List
a0 = b0
a1 = b1 + a0*g1
a2 = b2 + a0*g2+a1*g1
a3 = b3 + a0*g3+a1*g2+a2*g1
a4 =
a1*g3+a2*g2+a3*g1
a5 =
a2*g3+a3*g2+a4*g1
a6 =
a3*g3+a4*g2+a5*g1
a7 =
a4*g3+a5*g2+a6*g1
a8 =
a5*g3+a6*g2+a7*g1
a9 =
a6*g3+a7*g2+a8*g1
a10=
a7*g3+a8*g2+a9*g1 $
?
? Long Run Effect
?
Wald
; fn1= (bb0+bb1+bb2+bb3)/(1-gg1-gg2-gg3)
; Start=b ; Var=Varb
; labels=gg1,gg2,gg3,bb0,bb1,bb2,bb3,bq1,bq2,bq3,bq4$
?
? Unrestricted Lag Model with 10 Lagged Values
?
Sample ; 1 - 128$
Create ; ly4=ly[-4];ly5=ly[-5];ly6=ly[-6]
; ly7=ly[-7];ly8=ly[-8];ly9=ly[-9];ly10=ly[-10]$
Sample ; 11 - 128$
Regress; Lhs = lc ; Rhs = ly,ly1,ly2,ly3,ly4,ly5,ly6,ly7,ly8,ly9,ly10,
q1,q2,q3,q4 $
?
? Long Run Effect = Sum of coefficients
?
Wald ; fn1=v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11
; start=b;var=varb;labels=11_v,4_dq$
?
? Plot two sets of coefficients
?
Matrix ; Ardl=[a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
; Unres=b(1:11)
; Lag=[0,1,2,3,4,5,6,7,8,9,10]$
Mplot ; Lhs=Lag
; Rhs=ARDL,Unres
; Grid ; Fill ; Limits=-.2,1 ; EndPoints=0,10
; Yaxis=LagWt ;Title=Lag Coefficients $
239
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LC
Mean=
6.451850235
, S.D.=
.3238111975
|
| Model size: Observations =
125, Parameters = 11, Deg.Fr.=
114 |
| Residuals: Sum of squares= .6226132522E-02, Std.Dev.=
.00739 |
| Fit:
R-squared= .999521, Adjusted R-squared =
.99948 |
| Model test: F[ 10,
114] =23794.90,
Prob value =
.00000 |
| Diagnostic: Log-L =
441.8398, Restricted(b=0) Log-L =
-35.9160 |
|
LogAmemiyaPrCrt.=
-9.731, Akaike Info. Crt.=
-6.893 |
| Autocorrel: Durbin-Watson Statistic =
2.01407,
Rho =
-.00704 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LC1
.8706164426
.99055652E-01
8.789
.0000 6.4431751
LC2
.1180990706
.12992494
.909
.3653 6.4345929
LC3
-.8196778907E-01 .97162656E-01
-.844
.4007 6.4259839
LY
.3153826638
.58936010E-01
5.351
.0000 6.5487101
LY1
-.8363017659E-01 .72458917E-01
-1.154
.2508 6.5400030
LY2
-.7655210459E-01 .71692616E-01
-1.068
.2879 6.5313909
LY3
-.6359220813E-01 .63878287E-01
-.996
.3216 6.5227463
Q1
.5888645232E-02 .13556439E-01
.434
.6648 .24800000
Q2
.6364672141E-02 .13580857E-01
.469
.6402 .24800000
Q3
.5623633510E-02 .13607036E-01
.413
.6802 .24800000
Q4
.4165480627E-02 .13588045E-01
.307
.7597 .25600000
A0
= .31538266381914500D+00
A1
= .19094715625389090D+00
A2
= .12693602880702680D+00
A3
= .43619847737177700D-01
A4
= .37315667469401120D-01
A5
= .27234431511063550D-01
A6
= .24542267048675820D-01
A7
= .21524579522454650D-01
A8
= .19405725644981920D-01
A9
= .17425301296226190D-01
A10
= .15698229795711810D-01
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .9823693171
.22348398E-01
43.957
.0000
240
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LC
Mean=
6.483124146
, S.D.=
.3057207536
|
| Model size: Observations =
118, Parameters = 15, Deg.Fr.=
103 |
| Residuals: Sum of squares= .1928767571E-01, Std.Dev.=
.01368 |
| Fit:
R-squared= .998236, Adjusted R-squared =
.99800 |
| Model test: F[ 14,
103] = 4163.88,
Prob value =
.00000 |
| Diagnostic: Log-L =
346.9847, Restricted(b=0) Log-L =
-27.0928 |
|
LogAmemiyaPrCrt.=
-8.463, Akaike Info. Crt.=
-5.627 |
| Autocorrel: Durbin-Watson Statistic =
.43365,
Rho =
.78317 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LY
.6364230984
.10177907
6.253
.0000 6.5807044
LY1
.2549160948
.12888180
1.978
.0506 6.5719769
LY2
.1209456989
.13074491
.925
.3571 6.5631387
LY3
-.8010460464E-02 .13120238
-.061
.9514 6.5543235
LY4
-.9682191104E-01 .13159448
-.736
.4635 6.5454702
LY5
-.9079748315E-01 .13106868
-.693
.4900 6.5366540
LY6
-.2510685562E-01 .12898456
-.195
.8461 6.5280586
LY7
.2004806151
.10285053
1.949
.0540 6.5196282
LY8
.3016335323E-05 .19765066E-04
.153
.8790 -2.0056133
LY9
-.6383869148E-05 .19776192E-04
-.323
.7475 -10.530809
LY10
-.7089693017E-05 .14165550E-04
-.500
.6178 -19.055926
Q1
-.3741004273E-01 .28823082E-01
-1.298
.1972 .24576271
Q2
-.3725119811E-01 .28783890E-01
-1.294
.1985 .24576271
Q3
-.3762376347E-01 .28834623E-01
-1.305
.1949 .25423729
Q4
-.3837521624E-01 .28930243E-01
-1.326
.1876 .25423729
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .9920183396
.43015547E-02 230.619
.0000
*/
LAG COEFFICIENTS
1.0
ARDL
UNRES
LAGWT
.8
.5
.3
.0
-.2
10
LAG
241
/*=================================================================
Example 17.5. Characteristic Roots of a Dynamic Equation
*/=================================================================
?
? We form the matrix C (name C is in use, we use CC), then get
? the possibly complex roots.
?
Matrix ; CC=[g1,g2,g3/1,0,0/0,1,0] ; List ; CXRT(CC) $
/*
Matrix Result
has 3 rows and 2 columns.
1
2
+---------------------------1| .9006979D+00 .0000000D+00
2| -.3170854D+00 .0000000D+00
3| .2870039D+00 .0000000D+00
*/
/*=================================================================
Example 17.6. An Error Correction Model for Consumption
*/=================================================================
Sample ; 1 - 128 $
Create ; dc = lc - lc1
; dy = ly - ly1 $
Sample ; 2 - 128 $
Nlsq
; Lhs = dc
; Fcn = mu + beta0*dy + (gamma1-1) *(lc1 - theta*ly1)
; Labels = mu,beta0,gamma1,theta
; start = 0,0,0,0 $
/*
+-----------------------------------------------------------------------+
| User Defined Optimization
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Number of iterations completed = 10
|
| Dep. var. = DC
Mean=
.8555875954E-02, S.D.=
.8163655587E-02 |
| Model size: Observations =
127, Parameters =
4, Deg.Fr.=
123 |
| Residuals: Sum of squares= .6861320052E-02, Std.Dev.=
.00735 |
| Fit:
R-squared= .182914, Adjusted R-squared =
.18935 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 3,
123] =
9.18,
Prob value =
.00002 |
| Diagnostic: Log-L =
443.7485, Restricted(b=0) Log-L =
430.9208 |
|
LogAmemiyaPrCrt.=
-9.795, Akaike Info. Crt.=
-6.925 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
242
243
7.4
LC
LY
Variable
7.1
6.7
6.3
6.0
5.6
1953 1957 1961 1965 1969 1973 1977 1981 1985
Quarter
244
.015
EQERROR
.010
.005
.000
-.005
1953 1957 1961 1965 1969 1973 1977 1981 1985
Quarter
245
/*=================================================================
Example 17.7. Testing Common Factor Restrictions
*/=================================================================
Period ; 1953.4 - 1984.4 $
Regress; lhs = lc ; rhs = One,lc1,lc2,ly,ly1,ly2 $
Calc
; List ; ee0 = sumsqdev $
Nlsq
; lhs = lc
; fcn = mu + (tau1+lambda2)*lc1 - tau2*lambda2*lc2
+ beta0*ly - beta0*(tau1+tau2)*ly1 + beta0*tau1*tau2*ly2
; labels=mu,beta0,tau1,tau2,lambda2
; start=0,0,0,0,0 ;maxit=200$
Calc
; List ; ee0 ; ee1 = sumsqdev $
Nlsq
; lhs = lc
; fcn = mu + rho1*lc1+rho2*lc2
+ beta0*(ly-rho1*ly1-rho2*ly2)
; labels=mu,beta0,rho1,rho2
; start=0,0,0,0 ;maxit=200$
Calc
; list ; ee2 = sumsqdev $
Calc
; List ; ee0 ; ee1
; F1 = ((ee1-ee0)/1)/(ee0/(125-6)) $
Calc
; List ; ee0 ; ee2
; F2 = ((ee2-ee0)/2)/(ee0/(125-6)) $
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LC
Mean=
6.451850235
, S.D.=
.3238111975
|
| Model size: Observations =
125, Parameters =
6, Deg.Fr.=
119 |
| Residuals: Sum of squares= .6481263733E-02, Std.Dev.=
.00738 |
| Fit:
R-squared= .999502, Adjusted R-squared =
.99948 |
| Model test: F[ 5,
119] =47720.63,
Prob value =
.00000 |
| Diagnostic: Log-L =
439.3298, Restricted(b=0) Log-L =
-35.9160 |
|
LogAmemiyaPrCrt.=
-9.771, Akaike Info. Crt.=
-6.933 |
| Autocorrel: Durbin-Watson Statistic =
2.07158,
Rho =
-.03579 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .6494191539E-02 .13486126E-01
.482
.6310
LC1
.9086046159
.96581645E-01
9.408
.0000 6.4431751
LC2
-.2141138412E-02 .96494561E-01
-.022
.9823 6.4345929
LY
.3062449314
.58235276E-01
5.259
.0000 6.5487101
LY1
-.9229841847E-01 .69572743E-01
-1.327
.1872 6.5400030
LY2
-.1220325919
.61915213E-01
-1.971
.0510 6.5313909
EE0
= .64812637328700630D-02
246
+-----------------------------------------------------------------------+
| User Defined Optimization
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Number of iterations completed = 65
|
| Dep. var. = LC
Mean=
6.451850235
, S.D.=
.3238111975
|
| Model size: Observations =
125, Parameters =
5, Deg.Fr.=
120 |
| Residuals: Sum of squares= .6745500827E-02, Std.Dev.=
.00735 |
| Fit:
R-squared= .999481, Adjusted R-squared =
.99949 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 4,
120] =57794.58,
Prob value =
.00000 |
| Diagnostic: Log-L =
436.8323, Restricted(b=0) Log-L =
-35.9160 |
|
LogAmemiyaPrCrt.=
-9.788, Akaike Info. Crt.=
-6.909 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
MU
.5747716575E-02 .13419787E-01
.428
.6684
BETA0
.2805761717
.56794666E-01
4.940
.0000
TAU1
.8325132707E-01 .10932414
.762
.4464
TAU2
.4887174624
.21755638
2.246
.0247
LAMBDA2
.8543857917
.64348149E-01
13.278
.0000
EE1
= .67455008270948710D-02
+-----------------------------------------------------------------------+
| User Defined Optimization
|
| Nonlinear
least squares regression
Weighting variable = none
|
| Number of iterations completed = 10
|
| Dep. var. = LC
Mean=
6.451850235
, S.D.=
.3238111975
|
| Model size: Observations =
125, Parameters =
4, Deg.Fr.=
121 |
| Residuals: Sum of squares= .7040821656E-02, Std.Dev.=
.00751 |
| Fit:
R-squared= .999458, Adjusted R-squared =
.99946 |
|
(Note: Not using OLS. R-squared is not bounded in [0,1] |
| Model test: F[ 3,
121] =74440.78,
Prob value =
.00000 |
| Diagnostic: Log-L =
434.1542, Restricted(b=0) Log-L =
-35.9160 |
|
LogAmemiyaPrCrt.=
-9.753, Akaike Info. Crt.=
-6.882 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
MU
.1268356673E-01 .13407493E-01
.946
.3441
BETA0
.2523008876
.55727737E-01
4.527
.0000
RHO1
.9661681816
.93871583E-01
10.292
.0000
RHO2
.3258077655E-01 .93831625E-01
.347
.7284
EE2
= .70408216561875250D-02
F1
F2
*/
=
=
.48515560404186640D+01
.51369143132593640D+01
247
Date
Period
Plot
Identify
;
;
;
;
1990.01
1990.01
Rhs = Y
Rhs = y
$
- 1994.12 $
$
; Pds = 15 $
248
Period
; 1990.03 - 1994.12 $
Regress ; Lhs = y ; Rhs = One,y[-1],y[-2] ; Res = u $
Identify ; Rhs = u ; Pds = 15 $
1.0
Y (x10^01)
.9
.9
.9
.8
.8
.7
.6
1989
1990
1991
1992
1993
1994
1995
Month
/*
-----------------------------------------------------------------------------Time series identification for Y
Box-Pierce Statistic =
321.9940
Box-Ljung Statistic =
360.5745
Degrees of freedom
=
15
Degrees of freedom
=
15
Significance level
=
.0000
Significance level
=
.0000
* => |coefficient| > 2/sqrt(N) or > 95% significant.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Lag | Autocorrelation Function
|Box/Prc|
Partial Autocorrelations
X
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1 | .967*|
|*********** | 56.05*| .967*|
|***********X
2 | .909*|
|********** |105.63*|-.381*|
**** |
X
3 | .853*|
|*********
|149.27*| .138 |
|**
X
4 | .795*|
|*********
|187.17*|-.156 |
** |
X
5 | .736*|
|********
|219.64*| .012 |
|*
X
6 | .674*|
|*******
|246.92*|-.101 |
* |
X
7 | .606*|
|*******
|268.94*|-.144 |
** |
X
249
8 | .530*|
|******
|285.83*|-.093 |
* |
X
9 | .451*|
|*****
|298.04*|-.102 |
* |
X
10 | .379*|
|****
|306.67*| .123 |
|*
X
11 | .318*|
|***
|312.73*| .009 |
|*
X
12 | .260*|
|***
|316.77*|-.056 |
* |
X
13 | .209 |
|**
|319.39*| .115 |
|*
X
14 | .165 |
|**
|321.03*|-.037 |
* |
X
15 | .127 |
|*
|321.99*| .071 |
|*
X
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
250
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = Y
Mean=
8.254137931
, S.D.=
.7940392727
|
| Model size: Observations =
58, Parameters =
3, Deg.Fr.=
55 |
| Residuals: Sum of squares= 1.330096379
, Std.Dev.=
.15551 |
| Fit:
R-squared= .962990, Adjusted R-squared =
.96164 |
| Model test: F[ 2,
55] = 715.53,
Prob value =
.00000 |
| Diagnostic: Log-L =
27.1821, Restricted(b=0) Log-L =
-68.4180 |
|
LogAmemiyaPrCrt.=
-3.672, Akaike Info. Crt.=
-.834 |
| Autocorrel: Durbin-Watson Statistic =
1.41841,
Rho =
.29079 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .4067997149
.21073101
1.930
.0587
Y
[-1] 1.156647985
.11066012
10.452
.0000 8.2758621
Y
[-2] -.2082934278
.11016139
-1.891
.0639 8.2812069
-----------------------------------------------------------------------------All observations in current sample
-----------------------------------------------------------------------------Time series identification for U
Box-Pierce Statistic =
7.9816
Box-Ljung Statistic =
9.5540
Degrees of freedom
=
14
Degrees of freedom
=
14
Significance level
=
.8903
Significance level
=
.7940
* => |coefficient| > 2/sqrt(N) or > 95% significant.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Lag | Autocorrelation Function
|Box/Prc|
Partial Autocorrelations
X
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1 | .213 |
|**
| 2.64 | .213 |
|**
X
2 |-.007 |
*|
| 2.64 |-.063 |
* |
X
3 |-.022 |
*|
| 2.67 |-.016 |
* |
X
4 | .108 |
|*
| 3.35 | .126 |
|*
X
5 | .079 |
|*
| 3.71 | .043 |
|*
X
6 | .045 |
|*
| 3.83 | .027 |
|*
X
7 |-.062 |
*|
| 4.05 |-.086 |
* |
X
8 | .032 |
|*
| 4.11 | .073 |
|*
X
9 |-.065 |
*|
| 4.36 |-.153 |
** |
X
10 |-.069 |
*|
| 4.63 |-.068 |
* |
X
11 | .038 |
|*
| 4.72 | .120 |
|*
X
12 |-.134 |
*|
| 5.75 |-.249 |
*** |
X
13 |-.141 |
**|
| 6.91 |-.117 |
* |
X
14 |-.136 |
*|
| 7.98 |-.183 |
** |
X
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*/
251
/*=================================================================
Example 18.2. ARMAX and Distributed Lag Models for Gasoline Sales
*/=================================================================
Read ; Nobs = 36 ; Nvar = 11 ; Names =
Year, G,
Pg, Y,
Pnc,
Puc, Ppt,
Pd,
Pn,
Ps,
Pop $
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
129.7
131.3
137.1
141.6
148.8
155.9
164.9
171.0
183.4
195.8
207.4
218.3
226.8
237.9
225.8
232.4
241.7
249.2
261.3
248.9
226.8
225.6
228.8
239.6
244.7
245.8
269.4
276.8
279.9
284.1
282.0
271.8
280.2
286.7
290.2
297.8
.925
.914
.919
.918
.914
.949
.970
1.000
1.014
1.047
1.056
1.063
1.076
1.181
1.599
1.708
1.779
1.882
1.963
2.656
3.691
4.109
3.894
3.764
3.707
3.738
2.921
3.038
3.065
3.353
3.834
3.766
3.751
3.713
3.732
3.789
6036
6113
6271
6378
6727
7027
7280
7513
7728
7891
8134
8322
8562
9042
8867
8944
9175
9381
9735
9829
9722
9769
9725
9930
10421
10563
10780
10859
11186
11300
11389
11272
11466
11476
11636
11934
1.045
1.045
1.041
1.035
1.032
1.009
.991
1.000
1.028
1.044
1.076
1.120
1.110
1.111
1.175
1.276
1.357
1.429
1.538
1.660
1.793
1.902
1.976
2.026
2.085
2.152
2.240
2.321
2.368
2.414
2.451
2.538
2.528
2.663
2.754
2.815
.836
.869
.948
.960
1.001
.994
.970
1.000
1.028
1.031
1.043
1.102
1.105
1.176
1.226
1.464
1.679
1.828
1.865
2.010
2.081
2.569
2.964
3.297
3.757
3.797
3.632
3.776
3.939
4.019
3.926
3.942
4.113
4.470
4.730
5.224
.810
.846
.874
.885
.901
.919
.952
1.000
1.046
1.127
1.285
1.377
1.434
1.448
1.480
1.586
1.742
1.824
1.878
2.003
2.516
3.120
3.460
3.626
3.852
4.028
4.264
4.413
4.494
4.719
5.197
5.427
5.518
6.086
6.268
6.410
.444
.448
.457
.463
.470
.471
.475
.483
.501
.514
.527
.547
.555
.566
.604
.659
.695
.727
.769
.821
.892
.957
1.000
1.041
1.038
1.045
1.053
1.085
1.105
1.129
1.144
1.167
1.184
1.200
1.225
1.239
.331
.335
.338
.343
.347
.353
.366
.375
.390
.409
.427
.442
.458
.497
.572
.615
.638
.671
.719
.800
.894
.969
1.000
1.021
1.050
1.075
1.069
1.111
1.152
1.213
1.285
1.332
1.358
1.379
1.396
1.419
.302
.307
.314
.320
.325
.332
.342
.353
.368
.386
.407
.431
.451
.474
.513
.556
.598
.648
.698
.756
.839
.926
1.000
1.062
1.117
1.173
1.224
1.271
1.336
1.408
1.482
1.557
1.625
1.684
1.734
1.786
180.7
183.7
186.5
189.2
191.9
194.3
196.6
198.7
200.7
202.7
205.1
207.7
209.9
211.9
213.9
216.0
218.0
220.2
222.6
225.1
227.7
230.0
232.2
234.3
236.3
238.5
240.7
242.8
245.0
247.3
249.9
252.6
255.4
258.1
260.7
263.2
252
?
? Data Setup
?
Create ; lg = Log(100*G/Pop)
; ly = Log(Y)
; lpg= Log(Pg)
; lpnc = Log(Pnc)
; lpuc = log(Puc)
; lppt = log(Ppt)
; t=trn(1,1) $
Create ; lg1=lg[-1]
; ly1=ly[-1] ; ly2=ly[-2]
; lp1=lpg[-1] ; lp2=lpg[-2] $
Sample ; 3 - 36 $
?
? Unrestricted distributed lag model
?
Regress; Lhs = lg ; Rhs = One,lpnc,lpuc,lppt,t,lpg,lp1,lp2,ly,ly1,ly2 $
Calc
; List ; eeu=sumsqdev
; LRPrice = b(6)+b(7)+b(8)
; LRIncome=b(9)+b(10)+b(11) $
?
? Autoregressive distributed lag model. Adds lagged dependent variable.
?
Regress; Lhs = lg ; Rhs = One,lpnc,lpuc,lppt,t,lpg,lp1,lp2,ly,ly1,ly2,lg1 $
Calc
; List ; eeardl=sumsqdev
; LRPrice = (b(6)+b(7)+b(8))/(1-b(12))
; LRIncome= (b(9)+b(10)+b(11))/(1-b(12)) $
?
? ARMAX 1,1 model. Same as previous + MA term in disturbance
?
Armax;Lhs=lg;Rhs = One,lpnc,lpuc,lppt,t,lpg,lp1,lp2,ly,ly1,ly2
; Model = 1,0,1 $
Calc
; List ; ee101l=sumsqdev
; LRPrice = (b(7)+b(8)+b(9))/(1-b(1))
; LRIncome= (b(10)+b(11)+b(12))/(1-b(1)) $
?
? ARMAX 1,2 model
?
Armax;Lhs=lg;Rhs = One,lpnc,lpuc,lppt,t,lpg,lp1,lp2,ly,ly1,ly2
; Model = 1,0,2 $
Calc
; List ; ee101=sumsqdev
; LRPrice = (b(7)+b(8)+b(9))/(1-b(1))
; LRIncome= (b(10)+b(11)+b(12))/(1-b(1)) $
?
? Likelihood ratio tests for MA disturbance terms
?
Calc
; List ; LRtest = n*log(eeardl/ee101)$
Calc
; List ; LRtest = n*log(eeardl/ee102)$
253
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.620873819
, S.D.=
.1319690203
|
| Model size: Observations =
34, Parameters = 11, Deg.Fr.=
23 |
| Residuals: Sum of squares= .1260984686E-01, Std.Dev.=
.02341 |
| Fit:
R-squared= .978059, Adjusted R-squared =
.96852 |
| Model test: F[ 10,
23] = 102.53,
Prob value =
.00000 |
| Diagnostic: Log-L =
86.0499, Restricted(b=0) Log-L =
21.1200 |
|
LogAmemiyaPrCrt.=
-7.228, Akaike Info. Crt.=
-4.415 |
| Autocorrel: Durbin-Watson Statistic =
.99232,
Rho =
.50384 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -14.29662165
1.5073767
-9.484
.0000
LPNC
.5882663457E-01 .15788778
.373
.7129 .46667946
LPUC
.2428456789E-01 .10955418
.222
.8265 .71204645
LPPT
-.1468164915
.80724704E-01
-1.819
.0820 .82861565
T
-.1724148643E-01 .68946034E-02
-2.501
.0200 19.500000
LPG
-.1423360612
.60999130E-01
-2.333
.0287 .71868477
LP1
-.1355717985
.92045537E-01
-1.473
.1543 .67686045
LP2
.1527629660
.65706547E-01
2.325
.0293 .63583381
LY
1.066226960
.36456200
2.925
.0076 9.1344038
LY1
-.2646159004
.43702942
-.605
.5508 9.1147281
LY2
1.330349791
.35703039
3.726
.0011 9.0954233
EEU
= .12609846858095140D-01
LRPRICE = -.12514489369519600D+00
LRINCOME= .21319608506567860D+01
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = LG
Mean=
4.620873819
, S.D.=
.1319690203
|
| Model size: Observations =
34, Parameters = 12, Deg.Fr.=
22 |
| Residuals: Sum of squares= .4087856687E-02, Std.Dev.=
.01363 |
| Fit:
R-squared= .992887, Adjusted R-squared =
.98933 |
| Model test: F[ 11,
22] = 279.19,
Prob value =
.00000 |
| Diagnostic: Log-L =
105.1997, Restricted(b=0) Log-L =
21.1200 |
|
LogAmemiyaPrCrt.=
-8.288, Akaike Info. Crt.=
-5.482 |
| Autocorrel: Durbin-Watson Statistic =
2.23098,
Rho =
-.11549 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -4.627715460
1.6758475
-2.761
.0114
LPNC
-.6487625126E-01 .93714005E-01
-.692
.4960 .46667946
LPUC
.4561854245E-01 .63856274E-01
.714
.4825 .71204645
LPPT
-.7486180042E-01 .48181135E-01
-1.554
.1345 .82861565
T
-.3644937438E-02 .44879063E-02
-.812
.4254 19.500000
LPG
-.2245579505
.37529595E-01
-5.983
.0000 .71868477
LP1
.8694928014E-01 .62857352E-01
1.383
.1805 .67686045
LP2
.9215605606E-01 .39284923E-01
2.346
.0284 .63583381
LY
.5782447449
.22413330
2.580
.0171 9.1344038
LY1
-.5417725200
.25769338
-2.102
.0472 9.1147281
LY2
.6317025598
.23204386
2.722
.0124 9.0954233
LG1
.7236274196
.10685159
6.772
.0000 4.6073642
EEARDL = .40878566872995180D-02
LRPRICE = -.16446137389191410D+00
LRINCOME= .24176594644651640D+01
+---------------------------------------------------------+
| Model:y(t) = mu + bx + phi(1)y(t-1)...phi(p)y(t-p))
|
254
|
+ e(t) + tau(1)e(t-1)...tau(q)e(t-q))
|
|
y(t) = [(1-L)^d]Y(t) (differences))
|
| Dependent variable
LG
|
| Raw data were differenced d = 0 times.
|
| Sum of squares at best estimates:
.003794 |
| Estimated standard deviation of e(t):
.010723 |
| For diagnostic checking, use IDENTIFY with residuals.
|
| Number of iterations completed
10 |
| Number of observations in the sample
34 |
+---------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Phi( 1)
.7567895407
.10933025
6.922
.0000
Mu
-4.241262015
1.6260814
-2.608
.0091
LPNC
-.7103594420E-01 .84364675E-01
-.842
.3998 .46667946
LPUC
.4294366513E-01 .56172547E-01
.764
.4446 .71204645
LPPT
-.7406407555E-01 .44872033E-01
-1.651
.0988 .82861565
T
-.2817177434E-02 .41662590E-02
-.676
.4989 19.500000
LPG
-.2301678388
.29763433E-01
-7.733
.0000 .71868477
LP1
.1032765894
.49429729E-01
2.089
.0367 .67686045
LP2
.8746080080E-01 .30851084E-01
2.835
.0046 .63583381
LY
.5711896035
.18242745
3.131
.0017 9.1344038
LY1
-.5551523610
.20507375
-2.707
.0068 9.1147281
LY2
.5911142674
.18871370
3.132
.0017 9.0954233
Tau( 1) -.2012147439
.21103910
-.953
.3404
EE101
= .37941383576883920D-02
LRPRICE = -.16212480626093280D+00
LRINCOME= .24964037797167360D+01
255
+---------------------------------------------------------+
| Model:y(t) = mu + bx + phi(1)y(t-1)...phi(p)y(t-p))
|
|
+ e(t) + tau(1)e(t-1)...tau(q)e(t-q))
|
|
y(t) = [(1-L)^d]Y(t) (differences))
|
| Dependent variable
LG
|
| Raw data were differenced d = 0 times.
|
| Sum of squares at best estimates:
.002348 |
| Estimated standard deviation of e(t):
.008567 |
| For diagnostic checking, use IDENTIFY with residuals.
|
| Number of iterations completed
46 |
| Number of observations in the sample
34 |
+---------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Phi( 1)
.6782460416
.10639955
6.375
.0000
Mu
-5.376139750
1.6339620
-3.290
.0010
LPNC
-.6700029245E-01 .80836954E-01
-.829
.4072 .46667946
LPUC
.1198396402E-01 .51321503E-01
.234
.8154 .71204645
LPPT
-.9170603295E-01 .38558900E-01
-2.378
.0174 .82861565
T
-.2740882117E-02 .44658357E-02
-.614
.5394 19.500000
LPG
-.2079645837
.23028449E-01
-9.031
.0000 .71868477
LP1
.8194823327E-01 .39585361E-01
2.070
.0384 .67686045
LP2
.1018543456
.20421712E-01
4.988
.0000 .63583381
LY
.8158187084
.16005178
5.097
.0000 9.1344038
LY1
-.6739998128
.16094847
-4.188
.0000 9.1147281
LY2
.6314479677
.14170962
4.456
.0000 9.0954233
Tau( 1) -.3513342541
.18326241
-1.917
.0552
Tau( 2) -.5215635178
.15679811
-3.326
.0009
EE102
= .23484984739687290D-02
LRPRICE = -.75094661971386960D-01
LRINCOME= .24032862471922000D+01
LRTEST
LRTEST
=.25351575386092380D+01
= .18844317034750870D+02
256
/*=================================================================
Example 18.3. Spectral Density for an AR(1) Process
No computations
*/=================================================================
/*=================================================================
Example 18.4. Spectral Analysis of the Growth Rate of GNP
*/=================================================================
Read ; Nobs = 136 ; Nvar = 4 ; Names = Qtr,GNP,M1,Price$
1950.1
1950.2
1950.3
1950.4
1951.1
1951.2
1951.3
1951.4
1952.1
1952.2
1952.3
1952.4
1953.1
1953.2
1953.3
1953.4
1954.1
1954.2
1954.3
1954.4
1955.1
1955.2
1955.3
1955.4
1956.1
1956.2
1956.3
1956.4
1957.1
1957.2
1957.3
1957.4
1958.1
1958.2
1958.3
1958.4
1959.1
1959.2
1959.3
1959.4
1960.1
1960.2
1960.3
1960.4
1961.1
1961.2
1961.3
1961.4
1962.1
1962.2
1962.3
1962.4
1963.1
1963.2
1963.3
1963.4
1964.1
1964.2
1964.3
1964.4
1965.1
1965.2
267.6
277.1
294.8
306.3
320.4
328.3
335.0
339.2
341.9
342.1
347.8
360.0
366.1
369.4
368.4
363.1
362.5
362.3
366.7
375.6
388.2
396.2
404.8
411.0
412.8
418.4
423.5
432.1
440.2
442.3
449.4
444.0
436.8
440.7
453.9
467.0
477.0
490.6
489.0
495.0
506.9
506.3
508.0
504.8
508.2
519.2
528.2
542.6
554.2
562.7
568.9
574.3
582.0
590.7
601.8
612.4
625.3
634.0
642.8
648.8
668.8
681.7
110.20
111.75
112.95
113.93
115.08
116.19
117.76
119.89
121.31
122.37
123.64
124.72
125.33
126.05
126.22
126.37
126.54
127.18
128.38
129.72
131.07
131.88
132.40
132.64
133.11
133.38
133.48
134.09
134.29
134.36
134.26
133.48
133.72
135.22
136.64
138.48
140.35
141.75
142.23
141.20
140.83
140.83
142.00
141.98
142.85
143.88
144.90
146.18
147.18
147.95
147.90
148.93
150.45
151.93
153.38
154.80
155.85
157.20
159.75
161.63
162.90
163.90
56.04
56.21
56.41
56.67
56.77
57.01
56.99
57.58
57.58
57.57
57.92
58.58
58.76
58.80
59.00
58.74
59.38
59.58
59.45
59.77
60.27
60.65
61.03
61.40
61.91
62.43
63.13
63.69
64.40
64.65
65.28
65.37
65.63
65.79
66.17
66.47
67.04
67.55
67.81
68.00
68.44
68.56
68.86
68.96
68.88
69.22
69.54
69.65
70.23
70.48
70.62
71.08
71.41
71.46
71.66
72.17
72.36
72.57
72.97
73.16
73.77
74.13
257
1965.3
1965.4
1966.1
1966.2
1966.3
1966.4
1967.1
1967.2
1967.3
1967.4
1968.1
1968.2
1968.3
1968.4
1969.1
1969.2
1969.3
1969.4
1970.1
1970.2
1970.3
1970.4
1971.1
1971.2
1971.3
1971.4
1972.1
1972.2
1972.3
1972.4
1973.1
1973.2
1973.3
1973.4
1974.1
1974.2
1974.3
1974.4
1975.1
1975.2
1975.3
1975.4
1976.1
1976.2
1976.3
1976.4
1977.1
1977.2
1977.3
1977.4
1978.1
1978.2
1978.3
1978.4
1979.1
1979.2
1979.3
1979.4
1980.1
1980.2
1980.3
1980.4
1981.1
1981.2
1981.3
1981.4
1982.1
1982.2
1982.3
1982.4
1983.1
1983.2
696.4
717.2
738.5
750.0
760.6
774.9
780.7
788.6
805.7
823.3
841.2
867.2
884.9
900.3
921.2
937.4
955.3
962.0
972.0
986.3
1003.6
1009.0
1049.3
1068.9
1086.6
1105.8
1142.4
1171.7
1196.1
1233.5
1283.5
1307.6
1337.7
1376.7
1387.7
1423.8
1451.6
1473.8
1479.8
1516.7
1578.5
1621.8
1672.0
1698.6
1729.0
1772.5
1834.8
1895.1
1954.4
1988.9
2031.7
2139.5
2202.5
2281.6
2335.5
2377.9
2454.8
2502.9
2572.9
2578.8
2639.1
2736.0
2875.8
2918.0
3009.3
3027.9
3026.0
3061.2
3080.1
3109.6
3173.8
3267.0
166.05
169.10
171.95
172.98
172.80
173.33
175.25
178.10
181.93
184.73
187.15
190.63
194.30
198.55
201.73
203.18
204.18
206.10
207.90
209.78
212.78
216.08
220.28
225.25
228.45
230.70
235.60
239.38
244.55
250.70
254.80
258.40
261.03
264.68
268.77
271.23
273.73
276.73
278.75
283.80
288.13
290.88
295.18
299.53
303.35
309.35
316.55
321.80
327.60
334.80
341.13
348.70
335.45
361.38
367.08
376.10
384.58
388.38
394.30
390.00
405.50
416.10
420.90
429.30
432.60
437.50
448.80
451.30
458.20
475.70
490.90
505.20
74.56
74.96
75.71
76.58
76.99
77.75
78.27
78.53
79.28
80.13
81.15
82.14
82.84
83.99
84.97
86.10
87.49
88.62
89.89
91.07
91.79
93.03
94.40
95.70
96.52
97.39
98.72
99.42
100.25
101.54
102.95
104.75
106.53
108.74
110.72
113.48
116.42
119.79
122.88
124.44
126.68
128.99
130.12
131.30
132.89
134.99
136.80
139.01
141.03
143.24
145.12
148.89
152.02
155.38
158.60
161.85
165.12
168.05
171.94
176.46
180.24
185.13
190.01
193.03
197.70
201.69
203.98
206.77
208.53
210.27
212.87
214.25
258
1983.3
1983.4
Create
Create
Create
Sample
Create
Date
Period
Create
Plot
;
;
;
;
;
;
;
;
;
3346.6
3431.7
517.20
523.40
215.89
218.21
z=log(gnp/price) $
dz=100*(z-z[-1])$ (Just change to DZ=Z to analyze REAL GNP.)
y=dz[+1]$
Move data back to rows 1-135
1 - 135 $
yd = y - xbr(y) $ Data in deviation form
1950.2$
1950.2-1983.4$
gnpgrwth=yd$
(Just labels the graph)
Rhs=gnpgrwth$
GNPGRWTH
4
2
0
-2
-4
1950 1955
1960
1965
1970
1975
1980
1985
Quarter
259
260
/*=====================================================================
Spectral Analysis of a variable. LIMDEP is not good at this. The
following is a brute force computation. Better to use RATS or GAUSS
*/=====================================================================
?
? The following analyzes the growth rate for GNP
?
?
Compute column of sample autocovariances
?
Move into c0 and vector of 134 covariances
Matrix ; Auto=init(135,1,0)$
Procedure
Calc
; i=j+1;mj=-j$
Sample ; 1-135$
Create ; lagyd=yd[mj]$
Sample ; i-135$
Matrix ; {cj=yd'lagyd/135} ; auto(i)=cj$
Endproc
Execute ; j=0,134$
Calc
; c0=auto(1)$
Matrix ; ck=auto(2:135)$
? 3: Sample periodogram (spectral density function)
Sample ; 1-135$
Create ; wj = Trn(1,1) ; Freq=2*pi*wj/135$ Frequencies in 2pi interval
Matrix ; W = wj ; omegas=freq ; Spectrum = 0.0 [135,1] $
? Procedure computes spectral density at each frequency
Procedure
Calc
; omegaj=omegas(i)$
Particular frequency
Create ; coswj=cos((wj*omegaj))$
Column of k*omega
Matrix ; cosines=coswj ; cosines=cosines(1:134)$ Subvector
Calc
; hy=1/(2*pi)*(c0+2*ck'cosines)$
Spectrum
Matrix ; Spectrum(i)=hy$
Move spectrum to vector
Endproc
Execute ; i=1,135$
Compute for all 135 frequencies
? 4. Plot periodogram
Matrix ; spectrum=spectrum(1:67); w=w(1:67) $ Only useful for 67
Mplot
; lhs=W;rhs=spectrum;fill;endpoints=0,70;limits=0,1.5$
261
1.5
SPECTRUM
1.2
.9
.6
.3
.0
14
28
42
56
70
Date
Period
Create
Create
Create
Plot
;
;
;
;
;
;
1950.1 $
1950.1-1983.4 $
z=log(gnp/price) $
yd = z - xbr(z) $ Data in deviation form
realgnp=yd$
(Just labels the graph)
Rhs=realgnp$
262
.6
R EALGN P
.4
.2
.0
-.2
-.4
-.6
-.8
1949
1954
1959
1964
1969
1974
1979
1984
Quarter
263
?
? The following analyzes the original series of real GNP
?
Matrix ; Auto=init(136,1,0)$
Procedure
Calc
; i=j+1;mj=-j$
Sample ; 1-136$
Create ; lagyd=yd[mj]$
Sample ; i-136$
Matrix ; {cj=yd'lagyd/135} ; auto(i)=cj$
Endproc
Execute ; j=0,135$
Calc
; c0=auto(1)$
Matrix ; ck=auto(2:136)$
? 3: Sample periodogram (spectral density function)
Sample ; 1-136$
Create ; wj = Trn(1,1) ; Freq=2*pi*wj/136$ Frequencies in 2pi interval
Matrix ; W = wj ; omegas=freq ; Spectrum = 0.0 [135,1] $
? Procedure computes spectral density at each frequency
Procedure
Calc
; omegaj=omegas(i)$
Particular frequency
Create ; coswj=cos((wj*omegaj))$
Column of k*omega
Matrix ; cosines=coswj ; cosines=cosines(1:135)$ Subvector
Calc
; hy=1/(2*pi)*(c0+2*ck'cosines)$
Spectrum
Matrix ; Spectrum(i)=hy$
Move spectrum to vector
Endproc
Execute ; i=1,136$
Compute for all 136 frequencies
? 4. Plot periodogram
Matrix ; spectrum=spectrum(1:68); w=w(1:68) $ Only useful for 68
Mplot
; lhs=W;rhs=spectrum;fill;endpoints=0,70;limits=0,1.5$
.9
S P E C TR U M
.7
.5
.3
.1
-.1
14
28
42
56
70
264
265
/*=================================================================
Example 18.5. A Nonstationary Series
*/=================================================================
Date
; 1950.1 $
Period ; 1950.1 - 1983.4 $
Create ; LogPrice = log(price) $
Create ; dlogP = logprice - logprice[-1] $
Create ; d2logP = dlogp - dlogp[-1] $
Period ; 1950.3 - 1983.4 $
Plot
; Rhs = LogPrice $
Plot
; Rhs = dlogP $
Plot
; Rhs = d2logP $
Identify ; Rhs = LogPrice ; Pds = 10 $
5.50
5.25
LOGPRICE
5.00
4.75
4.50
4.25
4.00
3.75
1950 1955 1960 1965 1970 1975 1980 1985
Quarter
266
.03
DLOGP
.02
.01
.00
-.01
1950 1955 1960 1965 1970 1975 1980 1985
Quarter
267
.020
.015
D2LOGP
.010
.005
.000
-.005
-.010
-.015
1950 1955 1960 1965 1970 1975 1980 1985
Quarter
268
269
/*=================================================================
Example 18.6. Test for a Unit Root
*/=================================================================
?
? Data are read in Example 18.4.
? Variables read are qtr,GNP,M1,Price
?
Create
; yt=log(GNP/Price)
; yt1=yt[-1] ; yt2=yt[-2] ; t = trn(1,1) $
Create
; dy1 = yt - yt1
; dy2 = yt1 - yt2 $
Sample
; 3 - 136 $
Regress ; Lhs = dy1 ; Rhs = One,yt1 $
Regress ; Lhs = dy1 ; Rhs = One,t,yt1,dy2 $
Calc
; List ; Rsqa = Rsqrd $
Regress ; Lhs = dy1 ; Rhs = One,dy2 $
Calc
; List ; Rsq = Rsqrd $
Calc
; List ; Ftest = ((Rsqa - Rsq)/2)/((1-rsqa)/(n-4))
; Ftb(.95,2,(n-4)) $
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = DY1
Mean=
.8657234086E-02, S.D.=
.1193419965E-01 |
| Model size: Observations =
134, Parameters =
2, Deg.Fr.=
132 |
| Residuals: Sum of squares= .1814441450E-01, Std.Dev.=
.01172 |
| Fit:
R-squared= .042134, Adjusted R-squared =
.03488 |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .2557909796E-01 .70952420E-02
3.605
.0004
YT1
-.7505859933E-02 .31149356E-02
-2.410
.0173 2.2544870
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = DY1
Mean=
.8657234086E-02, S.D.=
.1193419965E-01 |
| Model size: Observations =
134, Parameters =
4, Deg.Fr.=
130 |
| Residuals: Sum of squares= .1292009899E-01, Std.Dev.=
.00997 |
| Fit:
R-squared= .317932, Adjusted R-squared =
.30219 |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .1419956872
.39096783E-01
3.632
.0004
T
.6550410295E-03 .19676684E-03
3.329
.0011 69.500000
YT1
-.8125692526E-01 .23363228E-01
-3.478
.0007 2.2544870
DY2
.4926268437
.73297048E-01
6.721
.0000 .87873400E-02
RSQA
= .31793211367952040D+00
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = DY1
Mean=
.8657234086E-02, S.D.=
.1193419965E-01 |
| Model size: Observations =
134, Parameters =
2, Deg.Fr.=
132 |
| Residuals: Sum of squares= .1423933668E-01, Std.Dev.=
.01039 |
| Fit:
R-squared= .248288, Adjusted R-squared =
.24259 |
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .4335601869E-02 .11105839E-02
3.904
.0002
DY2
.4918020950
.74482005E-01
6.603
.0000 .87873400E-02
RSQ
= .24828793663054320D+00
FTEST
= .66369808621315140D+01
Result = .30658390938300010D+01
/*=================================================================
Example 18.7. Long Term Memory in the Growth of Real GNP
270
No computations
*/=================================================================
/*=================================================================
Example 18.8. Long Term Memory in Foreign Exchange Markets
No Computations
*/=================================================================
/*=================================================================
Example 18.9. Cointegrated Series
No computations
*/=================================================================
/*=================================================================
Example 18.10. Multiple Cointegrating Vectors
No computations
*/=================================================================
271
/*=================================================================
Example 18.11. An ARCH Model for Inflation
*/=================================================================
?
? The data are read in Example 18.4.
? Variables are Qtr,GNP,M1,Price. To do this set of computations,
? the program should be reset, and the data set read in fresh.
? Data setup
Create ; logp=log(price)
; logm1=log(m1)
; logy=log(gnp/price)$
Create ; dlogp=100*(logp-logp[-1]) ; dlogm1=100*(logm1-logm1[-1])$
Create ; dlogy=100*(logy-logy[-1]) ; xsdm1=dlogm1-dlogy$
Create ; lagxsdm1=xsdm1[-1]
; lagdlogp=dlogp[-1]$
?
? Set sample to observations 3-136 then run step 1 regression
?
Calc
; t0 = 1 ; t1=3 ; tt=136 ; t2=4 ; ttminus1=135$
Sample ; t1-tt$
Regress; lhs=dlogp;rhs=one,lagxsdm1,lagdlogp;res=et$
?
? Compute squared residuals, then set sample for step 2 regression
Matrix ; beta=b$
Create ; ee=et*et$
Create ; ee1=ee[-1]$
Sample ; t2-tt$
Regress; lhs=ee;rhs=one,ee1$
Matrix ; a=b$
?
? LM test for ARCH effects
?
Calc
; a0=a(1);a1=a(2);list;lmtest=nreg*rsqrd$
?
? Set sample for step 3 regression, then update alpha. Report results.
?
Sample ; t1-tt$
Create ; ht=a0+a1*ee1 ;gt=ee/ht-1 ;zt1=1/ht ; zt2=ee1/ht$
Names ; z=zt1,zt2 ; x=one,lagxsdm1,lagdlogp $
Sample ; t2-tt$
Matrix ; da=<Z'Z>*Z'gt;alpha=a+da;valpha=2*<Z'Z>
; stat(alpha,valpha)$
?
? Compute weighted least squares to update beta, step 4
?
Calc
; alpha0=alpha(1);alpha1=alpha(2)$
Create ; ht=alpha0+alpha1*ee1$
Create ; htplus1=ht[1] ; eeplus1=ee[1]$
Create ; rt=sqr((1/ht)+2*(alpha1*et/htplus1)^2)
; st=1/ht - (alpha1/htplus1)*(eeplus1/htplus1-1)
; etst = et*st$
Sample ; t2-ttminus1$
Matrix ; ww=bhhh(X,rt) ; Vbeta=<WW> ; db=vbeta*X'[etst]et
; beta=beta+db ; Stat(beta,vbeta)$
272
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = DLOGP
Mean=
1.012211362
, S.D.=
.7100138982
|
| Model size: Observations =
134, Parameters =
3, Deg.Fr.=
131 |
| Residuals: Sum of squares= 24.97239974
, Std.Dev.=
.43661 |
| Fit:
R-squared= .627544, Adjusted R-squared =
.62186 |
| Model test: F[ 2,
131] = 110.36,
Prob value =
.00000 |
| Diagnostic: Log-L =
-77.5732, Restricted(b=0) Log-L =
-143.7448 |
|
LogAmemiyaPrCrt.=
-1.635, Akaike Info. Crt.=
1.203 |
| Autocorrel: Durbin-Watson Statistic =
2.55356,
Rho =
-.27678 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .2427295991
.67062129E-01
3.619
.0004
LAGXSDM1 .4069687470E-01 .28237757E-01
1.441
.1519 .27509641
LAGDLOGP .7533929131
.57618919E-01
13.075
.0000 1.0064950
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = EE
Mean=
.1877485342
, S.D.=
.2704841669
|
| Model size: Observations =
133, Parameters =
2, Deg.Fr.=
131 |
| Residuals: Sum of squares= 9.502250517
, Std.Dev.=
.26933 |
| Fit:
R-squared= .016059, Adjusted R-squared =
.00855 |
| Model test: F[ 1,
131] =
2.14,
Prob value =
.14607 |
| Diagnostic: Log-L =
-13.2373, Restricted(b=0) Log-L =
-14.3139 |
|
LogAmemiyaPrCrt.=
-2.609, Akaike Info. Crt.=
.229 |
| Autocorrel: Durbin-Watson Statistic =
2.03347,
Rho =
-.01674 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .1640206032
.28437769E-01
5.768
.0000
EE1
.1266244001
.86596535E-01
1.462
.1461 .18738830
Matrix statistical results: Coefficients=ALPHA
Variance=VALPHA
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
ALPHA_ 1 .1705917119
.26902111E-01
6.341
.0000
ALPHA_ 2 .8660076551E-01 .11804850
.734
.4632
Matrix statistical results: Coefficients=BETA
Variance=VBETA
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
BETA _ 1 .3985526844
.67435646E-01
5.910
.0000
BETA _ 2 .6569283509E-01 .27693141E-01
2.372
.0177
BETA _ 3 .7737730896
.58064792E-01
13.326
.0000
*/
/*=================================================================
Example 18.12. GARCH Model for Inflation
No computations
*/=================================================================
273
GPA
2.66
2.89
3.28
2.92
4.00
2.86
2.76
2.87
3.03
3.92
2.63
3.32
3.57
3.26
3.53
2.74
2.75
2.83
3.12
3.16
2.06
3.62
2.89
3.51
3.54
2.83
3.39
2.67
3.65
4.00
3.10
2.39
?
Namelist
Matrix
Regress
Calc
Matrix
Probit
Calc
Matrix
Logit
Calc
Matrix
Create
Maximize
Calc
Matrix
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
TUCE
20
22
24
12
21
17
17
21
25
29
20
23
23
25
26
19
25
19
23
25
22
28
14
26
24
27
17
24
21
23
21
19
PSI
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
GRADE
0
0
0
0
1
0
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
0
1
1
1
0
1
1
0
1
X = One,GPA,TUCE,PSI $
xbar = mean(x) $
Lhs = Grade ; Rhs = X $
List ; Scale = 1.0 $
List ; ME = Scale * b $
Lhs = Grade ; Rhs = X ; Marginal Effects $
List ; Scale = N01(bxbar) $
List ; ME = Scale * b $
Lhs = Grade ; Rhs = X ; marginal Effects $
List ; Scale = LGD(bxbar) $
List ; ME = Scale * b $
d0 = 1-Grade ; d1 = Grade $
Fcn = -d0*exp(b1x) + d1*log(1-exp(-exp(b1x)))
Labels = b1,b2,b3,b4
Start = b $
List ; Scale = exp(-exp(bxbar))*exp(bxbar) $
List ; ME = Scale * b $
274
/*
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
| Dep. var. = GRADE
Mean=
.3437500000
, S.D.=
.4825587044
|
| Model size: Observations =
32, Parameters =
4, Deg.Fr.=
28 |
+-----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -1.498017120
.52388862
-2.859
.0079
GPA
.4638516793
.16195635
2.864
.0078 3.1171875
TUCE
.1049512224E-01 .19482854E-01
.539
.5944 21.937500
PSI
.3785547879
.13917274
2.720
.0111 .43750000
SCALE
= .10000000000000000D+01
Matrix ME
has 4 rows and 1 columns.
+-------------1| -.1498017D+01
2| .4638517D+00
3| .1049512D-01
4| .3785548D+00
+---------------------------------------------+
| Binomial Probit Model
|
| Number of observations
32
|
| Iterations completed
6
|
| Log likelihood function
-12.81880
|
| Restricted log likelihood
-20.59173
|
| Chi-squared
15.54585
|
| Degrees of freedom
3
|
| Significance level
.1404896E-02 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Index function for probability
Constant -7.452319647
2.5424723
-2.931
.0034
GPA
1.625810039
.69388249
2.343
.0191 3.1171875
TUCE
.5172894549E-01 .83890261E-01
.617
.5375 21.937500
PSI
1.426332342
.59503790
2.397
.0165 .43750000
+-------------------------------------------+
| Partial derivatives of E[y] = F[*]
with |
| respect to the vector of characteristics. |
| They are computed at the means of the Xs. |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Index function for probability
Constant -2.444733653
.75885194
-3.222
.0013
GPA
.5333470255
.23246407
2.294
.0218 3.1171875
TUCE
.1696968191E-01 .27119788E-01
.626
.5315 21.937500
PSI
.4679083617
.18764238
2.494
.0126 .43750000
SCALE
= .32805002591068580D+00
Matrix ME
has 4 rows and 1 columns.
+-------------1| -.2444734D+01
2| .5333470D+00
3| .1696968D-01
4| .4679084D+00
275
+---------------------------------------------+
| Multinomial Logit Model
|
| Dependent variable
GRADE
|
| Number of observations
32
|
| Iterations completed
6
|
| Log likelihood function
-12.88963
|
| Restricted log likelihood
-20.59173
|
| Chi-squared
15.40419
|
| Degrees of freedom
3
|
| Significance level
.1501878E-02 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Characteristics in numerator of Prob[Y = 1]
Constant -13.02134648
4.9313241
-2.641
.0083
GPA
2.826112525
1.2629411
2.238
.0252 3.1171875
TUCE
.9515765670E-01 .14155420
.672
.5014 21.937500
PSI
2.378687596
1.0645642
2.234
.0255 .43750000
+-------------------------------------------+
| Partial derivatives of probabilities with |
| respect to the vector of characteristics. |
| They are computed at the means of the Xs. |
| Observations used for means are All Obs. |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Marginal effects on Prob[Y = 1]
Constant -2.459760743
.81771031
-3.008
.0026
GPA
.5338588183
.23703797
2.252
.0243 3.1171875
TUCE
.1797548884E-01 .26236909E-01
.685
.4933 21.937500
PSI
.4493392735
.19676264
2.284
.0224 .43750000
SCALE
= .18890218048721940D+00
Matrix ME
has 4 rows and 1 columns.
+-------------1| -.2459761D+01
2| .5338588D+00
3| .1797549D-01
4| .4493393D+00
+---------------------------------------------+
| User Defined Optimization
|
| Number of observations
32
|
| Iterations completed
10
|
| Log likelihood function
-13.00800
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
B1
-10.03142629
3.4448183
-2.912
.0036
B2
2.293553481
.99127580
2.314
.0207
B3
.4115615961E-01 .12327466
.334
.7385
B4
1.562276316
.85886363
1.819
.0689
SCALE
= .20817920176287030D+00
Matrix ME
has 4 rows and 1 columns.
+-------------1| -.2088334D+01
2| .4774701D+00
3| .8567856D-02
4| .3252334D+00
/*=================================================================
276
P[Grd=1]
.8
.6
.4
.2
.0
2.0
2.4
2.8
3.2
3.6
4.0
GPAI
277
278
/*=================================================================
Example 19.3. Structural Equations for Probit Model
No computations
*/=================================================================
/*=================================================================
Example 19.4. Estimates of Logit and Probit Models
*/=================================================================
?
? First pass, use preprogrammed routine for marginal effects.
? These results all appear in Example 19.2. Compute some results.
?
Matrix ; xbar = Mean(X) $
Calc
; K = Col(X) $
Probit ; Lhs = Grade ; Rhs = X ; Marginal Effects $
Matrix ; bp = b ; Vp = Varb $
Calc
; bxp = bpxbar ; Pp = Phi(bxp) ; fp = N01(bxp) $
Logit ; Lhs = Grade ; Rhs = X ; Marginal Effects $
Matrix ; bl = b ; Vl = Varb $
Calc
; bxl = blxbar ; Pl = Lgp(bxl) ; fl = Lgd(bxl) $
Calc
; ql = 1-2*Pl $
?
? Compute marginal effects at the means using the formal results
? For the moment, ignore the fact that the 4th variable in X is a
? dummy variable.
? Probit
Matrix ; gamma = fp*bp ; G = Iden(K) - bxp*bp*xbar ; G = fp*G
; Vgamma= G * Vp * G ; Stat(gamma,Vgamma) $
? Logit
Matrix ; gamma = fl*bl ; G = Iden(K) + ql*bl*xbar ; G = fl*G
; Vgamma= G * Vl * G ; Stat(gamma,Vgamma) $
?
? Marginal effect for a binary variable. We do this directly,
? then use the WALD comand. Note that direct computation with
? analytic derivatives is almost exactly the same as the WALD
? result with numerical derivatives, and both are extremely close
? to the naive approach above which ignores the fact the the
? variable is binary.
? Probit
Matrix ; xbar0 = xbar ; xbar0(4)=0 $
Matrix ; xbar1 = xbar ; xbar1(4)=1 $
Calc
; MEp = Phi(bpxbar1) - Phi(bpxbar0)
; f1
=N01(bpxbar1) ; f0=-N01(bpxbar0) $
Matrix ; g1=f1*xbar1 ; g0=f0*xbar0
; g10=[g1/g0]
; I2=Iden(2) ; V=Kron(I2,Vp) ; VME = g10V*g10 $
Calc
; List ; MEp ; Sqr(VME) $
Wald
; Fn1=Phi(b1xbar1) - Phi(b1xbar0)
; Start = bp ; Var = Vp ; Labels=b1,b2,b3,b4 $
? Logit
Calc
; MEl = Lgp(bl'xbar1) - Lgp(bl'xbar0)
; f1
=Lgd(bl'xbar1) ; f0=-Lgd(bl'xbar0) $
Matrix ; g1=f1*xbar1 ; g0=f0*xbar0
; g10=[g1/g0]
; I2=Iden(2) ; V=Kron(I2,Vl) ; VME = g10'V*g10 $
Calc
; List ; MEl ; Sqr(VME) $
Wald
; Fn1=Lgp(b1'xbar1) - Lgp(b1'xbar0)
; Start = bl ; Var = Vl ; Labels=b1,b2,b3,b4 $
/*
279
*/
280
/*=================================================================
Example 19.5. Wald Test for a Subset of Coefficients
No computations
*/=================================================================
/*=================================================================
Example 19.6. Restricted Log Likelihoods and a Chow-type
Test for Probit Models
*/=================================================================
?
? Test whether PSI=1 and 0 divides the sample into different probit
? models.
?
Sample ; 1 - 32 $
Probit ; Lhs = Grade ; Rhs = One,GPA,TUCE $
Calc
; L10 = Logl $
Include; New ; PSI = 1 $
Probit ; Lhs = Grade ; Rhs = One,GPA,TUCE $
Calc
; L1 = Logl $
Include; New ; PSI = 0 $
Probit ; Lhs = Grade ; Rhs = One,GPA,TUCE $
Calc
; L0 = Logl $
Calc
; List ; L10 ; L1 ; L0
; LRTest = 2*(L1+L0-L10)
; Ctb(.95,3) $
/*
|=== Pooled ============================================================|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -6.034326531
2.1210343
-2.845
.0044
GPA
1.409575141
.63546771
2.218
.0265 3.1171875
TUCE
.5266746003E-01 .75552974E-01
.697
.4857 21.937500
|=== PSI = 1============================================================|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -3.870035107
2.8617290
-1.352
.1763
GPA
1.102961296
.78464845
1.406
.1598 3.1378571
TUCE
.2761610433E-01 .98490512E-01
.280
.7792 22.428571
|===PSI = 0=============================================================|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -14.90758306
9.8569123
-1.512
.1304
GPA
3.092024736
1.8135908
1.705
.0882 3.1011111
TUCE
.1535285643
.27087829
.567
.5709 21.555556
L10
= -.16152157328431760D+02
L1
= -.82172423029537920D+01
L0
= -.36612276368288500D+01
LRTEST = .85473747772982410D+01
Result = .78147277654400000D+01
*/
281
/*=================================================================
Example 19.7. Probit Model with Groupwise Heteroscedasticity
*/=================================================================
? No need to program; we just use the built-in procedure
Sample ; 1 - 32 $
? Restricted Model, homoscedastic
Probit ; Lhs = Grade ; Rhs = X ; Marginal Effects$
Calc
; Lr = Logl $
?
? LM test. Compute full model at restricted values. No iterations.
?
Probit ; Lhs = Grade ; Rhs = X ; Rh2 = Psi ; Het ; Start=b,0 ; Maxit=0 $
Calc
; List ; LMTest = LMSTAT $
Probit ; Lhs = Grade ; Rhs = X ; Rh2 = Psi ; Het ; Par ; MarginalEffects $
Calc
; Lu = Logl $
Calc
; List ; LRTest = 2*(Lu - Lr) $
Calc
; List ; WaldTest = (b(5))^2/varb(5,5) $
/*
+---------------------------------------------+
| Binomial Probit Model
|
| Restricted log likelihood
-20.59173
|
| Log likelihood function
-12.81880
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -7.452319647
2.5424723
-2.931
.0034
GPA
1.625810039
.69388249
2.343
.0191 3.1171875
TUCE
.5172894549E-01 .83890261E-01
.617
.5375 21.937500
PSI
1.426332342
.59503790
2.397
.0165 .43750000
Partial derivatives of E[y] = F[*]
GPA
.5333470255
.23246407
2.294
.0218 3.1171875
TUCE
.1696968191E-01 .27119788E-01
.626
.5315 21.937500
PSI
.4679083617
.18764238
2.494
.0126 .43750000
+---------------------------------------------+
| Iterations completed
1
|
| LM Stat. at start values
4.086181
|
| LM statistic kept as scalar
LMSTAT
|
+---------------------------------------------+
| Binomial Probit Model, heteroscedastic
|
| Log likelihood function
-11.89585
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -14.28904915
17.015554
-.840
.4010
GPA
3.121550555
3.2140951
.971
.3314 3.1171875
TUCE
.1237516165
.35386813
.350
.7266 21.937500
PSI
2.343220859
2.3421153
1.000
.3171 .43750000
Variance function
PSI
1.093371488
1.3540594
.807
.4194 .43750000
Partial derivatives of E[y] = F
GPA
.6786282685
.43618572
1.556
.1197 3.1171875
TUCE
.2690372741E-01 .57651589E-01
.467
.6407 21.937500
PSI
.7040071459
.37163541
1.894
.0582 .43750000
LRTEST =
WALDTEST=
*/
.18459040507145450D+01
.65201873686420550D+00
282
/*=================================================================
Example 19.8. Prediction with a Probit Model
No computations
*/=================================================================
/*=================================================================
Example 19.9. Fixed Effects in a Logit Model
No computations
*/=================================================================
/*=================================================================
Example 19.10. The Maximum Score Estimator
*/=================================================================
Probit ; Lhs = Grade ; Rhs = X $
MScore ; Lhs = Grade ; Rhs = X $
/*
+---------------------------------------------+
| Binomial Probit Model
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -7.452319647
2.5424723
-2.931
.0034
GPA
1.625810039
.69388249
2.343
.0191 3.1171875
TUCE
.5172894549E-01 .83890261E-01
.617
.5375 21.937500
PSI
1.426332342
.59503790
2.397
.0165 .43750000
Predicted
Actual
0
1 | Total
0
18
3 |
21
1
3
8 |
11
Total
21
11 |
32
+----------------------------------------------------------------------+
| Maximum Score Estimates of Linear Quantile
|
| Regression Model from Binary Response Data
|
| Quantile
.500
Number of Parameters =
4
|
| Observations input
=
32
Maximum Iterations
=
500
|
| End Game Iterations =
100
Bootstrap Estimates =
20
|
| Normal exit after 100 iterations.
|
| Score functions:
Naive
At theta(0)
Maximum
|
|
Raw
.31250
.31250
.62500
|
|
Normalized
.65625
.65625
.81250
|
| Estimated MSEs from 20 bootstrap samples
|
+----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -.8928565107
.68287204
-1.308
.1910
GPA
.1050498370
.45235084
.232
.8164 3.1171875
TUCE
.5995779004E-02 .80781967E-01
.074
.9408 21.937500
PSI
.4378765050
.30807068
1.421
.1552 .43750000
Frequencies of actual & predicted outcomes
Predicted
Actual
0
1 | Total
0
19
2 |
21
1
4
7 |
11
Total
23
9 |
32
*/
/*=================================================================
Example 19.11. Nonparametric Regression
283
*/=================================================================
Sample ; 1 - 32 $
Mscore ; Lhs = Grade ; Rhs = X $
Npreg ; Lhs = Grade ; Rhs = X ; Pts = 32 ; Smooth = 1 $
Create ; Xb=NPREGXB ; F1 = NPREGYF $
Npreg ; Lhs = Grade ; Rhs = X ; Pts = 32 ; Smooth = .3 $
Create ; Fpt3 = NPREGYF $
Npreg ; Lhs = Grade ; Rhs = X ; Pts = 32 ; Smooth = .5 $
Create ; Fpt5 = NPREGYF $
Plot
; lhs=xb ; rhs=f10,fpt3,fpt5 ;fill
; Yaxis=NonPFhat
; Title=Nonparametric Regression Function$
++
|NonparametricRegression|
|Basedon32observationsand4parameters|
|Smoothingparameter=1.0000|
|Smoothingparameter=.50000|
|Smoothingparameter=.30000|
|Descriptivestatisticsforxb:|
|Mean=.24229Standarddev.=.22992|
|Min.=.51416Max.=.10312|
|Variablescreated:NPREGXB=x(i)b|
|(Obs.132)NPREGYF=FittedY|
|SetSAMPLEbeforeanalyzing.UseLISTtoshow|
|orPlot;Lhs=NPREGXB;Rhs=NPREGYF$|
++
NonPFhat
.6
F10
FPT3
FPT5
.5
.3
.2
.0
-.6
-.5
-.4
-.3
-.2
-.1
.0
.1
.2
XB
284
/*=================================================================
Example 19.12. A Comparison of Binary Choice Estimators
No Computations
*/=================================================================
/*=================================================================
Example 19.13. Gender Economics Course in Liberal Arts Colleges
No Computations. (Data not publicly available)
*/=================================================================
/*=================================================================
Example 19.14. Attributes and Characteristics
No Computations
*/=================================================================
/*=================================================================
Example 19.15. Multinomial Logit Model for Occupational Choice
No Computations
*/=================================================================
/*=================================================================
Example 19.16. Conditional Logit Model for Travel Mode Choice
No Computations
*/=================================================================
/*=================================================================
Example 19.17. The Independence of Irrelevant Alternatives
No Computations
*/=================================================================
/*=================================================================
Example 19.18. Nested Logit Model
*/=================================================================
?
? Examples 19.18, 19.19, and 19.30 are based on the CLOGIT data set
? which is listed in full on the next five pages. The listing is
? in three columns, and as such is not suitable directly as input to
? LIMDEP. The accompanying program file, Ex19_18.lim, contains the
? full data set, prepared for input.
?
/*=================================================================
Example 19.19. A Heteroscedastic Extreme Value Model
*/=================================================================
?
/*=================================================================
Example 19.20. Multinomial Choice Models Based on the Normal
Distribution
*/=================================================================
285
= 7
Hinc Psize
35 1
35 1
35 1
35 1
30 2
30 2
30 2
30 2
40 1
40 1
40 1
40 1
70 3
70 3
70 3
70 3
45 2
45 2
45 2
45 2
20 1
20 1
20 1
20 1
45 1
45 1
45 1
45 1
12 1
12 1
12 1
12 1
40 1
40 1
40 1
40 1
70 2
70 2
70 2
70 2
15 2
15 2
15 2
15 2
35 2
35 2
35 2
35 2
50 4
50 4
50 4
50 4
40 1
40 1
40 1
40 1
26 4
26 4
26 4
26 4
26 1
26 1
26 1
26 1
26 1
26 1
26 1
26 1
6 1
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
20
35
0
69
45
35
0
64
10
53
0
69
20
35
0
64
45
53
0
90
34
35
0
50
34
35
0
15
34
35
0
30
44
53
0
80
34
35
0
45
44
53
0
64
60
53
0
69
2
35
0
69
5
35
0
69
15
35
0
64
45
53
0
69
10
35
0
69
15
35
21
19
17
59
18
14
16
58
28
25
9
61
21
15
13
62
45
17
13
142
71
32
33
120
70
31
33
85
15
12
9
85
90
45
86
75
70
31
39
85
39
35
19
74
43
21
9
59
11
13
13
59
17
25
13
64
32
29
18
59
29
26
9
62
31
19
17
60
15
26
300
399
327
148
305
456
427
93
305
346
316
73
305
395
314
235
465
623
559
105
596
590
577
110
596
590
577
65
361
406
296
140
928
918
902
110
638
632
581
140
664
658
592
179
320
345
321
100
285
417
284
101
300
420
297
90
325
405
327
73
290
395
314
66
295
397
307
132
330
373
54
63
53
75
51
63
62
72
75
78
57
69
54
58
47
98
116
111
98
153
136
96
96
132
135
95
96
92
55
56
41
106
231
185
223
87
140
100
102
106
139
135
109
101
91
74
58
70
42
58
44
70
50
70
45
73
67
73
54
70
73
86
57
70
63
62
50
75
50
67
6
6
6
20
20
20
20
72
72
72
72
6
6
6
6
10
10
10
10
50
50
50
50
50
50
50
50
18
18
18
18
60
60
60
60
45
45
45
45
18
18
18
18
8
8
8
8
6
6
6
6
20
20
20
20
45
45
45
45
70
70
70
70
4
4
4
4
40
40
40
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
286
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
69
10
35
0
64
45
53
0
64
30
53
0
64
55
53
0
30
34
35
0
75
34
35
0
40
34
35
0
30
34
35
0
40
44
53
0
45
44
53
0
20
34
35
0
60
44
53
0
40
34
35
0
50
44
53
0
75
34
35
0
90
44
53
0
85
44
53
0
69
15
35
12
60
23
25
17
62
24
28
11
50
31
14
6
48
25
14
4
147
96
57
28
125
70
31
24
152
73
34
24
116
71
32
29
100
70
31
17
105
35
31
12
106
72
33
44
90
69
30
13
48
31
25
16
69
16
13
4
99
96
57
29
64
74
35
20
105
56
35
8
60
24
25
309
117
325
425
307
184
360
464
427
67
265
393
308
154
360
462
351
100
678
672
629
110
596
590
577
95
600
594
587
180
657
651
629
105
622
616
577
115
622
616
577
190
659
653
592
100
596
590
577
115
365
410
308
85
344
389
315
135
678
672
629
155
678
672
629
85
665
659
587
123
365
430
46
73
58
71
50
90
79
98
76
60
71
73
53
71
80
84
57
158
169
130
96
137
135
95
87
162
138
98
88
136
142
102
97
116
165
125
105
122
130
125
100
127
143
104
108
105
160
120
101
60
70
69
49
82
68
72
52
114
169
130
97
88
177
137
115
118
156
135
97
73
64
71
40
35
35
35
35
40
40
40
40
4
4
4
4
15
15
15
15
26
26
26
26
26
26
26
26
70
70
70
70
70
70
70
70
45
45
45
45
8
8
8
8
70
70
70
70
26
26
26
26
50
50
50
50
10
10
10
10
30
30
30
30
60
60
60
60
30
30
30
30
30
30
30
1
1
1
1
1
2
2
2
2
3
3
3
3
4
4
4
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
1
1
1
1
2
2
2
2
1
1
1
1
3
3
3
3
1
1
1
1
2
2
2
2
4
4
4
4
1
1
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
64
30
53
0
64
15
53
0
69
30
35
0
69
45
35
0
64
10
53
0
69
40
35
0
64
50
53
0
69
40
35
0
64
25
53
0
64
25
53
0
69
5
35
0
64
75
53
0
69
34
10
0
64
44
53
0
69
34
45
0
64
40
53
0
64
45
53
0
64
40
53
13 332
58
90
22 340
25 417
9 334
45
73
22 290
13 395
5 314
108 170
31 875
44 887
50 884
110 249
22 890
47 955
38 990
115 138
44 830
50 869
18 862
117 147
59 790
48 885
38 883
88 119
78 775
43 840
16 855
105 196
43 895
44 919
50 935
120 333
28 870
52 890
38 921
103 146
36 875
43 943
19 887
103 138
22 800
43 821
36 846
116 164
89 685
47 875
19 874
103 129
88 925
30 790
50 887
109 230
101 1104
56 1094
26 960
108 177
92 907
39 850
52 865
92 161
73 792
46 920
16 887
119 161
75 765
51 869
19 898
109 190
24 399
46 951
49
72
74
88
60
56
66
73
53
126
126
140
146
137
119
151
146
136
170
182
149
133
145
144
134
106
196
170
146
126
140
144
152
170
160
187
178
125
169
186
154
118
109
132
128
141
193
180
152
117
189
116
146
144
269
222
172
127
191
131
146
117
193
186
151
143
191
182
155
138
85
190
30
50
50
50
50
6
6
6
6
30
30
30
30
12
12
12
12
36
36
36
36
30
30
30
30
35
35
35
35
6
6
6
6
6
6
6
6
8
8
8
8
6
6
6
6
12
12
12
12
30
30
30
30
35
35
35
35
35
35
35
35
60
60
60
60
60
60
60
60
12
12
12
1
2
2
2
2
4
4
4
4
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
3
3
3
3
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
2
2
2
2
1
1
1
1
2
2
2
2
1
1
1
1
3
3
3
3
2
2
2
2
2
2
2
287
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
0
0
1
0
1
0
0
0
0
0
0
69
30
35
0
69
25
35
0
69
75
35
0
64
30
53
0
64
50
53
0
69
30
35
0
64
44
53
0
64
44
53
0
69
34
30
0
69
34
60
0
64
44
53
0
69
1
35
0
69
25
35
0
25
44
53
0
69
10
35
0
64
44
53
0
69
10
35
0
64
44
53
27 897
111 108
30 760
50 867
47 844
104 246
23 830
45 1068
41 978
104 200
23 835
43 846
40 927
124 160
82 850
54 893
19 886
103 145
73 840
43 892
50 894
103 125
80 800
42 844
38 861
113 163
51 948
49 938
26 720
76 147
63 918
44 908
10 1440
108 163
89 905
43 785
35 879
127 193
109 888
52 1025
50 892
44 100
25 351
20 361
5 180
59
98
11 320
13 413
17 332
59 114
60 337
25 423
8 335
65 140
69 596
30 590
16 577
60
67
37 285
28 400
14 320
59 118
17 349
14 359
5 240
61
72
18 305
27 396
12 332
59 118
32 349
26 359
163
122
113
144
139
131
113
161
147
126
114
135
141
148
211
189
153
125
200
178
186
116
167
134
132
137
195
191
135
98
203
182
228
125
187
128
130
148
205
163
147
59
78
75
32
69
46
57
53
72
97
71
44
86
160
120
104
67
68
72
49
77
70
68
41
69
51
70
48
77
85
80
12
10
10
10
10
10
10
10
10
15
15
15
15
10
10
10
10
8
8
8
8
30
30
30
30
20
20
20
20
70
70
70
70
20
20
20
20
60
60
60
60
70
70
70
70
8
8
8
8
30
30
30
30
70
70
70
70
60
60
60
60
20
20
20
20
15
15
15
15
30
30
30
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
2
2
2
2
5
5
5
5
1
1
1
1
1
1
1
1
4
4
4
4
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
2
2
2
2
1
1
1
1
2
2
2
1
0
1
0
0
0
1
0
0
0
1
0
0
0
0
0
1
1
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
1
0
0
0
0
0
64
20
53
0
64
20
53
0
69
10
35
0
64
44
53
0
30
44
53
0
45
44
53
0
30
34
35
0
69
34
5
0
45
34
35
0
64
44
40
0
64
44
53
0
69
34
15
0
64
44
53
0
69
34
35
0
64
44
53
0
64
44
53
0
69
34
30
0
69
34
35
6 265
60
74
40 262
26 389
10 315
44
93
30 291
19 346
4 316
58 124
30 340
25 427
14 364
84 108
70 596
31 590
15 360
145
90
31 343
25 388
13 296
121 100
92 926
47 916
20 885
84 180
72 707
33 701
26 626
61 146
17 409
31 300
13 350
180 160
89 985
44 975
39 896
94 231
79 949
32 1110
13 942
92 203
77 961
46 951
17 780
59 111
31 376
25 360
23 351
75 153
64 900
45 890
13 720
58
99
16 366
13 411
13 300
110 153
91 874
46 864
21 960
108 187
90 932
45 922
20 1440
104 179
89 978
28 795
40 904
108 180
89 901
44 891
46
71
80
85
58
58
74
72
52
71
67
71
54
100
160
120
70
158
83
84
58
136
233
186
154
103
149
109
94
77
61
64
51
197
196
150
136
129
223
201
156
123
223
190
135
71
72
64
61
99
201
180
122
68
55
57
46
133
223
177
167
136
231
185
238
123
195
114
138
128
187
141
30
26
26
26
26
35
35
35
35
12
12
12
12
70
70
70
70
50
50
50
50
40
40
40
40
70
70
70
70
10
10
10
10
26
26
26
26
50
50
50
50
70
70
70
70
30
30
30
30
50
50
50
50
20
20
20
20
32
32
32
32
27
27
27
27
30
30
30
30
35
35
35
2
2
2
2
2
4
4
4
4
1
1
1
1
2
2
2
2
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
3
3
3
3
3
3
3
3
1
1
1
1
5
5
5
5
1
1
1
1
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
288
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
64
44
53
0
64
44
53
0
64
44
53
0
69
34
35
0
64
44
53
0
60
44
53
0
30
44
53
0
55
34
35
0
40
34
35
0
69
34
40
0
69
34
20
0
90
34
35
0
10
34
35
0
25
44
53
0
99
34
35
0
30
34
35
0
35
44
53
0
69
34
15
34
78
66
43
11
60
32
26
8
78
67
44
12
67
38
32
12
108
90
45
19
108
32
26
7
58
32
26
8
69
43
37
13
66
31
25
18
57
31
18
13
129
67
54
38
151
96
51
35
70
34
28
22
75
15
12
7
110
92
47
45
94
89
44
58
95
45
43
23
104
89
38
720
146
903
893
870
144
404
449
270
175
932
922
720
108
370
415
240
200
944
934
720
80
344
389
315
90
506
551
402
115
392
437
268
105
372
417
327
67
355
245
320
185
933
820
894
95
895
885
844
85
351
396
307
100
348
393
290
260
934
924
816
195
943
933
912
155
930
920
860
178
992
675
112
100
203
178
143
82
93
94
49
105
208
183
121
79
78
77
38
139
234
187
128
120
84
85
55
72
109
110
69
81
85
84
42
77
71
70
54
65
69
45
48
149
168
143
135
161
193
147
127
80
72
71
55
90
68
72
51
138
193
147
134
115
191
145
157
119
186
183
153
123
197
111
35
40
40
40
40
60
60
60
60
40
40
40
40
70
70
70
70
70
70
70
70
30
30
30
30
35
35
35
35
60
60
60
60
45
45
45
45
45
45
45
45
6
6
6
6
36
36
36
36
20
20
20
20
20
20
20
20
26
26
26
26
29
29
29
29
8
8
8
8
32
32
32
1
4
4
4
4
2
2
2
2
4
4
4
4
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
1
0
1
0
0
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
0
0
1
0
0
0
1
0
0
64
44
30
0
64
44
53
0
64
44
30
0
69
34
35
0
64
10
53
0
64
44
53
0
64
44
53
0
69
34
15
0
69
34
25
0
64
44
53
0
64
44
53
0
69
34
35
0
69
34
5
0
69
34
45
0
64
44
53
0
69
30
35
0
69
30
35
0
64
99
53
39 900
103 170
88 889
35 770
18 905
86 167
75 972
44 962
13 870
108 139
90 862
36 780
18 875
59 106
31 372
25 417
13 300
58 124
35 380
13 427
8 364
107 153
89 880
44 870
2 660
86 143
74 880
43 870
16 660
108 196
91 967
35 935
38 903
103 149
45 892
25 730
37 882
103 160
89 987
44 977
34 660
114 161
60 1031
58 1021
19 720
107 150
91 914
46 904
36 750
118 137
96 904
65 850
64 859
102 101
87 870
35 800
35 825
85 101
73 870
42 860
12 600
107 158
61 780
45 901
54 853
113 244
67 845
49 893
47 868
84 215
37 885
46 966
137
129
222
152
155
112
222
190
145
129
220
154
151
71
71
70
46
77
92
78
63
131
222
176
102
108
207
175
116
129
196
136
136
119
142
104
133
127
239
192
134
138
217
213
128
123
190
144
117
132
194
157
157
113
182
122
125
101
205
173
103
125
146
143
147
140
158
146
141
117
171
193
32
45
45
45
45
45
45
45
45
26
26
26
26
60
60
60
60
10
10
10
10
45
45
45
45
60
60
60
60
60
60
60
60
8
8
8
8
60
60
60
60
12
12
12
12
45
45
45
45
50
50
50
50
26
26
26
26
35
35
35
35
12
12
12
12
15
15
15
15
12
12
12
1
2
2
2
2
3
3
3
3
2
2
2
2
1
1
1
1
2
2
2
2
2
2
2
2
3
3
3
3
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
3
3
3
3
1
1
1
1
1
1
1
1
4
4
4
289
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
64
25
53
0
69
15
35
0
69
45
35
0
69
30
35
0
64
10
53
0
64
10
53
0
45
34
35
0
45
34
35
0
60
34
35
0
60
44
53
0
60
34
35
0
60
44
53
0
45
44
53
0
75
44
53
0
30
34
35
0
90
44
53
0
45
44
53
0
60
34
35
10 921
94 163
68 755
47 895
16 879
112 161
21 797
45 876
47 852
103 166
20 820
43 836
35 886
107 152
33 755
44 882
48 845
103 164
41 730
43 925
19 898
143 166
83 825
70 896
50 911
94 270
91 916
46 906
49 872
138 115
60 880
58 870
47 888
102 250
112 997
67 952
43 971
151 255
91 941
46 931
21 959
111 205
97 888
52 878
49 855
70
95
31 360
25 405
7 335
74
70
26 361
21 406
4 315
165 180
98 967
53 922
26 947
93 175
96 1030
51 1020
54 967
71 115
31 385
25 430
7 332
75
75
33 418
28 463
5 291
81
70
32 341
26 386
150
119
183
183
149
129
108
140
140
121
109
134
131
124
115
140
140
128
152
183
155
168
208
206
188
123
190
144
144
150
156
153
143
129
220
170
148
190
234
187
166
133
193
147
142
93
85
86
58
85
81
82
52
192
245
193
170
112
208
162
159
89
89
90
57
96
96
98
49
89
69
68
12
35
35
35
35
26
26
26
26
6
6
6
6
4
4
4
4
40
40
40
40
40
40
40
40
60
60
60
60
4
4
4
4
50
50
50
50
60
60
60
60
70
70
70
70
40
40
40
40
35
35
35
35
60
60
60
60
60
60
60
60
50
50
50
50
40
40
40
40
60
60
60
4
3
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
2
2
2
2
3
3
3
3
2
2
2
2
1
1
1
1
2
2
2
2
3
3
3
3
1
1
1
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
1
0
0
0
75
34
35
0
64
44
53
0
64
44
53
0
64
44
53
0
69
34
35
0
64
44
53
0
64
44
53
0
69
34
35
0
64
44
53
0
64
44
53
0
69
34
50
0
69
34
15
0
64
44
15
0
69
34
35
0
69
34
30
0
69
34
15
0
69
34
15
0
90
44
53
13 307
94
95
33 367
27 412
14 314
70 158
61 778
34 772
11 470
65 145
54 674
33 668
8 560
71 133
59 625
32 619
8 510
81 139
71 698
32 692
33 600
65 154
53 621
32 615
9 535
58 148
48 646
32 640
5 470
81
95
70 610
31 604
30 440
71 145
59 658
32 652
10 590
82 159
71 765
32 759
13 490
61
73
33 350
26 227
14 314
60 133
31 397
21 240
14 351
81 129
35 677
31 565
12 588
59 117
32 397
26 442
17 180
111 276
93 1047
35 860
42 1008
59
88
30 361
21 295
13 299
59 114
31 389
21 243
13 334
55 115
72 602
33 596
46
104
73
72
48
93
179
151
82
87
156
135
93
91
153
126
85
96
147
107
98
89
147
125
90
80
145
129
76
91
136
96
78
93
159
131
100
106
187
147
87
69
71
51
48
74
74
47
52
101
138
117
101
72
75
74
37
141
207
128
151
68
70
53
45
71
73
47
49
72
163
123
60
20
20
20
20
50
50
50
50
70
70
70
70
50
50
50
50
26
26
26
26
45
45
45
45
45
45
45
45
30
30
30
30
40
40
40
40
50
50
50
50
35
35
35
35
34
34
34
34
8
8
8
8
30
30
30
30
32
32
32
32
26
26
26
26
42
42
42
42
50
50
50
1
1
1
1
1
3
3
3
3
4
4
4
4
3
3
3
3
1
1
1
1
4
4
4
4
6
6
6
6
1
1
1
1
3
3
3
3
2
2
2
2
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
290
0
1
0
0
0
0
0
0
1
0
0
0
1
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
0
1
1
0
0
0
1
0
0
0
0
0
1
0
0
1
0
15
44
53
0
69
34
35
0
69
34
35
0
64
20
53
0
64
50
53
0
64
30
53
0
64
44
15
0
15
34
35
0
10
44
53
0
69
34
35
0
69
34
35
0
69
34
35
0
30
34
35
0
20
34
35
0
64
44
30
0
64
10
24
87
31
25
7
62
39
33
12
59
31
25
14
51
61
22
6
64
41
15
9
58
21
24
7
71
58
35
11
50
15
12
13
61
24
19
4
59
31
25
13
58
31
25
18
62
19
16
18
93
33
27
13
76
33
27
13
100
49
48
14
48
21
589
110
348
393
320
76
377
422
300
121
386
431
270
90
350
405
327
215
420
385
321
74
295
389
315
119
617
615
586
75
361
406
315
80
350
395
314
100
372
417
210
73
324
334
240
184
454
464
225
85
365
410
308
95
344
389
315
190
678
430
629
63
255
113
104
84
85
56
71
80
79
45
72
73
72
43
64
114
83
56
97
104
73
58
69
66
83
55
89
152
128
100
58
55
56
47
73
77
79
52
70
71
70
36
66
66
61
44
82
68
66
42
102
72
71
46
86
70
69
47
129
152
113
109
58
60
50
70
70
70
70
30
30
30
30
26
26
26
26
26
26
26
26
18
18
18
18
35
35
35
35
50
50
50
50
4
4
4
4
30
30
30
30
45
45
45
45
60
60
60
60
4
4
4
4
30
30
30
30
60
60
60
60
4
4
4
4
18
18
1
2
2
2
2
1
1
1
1
1
1
1
1
3
3
3
3
2
2
2
2
2
2
2
2
3
3
3
3
1
1
1
1
4
4
4
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
3
3
0
0
0
1
0
0
0
0
0
1
1
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
0
0
0
1
0
0
0
1
53
0
64
10
53
0
69
34
35
0
30
34
35
0
5
44
53
0
5
44
53
0
64
44
16
0
69
34
35
0
69
34
5
0
69
34
10
0
69
34
30
0
69
34
35
0
45
34
35
0
69
34
50
0
69
34
35
0
64
44
53
0
13
4
58
30
13
6
59
30
24
10
111
71
32
27
64
30
24
7
60
24
19
3
97
76
38
15
91
77
38
29
59
16
14
17
60
34
37
13
107
89
35
37
81
69
30
30
126
70
31
32
59
15
29
13
81
35
31
27
66
54
33
12
397
324
93
315
346
316
94
361
406
270
105
596
590
577
80
348
393
291
85
379
424
337
188
825
810
803
117
630
624
540
114
378
370
335
66
352
250
307
144
879
775
868
124
605
599
720
135
596
590
577
86
360
265
300
124
605
599
510
140
670
664
540
73
53
72
78
65
54
69
70
68
39
122
136
96
90
76
83
84
51
73
81
83
54
125
201
161
137
104
145
106
88
72
57
54
53
67
72
64
46
123
184
119
131
94
135
95
108
141
135
95
95
68
54
57
46
94
100
96
82
87
156
134
94
18
18
15
15
15
15
26
26
26
26
40
40
40
40
70
70
70
70
45
45
45
45
26
26
26
26
35
35
35
35
4
4
4
4
20
20
20
20
45
45
45
45
40
40
40
40
40
40
40
40
2
2
2
2
20
20
20
20
70
70
70
70
3
3
2
2
2
2
1
1
1
1
1
1
1
1
2
2
2
2
4
4
4
4
3
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
4
291
/*=================================================================
Example 19.18. Nested Logit Model
*/=================================================================
Read ; Nobs=840 ; Nvar = 7
; Names=2 $
Mode TTME Invc Invt GC Hinc Psize
0 69
59 100
70
35 1
0 34
31 372
71
35 1
0 35
25 417
70
35 1
1
0
10 180
30
35 1
... total 840 observations in 210 groups of 4 ...
?---------------------------------------------------------------Create ; AASC=Dmy(4,1)
; TASC=Dmy(4,2)
; BASC=Dmy(4,3)
; CASC=Dmy(4,4) $
Create ; HincAir = Hinc*AASC $
?---------------------------------------------------------------? Unconditional
?---------------------------------------------------------------Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Rhs = AASC,TASC,BASC,GC,TTME,HincAir $
Calc
; List ; L0 = LogL $
?---------------------------------------------------------------? FIML
?---------------------------------------------------------------Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Tree= Fly(Air),Ground(Train,Bus,Car)
; Model:
U(Air,Train,Bus,Car)=at*TASC+ab*BASC+bg*GC+bt*TTME /
U(Fly,Ground)=aa*AASC + g*HincAir
; ShowTree ; Describe ; Effects:GC(*) $
Calc
; List ; LFIML = LogL $
Calc
; List ; LRTest = 2*(LFIML - L0) $
Matrix ; List ; tau = b(7:8) ; Vtau = Part(Varb,7,8,7,8) $
Wald
; Fn1=tauF-1 ; Fn2=tauG-1
; Start = Tau ; Var = Vtau ; Labels = tauF,tauG $
?---------------------------------------------------------------? LIML
?---------------------------------------------------------------Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; IVB=IncVlu ; Conditional
; Tree= Fly(Air),Ground(Train,Bus,Car)
; Model:
U(Air,Train,Bus,Car)=at*TASC+ab*BASC+bg*GC+bt*TTME /
U(Fly,Ground)=aa*AASC + g*HincAir $
Create ; IVAir = AASC*IncVlu
; IVGround = (1-AASC) * IncVlu $
Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Sequential ; Maxit=400
; Tree= Fly(Air),Ground(Train,Bus,Car)
; Model:
U(Air,Train,Bus,Car)=at*TASC+ab*BASC+bg*GC+bt*TTME /
U(Fly,Ground)=aa*AASC + g*HincAir + tauA*IVAir + tauG*IvGround $
/*
292
?---------------------------------------------------------------?---------------------------------------------------------------? Unconditional
?---------------------------------------------------------------?---------------------------------------------------------------+---------------------------------------------+
| Discrete choice (multinomial logit) model
|
| Maximum Likelihood Estimates
|
| Dependent variable
Choice
|
| Weighting variable
ONE
|
| Number of observations
210
|
| Iterations completed
6
|
| Log likelihood function
-199.1284
|
| Log-L for Choice
model =
-199.1284
|
| R2=1-LogL/LogL* Log-L fncn R-sqrd RsqAdj |
| No coefficients
-291.1218 .31600 .30942 |
| Constants only
-283.7588 .29825 .29150 |
| Response data are given as ind. choice.
|
| Number of obs.=
210, skipped
0 bad obs. |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
AASC
5.207443299
.77905514
6.684
.0000
TASC
3.869042702
.44312685
8.731
.0000
BASC
3.163194212
.45026593
7.025
.0000
GC
-.1550152532E-01 .44079931E-02
-3.517
.0004
TTME
-.9612479610E-01 .10439847E-01
-9.207
.0000
HINCAIR
.1328702625E-01 .10262407E-01
1.295
.1954
L0
= -.19912836871598160D+03
?---------------------------------------------------------------?---------------------------------------------------------------? FIML
?---------------------------------------------------------------?---------------------------------------------------------------Tree Structure Specified for the Nested Logit Model
Sample proportions are marginal, not conditional.
Choices marked with * are excluded for the IIA test.
----------------+----------------+----------------+----------------+------+--Trunk
(prop.)|Limb
(prop.)|Branch
(prop.)|Choice
(prop.)|Weight|IIA
----------------+----------------+----------------+----------------+------+--Trunk{1} 1.00000|Lmb[1|1] 1.00000|FLY
.27619|AIR
.27619| 1.000|
|
|GROUND
.72381|TRAIN
.30000| 1.000|
|
|
|BUS
.14286| 1.000|
|
|
|CAR
.28095| 1.000|
----------------+----------------+----------------+----------------+------+---
293
+---------------------------------------------+
| Start values obtained using non-nested mode |
| Maximum Likelihood Estimates
|
| Dependent variable
Choice
|
| Weighting variable
ONE
|
| Number of observations
210
|
| Iterations completed
5
|
| Log likelihood function
-378.5920
|
| Log-L for Choice
model =
-260.1975
|
| R2=1-LogL/LogL* Log-L fncn R-sqrd RsqAdj |
| No coefficients
-312.5500 .16750 .16218 |
| Constants only
-283.7588 .08303 .07717 |
| Log-L for Branch
model =
-118.3945
|
| Response data are given as ind. choice.
|
| Number of obs.=
210, skipped
0 bad obs. |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Model for Choice Among Alternatives
AT
.7777869968
.20792992
3.741
.0002
AB
-.1307604798
.22872416
-.572
.5675
BG
-.1773795033E-01 .40547008E-02
-4.375
.0000
BT
-.1340138348E-01 .31790445E-02
-4.216
.0000
Model for Choice Among Branches
AA
-1.922542151
.35420335
-5.428
.0000
G
.2612090765E-01 .81743148E-02
3.195
.0014
+---------------------------------------------+
| FIML: Nested Multinomial Logit Model
|
| Dependent variable
MODE
|
| Number of observations
840
|
| Iterations completed
27
|
| Log likelihood function
-193.6561
|
| Restricted log likelihood
-312.5500
|
| Chi-squared
237.7877
|
| Degrees of freedom
8
|
| Significance level
.0000000
|
| R2=1-LogL/LogL* Log-L fncn R-sqrd RsqAdj |
| No coefficients
-312.5500 .38040 .37243 |
| Constants only
-283.7588 .31753 .30875 |
| At start values
-287.6816 .32684 .31818 |
| Response data are given as ind. choice.
|
| Number of obs.=
210, skipped
0 bad obs. |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Attributes in the Utility Functions (beta)
AT
5.064602771
.66202159
7.650
.0000
AB
4.096314801
.61515554
6.659
.0000
BG
-.3158748258E-01 .81563642E-02
-3.873
.0001
BT
-.1126174878
.14129116E-01
-7.971
.0000
Attributes of Branch Choice Equations (alpha)
AA
3.540865214
1.2081272
2.931
.0034
G
.1533131683E-01 .93813382E-02
1.634
.1022
IV parameters, tau(j|i,l),sigma(i|l),phi(l)
FLY
.5860093848
.14062118
4.167
.0000
GROUND
.3889619203
.12366583
3.145
.0017
LRTEST = .10944440274998270D+02
294
Matrix TAU
has 2 rows and 1 columns.
+-------------1| .5860094D+00
2| .3889619D+00
Matrix VTAU
has 2 rows and 2 columns.
+---------------------------1| .1977432D-01 .9621190D-02
2| .9621190D-02 .1529324D-01
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions and joint test of
|
| nonlinear restrictions.
|
| Wald Statistic
=
24.47765
|
| Prob. from Chi-squared[ 2] =
.00000
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) -.4139906152
.14062118
-2.944
.0032
Fncn( 2) -.6110380797
.12366583
-4.941
.0000
+-------------------------------------------------------------------------+
:
Descriptive Statistics for Alternative AIR
:
|
Utility Function
|
|
58.0 observs. |
|
Coefficient
| All
210.0 obs.|that chose AIR
|
| Name
Value Variable : Mean
Std. Dev.|Mean
Std. Dev. |
| ------------------- -------- | -------------------+------------------- |
| AT
5.0646 TASC
|
.000
.000|
.000
.000 |
| AB
4.0963 BASC
|
.000
.000|
.000
.000 |
| BG
-.0316 GC
| 102.648
30.575| 113.552
33.198 |
| BT
-.1126 TTME
|
61.010
15.719|
46.534
24.389 |
:
Descriptive Statistics for Alternative TRAIN
:
|
Utility Function
|
|
63.0 observs. |
|
Coefficient
| All
210.0 obs.|that chose TRAIN
|
| Name
Value Variable : Mean
Std. Dev.|Mean
Std. Dev. |
| ------------------- -------- | -------------------+------------------- |
| AT
5.0646 TASC
|
1.000
.000|
1.000
.000 |
| AB
4.0963 BASC
|
.000
.000|
.000
.000 |
| BG
-.0316 GC
| 130.200
58.235| 106.619
49.601 |
| BT
-.1126 TTME
|
35.690
12.279|
28.524
19.354 |
:
Descriptive Statistics for Alternative BUS
:
|
Utility Function
|
|
30.0 observs. |
|
Coefficient
| All
210.0 obs.|that chose BUS
|
| Name
Value Variable : Mean
Std. Dev.|Mean
Std. Dev. |
| ------------------- -------- | -------------------+------------------- |
| AT
5.0646 TASC
|
.000
.000|
.000
.000 |
| AB
4.0963 BASC
|
1.000
.000|
1.000
.000 |
| BG
-.0316 GC
| 115.257
44.934| 108.133
43.244 |
| BT
-.1126 TTME
|
41.657
12.077|
25.200
14.919 |
:
Descriptive Statistics for Alternative CAR
:
|
Utility Function
|
|
59.0 observs. |
|
Coefficient
| All
210.0 obs.|that chose CAR
|
| Name
Value Variable : Mean
Std. Dev.|Mean
Std. Dev. |
| ------------------- -------- | -------------------+------------------- |
| AT
5.0646 TASC
|
.000
.000|
.000
.000 |
| AB
4.0963 BASC
|
.000
.000|
.000
.000 |
| BG
-.0316 GC
|
95.414
46.827|
89.085
49.833 |
| BT
-.1126 TTME
|
.000
.000|
.000
.000 |
+-------------------------------------------------------------------------+
295
+-----------------------------------------------------------+
| Partial effects = average over observations
|
|
|
| dlnP[alt=k,br=j,lmb=i,tr=l]
|
| ---------------------------- = D(m:K,J,I,L) = delta(m)*F |
| dx(m):alt=K,br=J,lmb=I,tr=L]
|
|
|
| delta(m) = coefficient on x(m) in U(K:J,I,L)
|
| F = (l=L) (i=I) (j=J) [(k=K)-P(K:JIL)]
|
| + (l=L) (i=I) [(j=J)-P(J:IL)] P(K:JIL)t(J:IL)
|
| + (l=L) [(i=I)-P(I:L)] P(J:IL) P(K:JIL)t(J:IL)s(I:L)
|
| + [(l=L)-P(L)] P(I:L) P(J:IL) P(K:JIL)t(J:IL)s(I:L)f(L) |
|
|
| P(K|JIL)=Prob[choice=K |branch=J,limb=I,trunk=L]
|
| P(J|IL), P(IL), P(L) defined likewise.
|
| (n=N) = 1 if n=N, 0 else, for n=k,j,i,l and N=K,J,I,L.
|
| Elasticity = x(l) * D(l:K,J,I)
|
| Marginal effect = P(KJIL)*D = P(K:JIL)P(J:IL)P(I:L)P(L)D |
| F is decomposed into the 4 parts in the tables.
|
+-----------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice AIR
|
| Effects on probabilities of all choices in the model:
|
| * indicates direct Elasticity effect of the attribute.
|
|
Decomposition of Effect
Total |
|
Trunk
Limb
Branch
Choice
Effect|
| Trunk=Trunk{1}
|
| Limb=Lmb[1|1]
|
|
Branch=FLY
|
| *
Choice=AIR
.000
.000 -1.377
.000
-1.377 |
|
Branch=GROUND
|
|
Choice=TRAIN
.000
.000
.523
.000
.523 |
|
Choice=BUS
.000
.000
.523
.000
.523 |
|
Choice=CAR
.000
.000
.523
.000
.523 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice TRAIN
|
| Effects on probabilities of all choices in the model:
|
| * indicates direct Elasticity effect of the attribute.
|
|
Decomposition of Effect
Total |
|
Trunk
Limb
Branch
Choice
Effect|
| Trunk=Trunk{1}
|
| Limb=Lmb[1|1]
|
|
Branch=FLY
|
|
Choice=AIR
.000
.000
.377
.000
.377 |
|
Branch=GROUND
|
| *
Choice=TRAIN
.000
.000
-.125 -2.820
-2.945 |
|
Choice=BUS
.000
.000
-.125
1.293
1.167 |
|
Choice=CAR
.000
.000
-.125
1.293
1.167 |
+-----------------------------------------------------------------+
296
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice BUS
|
| Effects on probabilities of all choices in the model:
|
| * indicates direct Elasticity effect of the attribute.
|
|
Decomposition of Effect
Total |
|
Trunk
Limb
Branch
Choice
Effect|
| Trunk=Trunk{1}
|
| Limb=Lmb[1|1]
|
|
Branch=FLY
|
|
Choice=AIR
.000
.000
.196
.000
.196 |
|
Branch=GROUND
|
|
Choice=TRAIN
.000
.000
-.064
.668
.604 |
| *
Choice=BUS
.000
.000
-.064 -2.973
-3.037 |
|
Choice=CAR
.000
.000
-.064
.668
.604 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice CAR
|
| Effects on probabilities of all choices in the model:
|
| * indicates direct Elasticity effect of the attribute.
|
|
Decomposition of Effect
Total |
|
Trunk
Limb
Branch
Choice
Effect|
| Trunk=Trunk{1}
|
| Limb=Lmb[1|1]
|
|
Branch=FLY
|
|
Choice=AIR
.000
.000
.337
.000
.337 |
|
Branch=GROUND
|
|
Choice=TRAIN
.000
.000
-.175
1.318
1.142 |
|
Choice=BUS
.000
.000
-.175
1.318
1.142 |
| *
Choice=CAR
.000
.000
-.175 -1.696
-1.872 |
+-----------------------------------------------------------------+
?---------------------------------------------------------------?---------------------------------------------------------------? First step of sequential
?---------------------------------------------------------------?---------------------------------------------------------------+---------------------------------------------+
| Conditional logit model for choices only
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Model for Choice Among Alternatives
AT
4.463667918
.64053383
6.969
.0000
AB
3.104743906
.60901921
5.098
.0000
BG
-.6368191629E-01 .10042373E-01
-6.341
.0000
BT
-.6987782750E-01 .14880300E-01
-4.696
.0000
297
298
+---------------------------------------------+
| Heteroskedastic Extreme Value Model
|
| Number of observations
840
|
| Iterations completed
49
|
| Log likelihood function
-195.6605
|
| Restricted log likelihood
-291.1218
|
| Degrees of freedom
9
|
| Response data are given as ind. choice.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Attributes in the Utility Functions (beta)
AASC
7.832613245
10.950710
.715
.4744
TASC
7.171796833
9.1351209
.785
.4324
BASC
6.865474896
8.8290904
.778
.4368
GC
-.5155873099E-01 .69439362E-01
-.743
.4578
TTME
-.1968357725
.28826209
-.683
.4947
HINCAIR
.4023973693E-01 .60667280E-01
.663
.5071
Scale Parameters of Extreme Value Distns.
s_AIR
.2485151009
.36917696
.673
.5008
s_TRAIN
.2594728814
.41877591
.620
.5355
s_BUS
.6065447951
1.0399765
.583
.5597
s_CAR
1.000000000
........(Fixed Parameter)........
s_AIR
5.160852582
7.6666081
.673
.5008
s_TRAIN
4.942904989
7.9775949
.620
.5355
s_BUS
2.114517857
3.6255342
.583
.5597
s_CAR
1.282549800
........(Fixed Parameter)........
+---------------------------------------------+
| Heteroskedastic Extreme Value Model
|
| Log likelihood function
-200.3791
|
| Response data are given as ind. choice.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Attributes in the Utility Functions (beta)
AASC
2.972882222
.99511560
2.987
.0028
TASC
4.049855081
.49357307
8.205
.0000
BASC
3.041937384
.42851620
7.099
.0000
GC
-.2840881580E-01 .57954841E-02
-4.902
.0000
TTME
-.8279350315E-01 .57583453E-02 -14.378
.0000
HINCAIR
.2831068885E-01 .18590319E-01
1.523
.1278
Scale Parameters of Extreme Value Distns.
s_AIR
.4958593162
.12406770
3.997
.0001
s_TRAIN
1.000000000
........(Fixed Parameter)........
s_BUS
1.000000000
........(Fixed Parameter)........
s_CAR
1.000000000
........(Fixed Parameter)........
s_AIR
s_TRAIN
s_BUS
s_CAR
2.586519519
1.282549800
1.282549800
1.282549800
.64716650
3.997
.0001
........(Fixed Parameter)........
........(Fixed Parameter)........
........(Fixed Parameter)........
299
300
Comparison of Elasticities
==========================
Multinomial Logit
==========================
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice AIR
|
| *
Choice=AIR
.000
.000
.000 -1.136
-1.136 |
|
Choice=TRAIN
.000
.000
.000
.456
.456 |
|
Choice=BUS
.000
.000
.000
.456
.456 |
|
Choice=CAR
.000
.000
.000
.456
.456 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice TRAIN
|
|
Choice=AIR
.000
.000
.000
.498
.498 |
| *
Choice=TRAIN
.000
.000
.000 -1.520
-1.520 |
|
Choice=BUS
.000
.000
.000
.498
.498 |
|
Choice=CAR
.000
.000
.000
.498
.498 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice BUS
|
|
Choice=AIR
.000
.000
.000
.238
.238 |
|
Choice=TRAIN
.000
.000
.000
.238
.238 |
| *
Choice=BUS
.000
.000
.000 -1.549
-1.549 |
|
Choice=CAR
.000
.000
.000
.238
.238 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice CAR
|
|
Choice=AIR
.000
.000
.000
.418
.418 |
|
Choice=TRAIN
.000
.000
.000
.418
.418 |
|
Choice=BUS
.000
.000
.000
.418
.418 |
| *
Choice=CAR
.000
.000
.000 -1.061
-1.061 |
+-----------------------------------------------------------------+
301
Comparison of Elasticities
==========================
Nested Logit
==========================
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice AIR
|
|
Branch=FLY
|
| *
Choice=AIR
.000
.000 -1.377
.000
-1.377 |
|
Branch=GROUND
|
|
Choice=TRAIN
.000
.000
.523
.000
.523 |
|
Choice=BUS
.000
.000
.523
.000
.523 |
|
Choice=CAR
.000
.000
.523
.000
.523 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice TRAIN
|
|
Branch=FLY
|
|
Choice=AIR
.000
.000
.377
.000
.377 |
|
Branch=GROUND
|
| *
Choice=TRAIN
.000
.000
-.125 -2.820
-2.945 |
|
Choice=BUS
.000
.000
-.125
1.293
1.167 |
|
Choice=CAR
.000
.000
-.125
1.293
1.167 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice BUS
|
|
Branch=FLY
|
|
Choice=AIR
.000
.000
.196
.000
.196 |
|
Branch=GROUND
|
|
Choice=TRAIN
.000
.000
-.064
.668
.604 |
| *
Choice=BUS
.000
.000
-.064 -2.973
-3.037 |
|
Choice=CAR
.000
.000
-.064
.668
.604 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice CAR
|
|
Branch=FLY
|
|
Choice=AIR
.000
.000
.337
.000
.337 |
|
Branch=GROUND
|
|
Choice=TRAIN
.000
.000
-.175
1.318
1.142 |
|
Choice=BUS
.000
.000
-.175
1.318
1.142 |
| *
Choice=CAR
.000
.000
-.175 -1.696
-1.872 |
+-----------------------------------------------------------------+
302
Comparison of Elasticities
=============================
Heteroscedastic Extreme Value
=============================
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice AIR
|
| *
Choice=AIR
.000
.000
.000 -1.040
-1.040 |
|
Choice=TRAIN
.000
.000
.000
.277
.277 |
|
Choice=BUS
.000
.000
.000
.688
.688 |
|
Choice=CAR
.000
.000
.000
.690
.690 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice TRAIN
|
|
Choice=AIR
.000
.000
.000
.367
.367 |
| *
Choice=TRAIN
.000
.000
.000 -1.495
-1.495 |
|
Choice=BUS
.000
.000
.000
.858
.858 |
|
Choice=CAR
.000
.000
.000
.930
.930 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice BUS
|
|
Choice=AIR
.000
.000
.000
.221
.221 |
|
Choice=TRAIN
.000
.000
.000
.250
.250 |
| *
Choice=BUS
.000
.000
.000 -6.562
-6.562 |
|
Choice=CAR
.000
.000
.000
1.254
1.254 |
+-----------------------------------------------------------------+
+-----------------------------------------------------------------+
| Elasticity
Averaged over observations.
|
| Attribute is GC
in choice CAR
|
|
Choice=AIR
.000
.000
.000
.441
.441 |
|
Choice=TRAIN
.000
.000
.000
.553
.553 |
|
Choice=BUS
.000
.000
.000
3.384
3.384 |
| *
Choice=CAR
.000
.000
.000 -2.717
-2.717 |
+-----------------------------------------------------------------+
*/
303
/*=================================================================
Example 19.20. Multinomial Choice Models Based on the Normal
Distribution
*/=================================================================
? Note: Estimated Models are based on simulations and large
? samples of random draws by the random number generators. As
? such, models will differ slightly from one estimation to the
? next. Also, for purposes of our illustrations, we restricted
? the simulations to only 10 draws, rather than the more common
? 100, 500, etc. Thus, there will be correspondingly greater
? variation across estimations with our specifications.
?
? Random Parameters Logit Model
? =================================================
? 1. Full correlation across all parameters
Calc
; Ran(12345) $
Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Rhs = AASC,TASC,BASC,GC,TTME,HincAir
; RPL ; Pts=10 ; Cor
; Fcn=AASC(n),TASC(n),BASC(n),GC(n),TTME(n),HincAir(n) $
?
? 2. Variation only in constants
Calc
; Ran(12345) $
Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Rhs = AASC,TASC,BASC,GC,TTME,HincAir
; RPL ; Pts=10 ; Cor
; Fcn=AASC(n),TASC(n),BASC(n) $
?
? 3. Variation only in constants, no correlation
Calc
; Ran(12345) $
Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Rhs = AASC,TASC,BASC,GC,TTME,HincAir
; RPL ; Pts=10
; Fcn=AASC(n),TASC(n),BASC(n) $
?
? Multinomial Probit Model
? =================================================
? 1. Full correlation across all parameters
Calc
; Ran(12345) $
Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Rhs = AASC,TASC,BASC,GC,TTME,HincAir
; MNP ; Pts=10 ; Maxit=20 $
?
? 2. Variation only in constants
?
Calc
; Ran(12345) $
Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Rhs = AASC,TASC,BASC,GC,TTME,HincAir
; MNP ; Cor = 0 ; Pts=10 ; Maxit=20 $
?
? 3. Variation only in constants, no correlation
Calc
; Ran(12345) $
Nlogit ; Lhs = Mode ; Choices=Air,Train,Bus,Car
; Rhs = AASC,TASC,BASC,GC,TTME,HincAir
; MNP ; Cor = 0 ; Sdv = 1 ; Pts=10 ; Maxit=20 $
/*
304
305
306
307
308
/*=================================================================
Example 19.21. Rating Assignments
No computations
*/=================================================================
/*=================================================================
Example 19.22. Poisson Regression Model
*/=================================================================
?
Read ; Nobs=40 ; Nvar=14 ; Names = 1 $
Type TA TB TC TD TE T6064 T6569 T7074 T7579 O6074 O7579
1
1 0 0 0 0
1
0
0
0
1
0
1
1 0 0 0 0
1
0
0
0
0
1
1
1 0 0 0 0
0
1
0
0
1
0
1
1 0 0 0 0
0
1
0
0
0
1
1
1 0 0 0 0
0
0
1
0
1
0
1
1 0 0 0 0
0
0
1
0
0
1
1
1 0 0 0 0
0
0
0
1
1
0
1
1 0 0 0 0
0
0
0
1
0
1
2
0 1 0 0 0
1
0
0
0
1
0
2
0 1 0 0 0
1
0
0
0
0
1
2
0 1 0 0 0
0
1
0
0
1
0
2
0 1 0 0 0
0
1
0
0
0
1
2
0 1 0 0 0
0
0
1
0
1
0
2
0 1 0 0 0
0
0
1
0
0
1
2
0 1 0 0 0
0
0
0
1
1
0
2
0 1 0 0 0
0
0
0
1
0
1
3
0 0 1 0 0
1
0
0
0
1
0
3
0 0 1 0 0
1
0
0
0
0
1
3
0 0 1 0 0
0
1
0
0
1
0
3
0 0 1 0 0
0
1
0
0
0
1
3
0 0 1 0 0
0
0
1
0
1
0
3
0 0 1 0 0
0
0
1
0
0
1
3
0 0 1 0 0
0
0
0
1
1
0
3
0 0 1 0 0
0
0
0
1
0
1
4
0 0 0 1 0
1
0
0
0
1
0
4
0 0 0 1 0
1
0
0
0
0
1
4
0 0 0 1 0
0
1
0
0
1
0
4
0 0 0 1 0
0
1
0
0
0
1
4
0 0 0 1 0
0
0
1
0
1
0
4
0 0 0 1 0
0
0
1
0
0
1
4
0 0 0 1 0
0
0
0
1
1
0
4
0 0 0 1 0
0
0
0
1
0
1
5
0 0 0 0 1
0
0
0
1
0
1
5
0 0 0 0 1
1
0
0
0
0
1
5
0 0 0 0 1
0
1
0
0
1
0
5
0 0 0 0 1
0
1
0
0
0
1
5
0 0 0 0 1
0
0
1
0
1
0
5
0 0 0 0 1
0
0
1
0
0
1
5
0 0 0 0 1
0
0
0
1
1
0
5
0 0 0 0 1
0
0
0
1
0
1
?
Reject
Create
Months
127
63
1095
1095
1512
3353
.
2244
44882
17176
28609
20370
7064
13099
.
7117
1179
552
781
676
783
1948
.
274
251
105
288
192
349
1208
.
2051
45
.
789
437
1157
2161
.
542
Acc
0
0
3
4
6
18
.
11
39
29
58
53
12
44
.
18
1
1
0
1
6
2
.
1
0
0
0
0
2
11
.
4
0
.
7
7
5
12
.
1
; Acc = -999 $
; LogM = Log(Months) $
309
?
? Full model with period and ship effects. Use RST to force coefficient
? on logMonths to equal 1.
?
Poisson ; Lhs = Acc
; Rhs = One,TB,TC,TD,TE,T6569,T7074,T7579,O7579,LogM
; Rst = B1,B2,B3,B4,B5,
B6, B7,
B8,
B9, 1.0 $
Calc
; List ; Lfull = LogL $
/*
+---------------------------------------------+
| Poisson Regression
|
| Log likelihood function
-68.41456
|
| Chi- squared =
42.44145 RsqP=
.9456
|
| G - squared =
38.96262 RsqD=
.9366
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -6.402877189
.21752283
-29.435
.0000
TB
-.5447114535
.17761347
-3.067
.0022 .20588235
TC
-.6887644611
.32903575
-2.093
.0363 .20588235
TD
-.7430913936E-01 .29055779
-.256
.7981 .20588235
TE
.3205288062
.23575203
1.360
.1740 .17647059
T6569
.6958454875
.14965625
4.650
.0000 .29411765
T7074
.8174553971
.16983764
4.813
.0000 .29411765
T7579
.4449706379
.23323916
1.908
.0564 .17647059
O7579
.3838591307
.11826046
3.246
.0012 .58823529
LOGM
1.000000000
........(Fixed Parameter)........ 7.0492545
LFULL
= -.68414555743851670D+02
*/
? Force ship effect coefficients to equal zero.
?
Poisson ; Lhs = Acc
; Rhs = One,TB,TC,TD,TE,T6569,T7074,T7579,O7579,LogM
; Rst = B1, 0, 0, 0, 0,
B6, B7,
B8,
B9, 1.0 $
Calc
; List ; Lnoship = LogL $
/*
+---------------------------------------------+
| Log likelihood function
-80.20123
|
| Chi- squared =
82.83708 RsqP=
.8938
|
| G - squared =
62.53596 RsqD=
.8982
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -6.946953167
.12694255
-54.725
.0000
TB
.0000000000
........(Fixed Parameter)........ .20588235
TC
.0000000000
........(Fixed Parameter)........ .20588235
TD
.0000000000
........(Fixed Parameter)........ .20588235
TE
.0000000000
........(Fixed Parameter)........ .17647059
T6569
.7536172371
.14876631
5.066
.0000 .29411765
T7074
1.050336097
.15756211
6.666
.0000 .29411765
T7579
.6998988259
.22030227
3.177
.0015 .17647059
O7579
.3872453960
.11810212
3.279
.0010 .58823529
LOGM
1.000000000
........(Fixed Parameter)........ 7.0492545
LNOSHIP = -.80201227220281030D+02
*/
310
?
? Force period effects to equal zero
?
Poisson ; Lhs = Acc
; Rhs = One,TB,TC,TD,TE,T6569,T7074,T7579,O7579,LogM
; Rst = B1,B2,B3,B4,B5,
0,
0,
0,
B9, 1.0 $
Calc
; List ; Lnopd = LogL $
/*
+---------------------------------------------+
| Log likelihood function
-84.11515
|
| Chi- squared =
78.04910 RsqP=
.9000
|
| G - squared =
70.36380 RsqD=
.8855
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -5.799973547
.17841956
-32.507
.0000
TB
-.7437270799
.16914752
-4.397
.0000 .20588235
TC
-.7548677304
.32763934
-2.304
.0212 .20588235
TD
-.1843231891
.28755268
-.641
.5215 .20588235
TE
.3841930549
.23479004
1.636
.1018 .17647059
T6569
.0000000000
........(Fixed Parameter)........ .29411765
T7074
.0000000000
........(Fixed Parameter)........ .29411765
T7579
.0000000000
........(Fixed Parameter)........ .17647059
O7579
.5000989766
.11156453
4.483
.0000 .58823529
LOGM
1.000000000
........(Fixed Parameter)........ 7.0492545
LNOPD
= -.84115146686612620D+02
*/
?
? Likelihood ratio tests of restrictions
?
Calc
; List ; LRpd = 2*(Lfull - Lnopd)
; Ctb(.95,3)
; LRship = 2*(Lfull - Lnoship)
; Ctb(.95,4) $
/*
LRPD
= .31401181885521910D+02
Result = .78147277654400000D+01
LRSHIP = .23573342952858720D+02
Result = .94877290383399850D+01
*/
311
/*=================================================================
Example 19.23. A Regression-Based Test for Overdispersion in
the Poisson Model
*/=================================================================
Poisson ; Lhs = Acc
; Rhs = One,TB,TC,TD,TE,T6569,T7074,T7579,O7579,LogM
; Rst = B1,B2,B3,B4,B5,
B6, B7,
B8,
B9, 1.0
; Keep = Lambdai $
Create ; zi = ((Acc-Lambdai)^2 - Acc) / (sqr(2)*Lambdai) $
Regress ; Lhs = zi ; Rhs = One $
Regress ; Lhs = zi ; Rhs = lambdai $
/*
+---------------------------------------------+
| Poisson Regression
|
| Maximum Likelihood Estimates
|
+---------------------------------------------+
Results appear in previous examples
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .2248018912
.24061138
.934
.3569
+-----------------------------------------------------------------------+
| Ordinary
least squares regression
Weighting variable = none
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |t-ratio |P[|T|>t] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
LAMBDAI -.7910265460E-02 .12906232E-01
-.613
.5441 10.470588
*/
/*=================================================================
Example 19.24. A Conditional Moment Test for Overdispersion
*/=================================================================
Poisson ; Lhs = Acc
; Rhs = One,TB,TC,TD,TE,T6569,T7074,T7579,O7579,LogM
; Rst = B1,B2,B3,B4,B5,
B6, B7,
B8,
B9, 1.0
; Keep = Lambdai $
Create ; ei = Acc - Lambdai ; ei2 = ei*ei$
Create ; vi = ei^2 - Lambdai ; vi2 = vi*vi ; eivi = ei*vi $
Namelist; Z = TB,TC,TD,TE,T6569,T7074,T7579,O7579,LogM
; X = One,Z $
Matrix ; MM = Z'[vi2]Z ; DD = X'[ei2]X ; MD = Z'[eivi]X
; Q = MM - MD*<DD>*MD'
; r = Z'vi
; List ; CM = r'<Q>r $
Calc
; List ; Ctb(.95,8) $
/*
Regression Results appear in earlier examples
Matrix CM
has 1 rows and 1 columns.
1
+-------------1| .2655515D+02
Result = .15507313057789990D+02
*/
312
/*=================================================================
Example 19.25. A Lagrange Multiplier Test for Overdispersion
*/=================================================================
Poisson ; Lhs = Acc
; Rhs = One,TB,TC,TD,TE,T6569,T7074,T7579,O7579,LogM
; Rst = B1,B2,B3,B4,B5,
B6, B7,
B8,
B9, 1.0
; Keep = Lambdai ; Res = ei $
Calc
; List ; LM = (ei'ei - n*xbr(Acc))^2/(2*Lambdai'Lambdai) $
/*
Regression results appear in earlier examples.
LM
= .75044204556764770D+00
*/
/*==================================================================
Example 19.26 A Split Population Model for Major Derogatory Reports
*/==================================================================
?
? Initial Data Setup. Used for all examples
?
Read ; Nobs = 100 ; Nvar = 7 ; Names =
Derogs,Card,Age,Income,Exp,OwnRent,SelfEmpl $
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
0
3
0
1
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
1
0
1
0
1
0
1
1
1
1
0
1
0
1
1
1
0
1
1
1
0
1
1
1
1
1
1
1
1
0
1
0
38 4.52
33 2.42
34 4.50
31 2.54
32 9.79
23 2.50
28 3.96
29 2.37
37 3.80
28 3.20
31 3.95
42 1.98
30 1.73
29 2.45
35 1.91
41 3.20
40 4.00
30 3.00
40 10.00
46 3.40
35 2.35
25 1.88
34 2.00
36 4.00
43 5.14
30 4.51
22 3.84
22 1.50
34 2.50
40 5.50
22 2.03
29 3.20
25 3.15
21 2.47
24 3.00
43 3.54
43 2.28
37 5.70
27 3.50
28 4.60
26 3.00
23 2.59
30 1.51
30 1.85
38 2.60
28 1.80
36 2.00
38 3.26
124.98
9.85
15.00
137.87
546.50
92.00
40.83
150.79
777.82
52.58
256.66
0.00
0.00
78.87
42.62
335.43
248.72
0.00
548.03
0.00
43.34
0.00
218.52
170.64
37.58
502.20
0.00
73.18
0.00
1532.77
42.69
417.83
0.00
552.72
222.54
541.30
0.00
568.77
344.47
405.35
310.94
53.65
63.92
165.85
9.58
0.00
319.49
0.00
1
0
1
0
1
0
0
1
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
0
1
0
0
0
1
1
0
0
1
1
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
313
0
0
0
0
0
0
0
1
0
0
0
0
2
0
0
0
3
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
3
0
0
0
0
1
2
0
0
4
2
0
1
1
0
0
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
0
0
1
1
0
1
1
1
1
1
1
0
1
1
1
1
0
1
1
1
0
1
0
0
0
0
0
0
1
0
0
1
1
1
1
1
26
28
50
24
21
24
26
33
34
33
45
21
25
27
26
22
27
26
41
42
22
25
31
27
33
37
27
24
24
25
36
33
33
55
20
29
40
41
41
35
24
54
34
45
43
35
36
22
33
25
26
46
2.35
7.00
3.60
2.00
1.70
2.80
2.40
3.00
4.80
3.18
1.80
1.50
3.00
2.28
2.80
2.70
4.90
2.50
6.00
3.90
5.10
3.07
2.46
2.00
3.25
2.72
2.20
4.10
3.75
2.88
3.05
2.55
4.00
2.64
1.65
2.40
3.71
7.24
4.39
3.30
2.30
4.18
2.49
2.81
2.40
1.50
8.40
1.56
6.00
3.60
5.00
5.50
83.08
644.83
0.00
93.20
105.04
34.13
41.19
169.89
1898.03
810.39
0.00
32.78
95.80
27.78
215.07
79.51
0.00
0.00
306.03
104.54
0.00
642.47
308.05
186.35
56.15
129.37
93.11
0.00
292.66
98.46
258.55
101.68
0.00
65.25
108.61
49.56
0.00
235.57
0.00
0.00
0.00
0.00
0.00
0.00
68.38
0.00
0.00
0.00
474.15
234.05
451.20
251.52
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
0
0
0
1
0
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
?
?Variablesinmodelparts.Y=Derogs,forconvenience
?
Namelist ;
;
Create
;
Histogram;
?
X =
Z =
y =
Rhs
One,Age,Income,Exp
One,Age,Income,OwnRent $
Derogs $
= Derogs $
314
92
Frequency
69
46
23
3
4
DEROGS
315
+---------------------------------------------+
| Poisson Regression
|
| Log likelihood function
-79.70528
|
| Restricted log likelihood
-91.93738
|
| Chi- squared =
208.89386 RsqP=
.2557
|
| G - squared =
115.52058 RsqD=
.1748
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -1.548100204
.71359684
-2.169
.0300
AGE
.1202353857E-01 .19632020E-01
.612
.5402 32.080000
INCOME
.2211135873
.10113784
2.186
.0288 3.3693000
EXP
-.6640641019E-02 .19205129E-02
-3.458
.0005 189.02310
+---------------------------------------------+
| Multinomial Logit Model
|
| Log likelihood function
-45.31587
|
| Restricted log likelihood
-47.13935
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant -3.180366866
1.1781296
-2.700
.0069
AGE
.4167728346E-01 .34188956E-01
1.219
.2228 32.080000
INCOME
.1681214063
.16468011
1.021
.3073 3.3693000
OWNRENT -.8770336915
.64392165
-1.362
.1732 .36000000
+----------------------------------------------------------------------+
| Zero Altered Poisson
Regression Model
|
| Logistic distribution used for splitting model.
|
| ZAP term in probability is F[tau x Z(i)
]
|
| Comparison of estimated models
|
|
Pr[0|means]
Number of zeros
Log-likelihood |
| Poisson
.82882
Act.=
82 Prd.=
82.9
-79.70528 |
| Z.I.Poisson
.83497
Act.=
82 Prd.=
83.5
-64.68706 |
| Note, the ZIP log-likelihood is not directly comparable.
|
| ZIP model with nonzero Q does not encompass the others.
|
| Vuong statistic for testing ZIP vs. unaltered model is
6.1102
|
| Distributed as standard normal. A value greater than
|
| +1.96 favors the zero altered Z.I.Poisson model.
|
| A value less than -1.96 rejects the ZIP model.
|
+----------------------------------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Poisson/Negbin regression model
Constant 1.344753055
1.0535528
1.276
.2018
AGE
-.1048765464E-01 .32483456E-01
-.323
.7468 32.080000
INCOME
-.6937899516E-01 .20630881
-.336
.7367 3.3693000
EXP
-.5837869726E-02 .20820489E-02
-2.804
.0050 189.02310
Zero inflation model
Constant 4.258106947
1.7639127
2.414
.0158
AGE
-.3831975891E-01 .39309689E-01
-.975
.3297 32.080000
INCOME
-.7299972822
.39815656
-1.833
.0667 3.3693000
OWNRENT
.4918209292
.78944268
.623
.5333 .36000000
316
317
/*=================================================================
Example 20.12. Censoring in the Tobit and Poisson Regression Models
*/=================================================================
Read ; Nobs = 601 ; Nvar = 9;
Names=Y,Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8$
(Data are in Example 19.20)
/*=================================================================
Example 20.12. Censoring in the Tobit and Poisson Regression Models
*/=================================================================
? (continued)
Dstat
; Rhs=*
Histogram;rhs=y$
Descriptive Statistics
All results based on nonmissing observations.
==============================================================================
=
Variable
Mean
Std.Dev.
Minimum
Maximum
Cases
==============================================================================
=
Y
1.45590682
3.29875773
.000000000
12.0000000
601
Z1
.475873544
.499833583
.000000000
1.00000000
601
Z2
32.4875208
9.28876170
17.5000000
57.0000000
601
Z3
8.17769551
5.57130315
.125000000
15.0000000
601
Z4
.715474210
.451564115
.000000000
1.00000000
601
Z5
3.11647255
1.16750940
1.00000000
5.00000000
601
Z6
16.1663894
2.40255457
9.00000000
20.0000000
601
Z7
4.19467554
1.81944266
1.00000000
7.00000000
601
Z8
3.93178037
1.10317949
1.00000000
5.00000000
601
Histogram for Y
NOBS=
601, Too low:
0, Too high:
0
Bin Lower limit
Upper limit
Frequency
Cumulative Frequency
========================================================================
0
.000
1.000
451 ( .7504)
451( .7504)
1
1.000
2.000
34 ( .0566)
485( .8070)
2
2.000
3.000
17 ( .0283)
502( .8353)
3
3.000
4.000
19 ( .0316)
521( .8669)
4
4.000
5.000
0 ( .0000)
521( .8669)
5
5.000
6.000
0 ( .0000)
521( .8669)
6
6.000
7.000
0 ( .0000)
521( .8669)
7
7.000
8.000
42 ( .0699)
563( .9368)
8
8.000
9.000
0 ( .0000)
563( .9368)
9
9.000
10.000
0 ( .0000)
563( .9368)
10
10.000
11.000
0 ( .0000)
563( .9368)
11
11.000
12.000
0 ( .0000)
563( .9368)
12
12.000
13.000
38 ( .0632)
601(1.0000)
318
500
Freq ue n cy
375
250
125
6
Y
10 11 12
319
?
? Specification analysis for the tobit model
?
Create
;q=y>0$
Namelist ; X = one,z1,z2,z3,z4,z5,z6,z7,z8 $
Namelist ; Xr= one,
z2,z3,
z5,
z7,z8 $
?
? Tobit specification tests for three variables
? Wald
?
Tobit
; Lhs = y ; Rhs = X ; Wald:b(2)=0,b(5)=0,b(7)=0$
Calc
; LogLU=Logl $
Tobit
; Lhs = y ; Rhs = XR$
?
? Likelihood Ratio
?
Calc
; List ; LogLR=Logl ; LRTest = -2*(LogLR - LogLu) $
?
? lagrange Multiplier
?
Tobit
; Lhs = y ; Rhs = X ; Maxit = 0
; Start=b(1),0,b(2),b(3),0,b(4),0,b(5),b(6),s$
+---------------------------------------------+
| Limited Dependent Variable Model - CENSORED |
| Log likelihood function
-704.7311
|
| Threshold values for the model:
|
| Lower=
.0000
Upper=+infinity
|
| Wald test of 3 linear restrictions
|
| Chi-squared =
1.66, Sig. level = .64546 |
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Primary Index Equation for Model
Constant 7.608487071
3.9059870
1.948
.0514
Z1
.9457873252
1.0628656
.890
.3735 .47587354
Z2
-.1926982765
.80968360E-01
-2.380
.0173 32.487521
Z3
.5331896065
.14660745
3.637
.0003 8.1776955
Z4
1.019181783
1.2795746
.797
.4257 .71547421
Z5
-1.698999723
.40548331
-4.190
.0000 3.1164725
Z6
.2536077921E-01 .22766679
.111
.9113 16.166389
Z7
.2129825522
.32115700
.663
.5072 4.1946755
Z8
-2.273284428
.41540687
-5.472
.0000 3.9317804
Disturbance standard deviation
Sigma
8.258432069
.55458061
14.891
.0000
320
+---------------------------------------------+
| Limited Dependent Variable Model - CENSORED |
| Log likelihood function
-705.5762
|
| Threshold values for the model:
|
| Lower=
.0000
Upper=+infinity
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Primary Index Equation for Model
Constant 8.174197436
2.7414456
2.982
.0029
Z2
-.1793325837
.79093240E-01
-2.267
.0234 32.487521
Z3
.5541418128
.13451794
4.119
.0000 8.1776955
Z5
-1.686220493
.40375155
-4.176
.0000 3.1164725
Z7
.3260532488
.25442475
1.282
.2000 4.1946755
Z8
-2.284972720
.40782792
-5.603
.0000 3.9317804
Disturbance standard deviation
Sigma
8.247080326
.55336401
14.904
.0000
LRTEST
.16903037971408140D+01
321
/*
? Get main results, and MLEs. OLS is part of output
?
Tobit
; Lhs = y ; Rhs = XR ; MarginalEffects ; Par ; OLS $
Calc
; List ; Ltobit=Logl $
?
? Scaled tobit estimates and standard errors
?
Wald
; Start=B ; Var=varb ; labels=b1,b2,b3,b4,b5,b6,sg
; fn1=b1/sg ; fn2=b2/sg ; fn3=b3/sg
; fn4=b4/sg ; fn5=b5/sg ; fn6=b6/sg$
?
? Cragg/Greene consistency test for probability
?
Create
; q = y>0 $
Probit
; Lhs=q ; Rhs=xr ; Marginals$
Calc
; Lprobit=Logl $
Trunc
; Lhs=y ; Rhs=Xr ; Marginals $
Calc
; LTrunc=Logl $
Calc
; List ; Cragg = -2*(Ltobit - Lprobit - Ltrunc) $
/*
+-----------------------------------------------------------------------+
| Limited Dependent Variable Model - CENSORED
Regression
|
| Ordinary
least squares regression
Weighting variable = none
|
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 5.608160612
.79659947
7.040
.0000
Z2
-.5034734786E-01 .22105810E-01
-2.278
.0228 32.487521
Z3
.1618520786
.36896903E-01
4.387
.0000 8.1776955
Z5
-.4763238840
.11130785
-4.279
.0000 3.1164725
Z7
.1060059379
.71100666E-01
1.491
.1360 4.1946755
Z8
-.7122423539
.11828889
-6.021
.0000 3.9317804
+---------------------------------------------+
| Limited Dependent Variable Model - CENSORED |
| Log likelihood function
-705.5762
|
| Threshold values for the model:
|
| Lower=
.0000
Upper=+infinity
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Primary Index Equation for Model
Constant 8.174197436
2.7414456
2.982
.0029
Z2
-.1793325837
.79093240E-01
-2.267
.0234 32.487521
Z3
.5541418128
.13451794
4.119
.0000 8.1776955
Z5
-1.686220493
.40375155
-4.176
.0000 3.1164725
Z7
.3260532488
.25442475
1.282
.2000 4.1946755
Z8
-2.284972720
.40782792
-5.603
.0000 3.9317804
Disturbance standard deviation
Sigma
8.247080326
.55336401
14.904
.0000
322
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| They are computed at the means of the Xs. |
| Conditional Mean at Sample Point
1.1263 |
| Scale Factor for Marginal Effects
.2338 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 1.910805170
.65758415
2.906
.0037
Z2
-.4192088958E-01 .18444435E-01
-2.273
.0230 32.487521
Z3
.1295365141
.31167559E-01
4.156
.0000 8.1776955
Z5
-.3941718881
.93379144E-01
-4.221
.0000 3.1164725
Z7
.7621839800E-01 .59471640E-01
1.282
.2000 4.1946755
Z8
-.5341365586
.94896126E-01
-5.629
.0000 3.9317804
LTOBIT
= -.70557621764203170D+03
+-----------------------------------------------+
| WALD procedure. Estimates and standard errors |
| for nonlinear functions
|
+-----------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Fncn( 1) .9911625827
.33652215
2.945
.0032
Fncn( 2) -.2174497842E-01 .95484533E-02
-2.277
.0228
Fncn( 3) .6719248399E-01 .16136495E-01
4.164
.0000
Fncn( 4) -.2044627222
.48371582E-01
-4.227
.0000
Fncn( 5) .3953559755E-01 .30825623E-01
1.283
.1996
Fncn( 6) -.2770644434
.48258618E-01
-5.741
.0000
+---------------------------------------------+
| Binomial Probit Model
|
| Log likelihood function
-307.2955
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .9766647244
.36104809
2.705
.0068
Z2
-.2202376072E-01 .10177371E-01
-2.164
.0305 32.487521
Z3
.5990084920E-01 .17086004E-01
3.506
.0005 8.1776955
Z5
-.1836462412
.51493239E-01
-3.566
.0004 3.1164725
Z7
.3751312008E-01 .32844576E-01
1.142
.2534 4.1946755
Z8
-.2729824396
.52473295E-01
-5.202
.0000 3.9317804
+-------------------------------------------+
| Partial derivatives of E[y] = F[*]
with |
| respect to the vector of characteristics. |
| They are computed at the means of the Xs. |
| Observations used for means are All Obs. |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant .2969094977
.11108860
2.673
.0075
Z2
-.6695300413E-02 .30909282E-02
-2.166
.0303 32.487521
Z3
.1821006800E-01 .51704684E-02
3.522
.0004 8.1776955
Z5
-.5582910069E-01 .15568275E-01
-3.586
.0003 3.1164725
Z7
.1140411992E-01 .99845393E-02
1.142
.2534 4.1946755
Z8
-.8298761795E-01 .15933104E-01
-5.209
.0000 3.9317804
323
+---------------------------------------------+
| Limited Dependent Variable Model - TRUNCATE |
| Log likelihood function
-392.7103
|
| Threshold values for the model:
|
| Lower=
.0000
Upper=+infinity
|
| Observations after truncation
150
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 8.323045133
3.9597250
2.102
.0356
Z2
-.8414425459E-01 .11941653
-.705
.4810 33.410000
Z3
.5597703506
.21897633
2.556
.0106 9.5319467
Z5
-1.502400347
.61728675
-2.434
.0149 2.8533333
Z7
.1891403416
.37677181
.502
.6157 4.3133333
Z8
-1.349377201
.56454613
-2.390
.0168 3.4466667
Sigma
5.529829399
.65959601
8.384
.0000
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| They are computed at the means of the Xs. |
| Observations used for means are All Obs. |
| Conditional Mean at Sample Point
5.5614 |
| Scale Factor for Marginal Effects
.4843 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 4.030447257
1.9175029
2.102
.0356
Z2
-.4074698319E-01 .57827634E-01
-.705
.4810 33.410000
Z3
.2710696431
.10603962
2.556
.0106 9.5319467
Z5
-.7275396519
.29892205
-2.434
.0149 2.8533333
Z7
.9159149792E-01 .18245232
.502
.6157 4.3133333
Z8
-.6534379609
.27338232
-2.390
.0168 3.4466667
CRAGG =
.11140859667898440D+02
? Moment
Tobit
Matrix
Create
324
?
? Doubly censored (at 0 and 4) tobit model. Compared to standard case
?
Tobit ; Lhs = y ; Rhs = XR ; Mar $
Tobit ; Lhs = y ; Rhs = XR ; Mar ; Limits=0,4 $
?
+---------------------------------------------+
| Threshold values for the model:
|
| Lower=
.0000
Upper=+infinity
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 8.174197436
2.7414456
2.982
.0029
Z2
-.1793325837
.79093240E-01
-2.267
.0234 32.487521
Z3
.5541418128
.13451794
4.119
.0000 8.1776955
Z5
-1.686220493
.40375155
-4.176
.0000 3.1164725
Z7
.3260532488
.25442475
1.282
.2000 4.1946755
Z8
-2.284972720
.40782792
-5.603
.0000 3.9317804
Sigma
8.247080326
.55336401
14.904
.0000
+---------------------------------------------+
| Threshold values for the model:
|
| Lower=
.0000
Upper=
4.0000
|
+---------------------------------------------+
Constant 7.900980451
2.8038548
2.818
.0048
Z2
-.1775982087
.79906293E-01
-2.223
.0262 32.487521
Z3
.5323021100
.14116841
3.771
.0002 8.1776955
Z5
-1.616335655
.42439672
-3.809
.0001 3.1164725
Z7
.3241864581
.25387778
1.277
.2016 4.1946755
Z8
-2.207007447
.44983190
-4.906
.0000 3.9317804
Sigma
7.943219445
.87690019
9.058
.0000
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| Conditional Mean at Sample Point
1.1263 |
| Scale Factor for Marginal Effects
.2338 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 1.910805170
.65758415
2.906
.0037
Z2
-.4192088958E-01 .18444435E-01
-2.273
.0230 32.487521
Z3
.1295365141
.31167559E-01
4.156
.0000 8.1776955
Z5
-.3941718881
.93379144E-01
-4.221
.0000 3.1164725
Z7
.7621839800E-01 .59471640E-01
1.282
.2000 4.1946755
Z8
-.5341365586
.94896126E-01
-5.629
.0000 3.9317804
+-------------------------------------------+
| Lower=
.0000
Upper=
4.0000
|
| Conditional Mean at Sample Point
.2257 |
| Scale Factor for Marginal Effects
.1229 |
+-------------------------------------------+
Constant .9712865849
.34346628
2.828
.0047
Z2
-.2183257619E-01 .95804001E-02
-2.279
.0227 32.487521
Z3
.6543718236E-01 .16101450E-01
4.064
.0000 8.1776955
Z5
-.1987000409
.48288948E-01
-4.115
.0000 3.1164725
Z7
.3985302327E-01 .31004563E-01
1.285
.1987 4.1946755
Z8
-.2713127490
.48803373E-01
-5.559
.0000 3.9317804
? Poisson and Negative Binomial Regressions. Uncensored
?
Poisson ; Lhs=y ; rhs = Xr ; MarginalEffects $
325
Negbin
; Lhs=y ; rhs = Xr ; MarginalEffects $
?
? Censored Poisson and Negative Binomial Models, censored at 4
?
Create
; yc=y
; If(yc>=4)yc=4 $
Poisson ; Lhs=yc ; Rhs = Xr ; Limit=4 ; MarginalEffects$
?
? Create predictions from least restrictive model. Convert
? conditional means to integers, then censor.
?
Negbin
; Lhs=yc ; Rhs = Xr ; Limit=4 ; Margin ; keep=yfnb$
Create
; Iyfnb=int(yfnb) ; If(iyfnb>4)iyfnb=4$
+---------------------------------------------+
| Poisson Regression
|
| Log likelihood function
-1427.037
|
| Restricted log likelihood
-1709.723
|
| Chi- squared = 4125.90994 RsqP=
.0800
|
| G - squared = 2360.08448 RsqD=
.1933
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 2.533905282
.19692367
12.867
.0000
Z2
-.3225529750E-01 .58514053E-02
-5.512
.0000 32.487521
Z3
.1156984318
.99084864E-02
11.677
.0000 8.1776955
Z5
-.3540371394
.30892099E-01 -11.460
.0000 3.1164725
Z7
.7982824190E-01 .19448856E-01
4.105
.0000 4.1946755
Z8
-.4094427239
.27381245E-01 -14.953
.0000 3.9317804
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| Conditional Mean at Sample Point
1.4559 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 3.689129986
.39117889
9.431
.0000
Z2
-.4696070767E-01 .11623520E-01
-4.040
.0001 32.487521
Z3
.1684461361
.19682706E-01
8.558
.0000 8.1776955
Z5
-.5154450866
.61365588E-01
-8.400
.0000 3.1164725
Z7
.1162224820
.38634166E-01
3.008
.0026 4.1946755
Z8
-.5961104549
.54391454E-01 -10.960
.0000 3.9317804
326
+---------------------------------------------+
| Log likelihood function
-728.2441
|
| Restricted log likelihood
-1427.037
|
| Chi-squared
1397.586
|
| Degrees of freedom
1
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 2.189665176
.85899305
2.549
.0108
Z2
-.2623881896E-02 .17955428E-01
-.146
.8838 32.487521
Z3
.8481865225E-01 .40012554E-01
2.120
.0340 8.1776955
Z5
-.4222270934
.17050728
-2.476
.0133 3.1164725
Z7
.6044301285E-01 .90859681E-01
.665
.5059 4.1946755
Z8
-.4313313504
.16739868
-2.577
.0100 3.9317804
Overdispersion parameter for negative binomial model
Alpha
7.014805680
.94459163
7.426
.0000
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| Conditional Mean at Sample Point
1.4984 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 3.280911000
1.8007047
1.822
.0685
Z2
-.3931524815E-02 .37639913E-01
-.104
.9168 32.487521
Z3
.1270890418
.83878204E-01
1.515
.1297 8.1776955
Z5
-.6326490143
.35743393
-1.770
.0767 3.1164725
Z7
.9056551106E-01 .19046889
.475
.6344 4.1946755
Z8
-.6462904866
.35091738
-1.842
.0655 3.9317804
+---------------------------------------------+
| Poisson Regression
|
| Log likelihood function
-747.7541
|
| RIGHT Censored Data: Threshold = 4.
|
| Chi- squared = 1520.43723 RsqP=
.0799
|
| G - squared = 1077.99336 RsqD=
.1877
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 1.899932460
.28256837
6.724
.0000
Z2
-.3284957645E-01 .83771861E-02
-3.921
.0001 32.487521
Z3
.1053474148
.14041819E-01
7.502
.0000 8.1776955
Z5
-.3233479425
.43740859E-01
-7.392
.0000 3.1164725
Z7
.7984038573E-01 .27533200E-01
2.900
.0037 4.1946755
Z8
-.3896778919
.39122373E-01
-9.960
.0000 3.9317804
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| Conditional Mean at Sample Point
.7663 |
| Scale Factor for Marginal Effects
.7166 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 1.361437133
.28978016
4.698
.0000
Z2
-.2353906474E-01 .75918324E-02
-3.101
.0019 32.487521
Z3
.7548893733E-01 .14750440E-01
5.118
.0000 8.1776955
Z5
-.2317018658
.45888605E-01
-5.049
.0000 3.1164725
327
Z7
Z8
.5721133153E-01
-.2792320060
.24384424E-01
.45043450E-01
2.346
-6.199
.0190
.0000
4.1946755
3.9317804
+---------------------------------------------+
| Negative Binomial Regression
|
| Log likelihood function
-482.0505
|
| Restricted log likelihood
-747.7541
|
| Chi-squared
531.4072
|
| Degrees of freedom
1
|
| RIGHT Censored Data: Threshold = 4.
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 4.792788283
1.1636038
4.119
.0000
Z2
-.1659616715E-01 .24963901E-01
-.665
.5062 32.487521
Z3
.1744625408
.56779368E-01
3.073
.0021 8.1776955
Z5
-.7229290289
.19807844
-3.650
.0003 3.1164725
Z7
.8998362814E-01 .11558144
.779
.4363 4.1946755
Z8
-.8544311272
.21634356
-3.949
.0001 3.9317804
Overdispersion parameter for negative binomial model
Alpha
9.395956878
1.3533645
6.943
.0000
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| Conditional Mean at Sample Point
.7170 |
| Scale Factor for Marginal Effects
.2577 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 1.235198281
.79158359
1.560
.1187
Z2
-.4277167262E-02 .71500734E-02
-.598
.5497 32.487521
Z3
.4496251822E-01 .30220047E-01
1.488
.1368 8.1776955
Z5
-.1863134028
.11685569
-1.594
.1108 3.1164725
Z7
.2319059725E-01 .33257461E-01
.697
.4856 4.1946755
Z8
-.2202041478
.13847023
-1.590
.1118 3.9317804
Histogram; Rhs=yc$
(Actual data)
Histogram; Rhs=iyfnb$(Predictions)
Histogram for YC
NOBS=
601, Too low:
0, Too high:
0
Bin Lower limit
Upper limit
Frequency
Cumulative Frequency
========================================================================
0
.000
1.000
451 ( .7504)
451( .7504)
1
1.000
2.000
34 ( .0566)
485( .8070)
2
2.000
3.000
17 ( .0283)
502( .8353)
3
3.000
4.000
19 ( .0316)
521( .8669)
4
4.000
5.000
80 ( .1331)
601(1.0000)
Histogram for IYFNB
NOBS=
601, Too low:
0, Too high:
0
Bin Lower limit
Upper limit
Frequency
Cumulative Frequency
========================================================================
0
.000
1.000
251 ( .4176)
251( .4176)
1
1.000
2.000
96 ( .1597)
347( .5774)
2
2.000
3.000
50 ( .0832)
397( .6606)
3
3.000
4.000
34 ( .0566)
431( .7171)
4
4.000
5.000
170 ( .2829)
601(1.0000)
328
280
500
375
Frequency
Frequency
210
140
70
250
125
2
IYFNB
2
YC
329
496
Frequency
372
248
124
IEY
330
++
|ZeroAlteredPoissonRegressionModel|
|Logisticdistributionusedforsplittingmodel.|
|ZAPterminprobabilityisF[tauxZ(i)]|
|Comparisonofestimatedmodels|
|Pr[0|means]NumberofzerosLoglikelihood|
|Poisson.55783Act.=451Prd.=335.3771.44432|
|Z.I.Poisson.77364Act.=451Prd.=465.0551.72760|
|Note,theZIPloglikelihoodisnotdirectlycomparable.|
|ZIPmodelwithnonzeroQdoesnotencompasstheothers.|
|VuongstatisticfortestingZIPvs.unalteredmodelis21.6436|
|Distributedasstandardnormal.Avaluegreaterthan|
|+1.96favorsthezeroalteredZ.I.Poissonmodel.|
|Avaluelessthan1.96rejectstheZIPmodel.|
++
+++++++
|Variable|Coefficient|StandardError|b/St.Er.|P[|Z|>z]|MeanofX|
+++++++
Poisson/Negbinregressionmodel
Constant1.274187369.439409712.900.0037
Z2.4219823370E02.12229828E01.345.730132.487521
Z3.3312258287E01.23127736E011.432.15218.1776955
Z5.9085096098E01.72054203E011.261.20743.1164725
Z7.2052418829E01.44126404E01.465.64184.1946755
Z8.8166127920E01.66574722E011.227.22003.9317804
Zeroinflationmodel
Constant1.848860263.664366212.783.0054
Z2.3970949740E01.19046738E012.085.037132.487521
Z3.9814600629E01.31795289E013.087.00208.1776955
Z5.3062225236.95089852E013.220.00133.1164725
Z7.6770594854E01.60739793E011.115.26504.1946755
Z8.4577650236.94870568E014.825.00003.9317804
ZIP
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| They are computed at the means of the Xs. |
| Observations used for means are All Obs. |
| Conditional Mean at Sample Point
.0063 |
| Scale Factor for Marginal Effects -.3438 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 2.899747536
.57896387
5.009
.0000
Z2
-.2523628400E-01 .12985077E-01
-1.943
.0520 32.487521
Z3
.9869128559E-01 .26718883E-01
3.694
.0002 8.1776955
Z5
-.2879288809
.85416029E-01
-3.371
.0007 3.1164725
Z7
.6436057742E-01 .46300314E-01
1.390
.1645 4.1946755
Z8
-.3437579550
.79602625E-01
-4.318
.0000 3.9317804
331
Tobit(0)
+-------------------------------------------+
| Partial derivatives of expected val. with |
| respect to the vector of characteristics. |
| They are computed at the means of the Xs. |
| Observations used for means are All Obs. |
| Conditional Mean at Sample Point
1.1263 |
| Scale Factor for Marginal Effects
.2338 |
+-------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 1.910805168
.65758415
2.906
.0037
Z2
-.4192088954E-01 .18444435E-01
-2.273
.0230 32.487521
Z3
.1295365140
.31167559E-01
4.156
.0000 8.1776955
Z5
-.3941718875
.93379144E-01
-4.221
.0000 3.1164725
Z7
.7621839725E-01 .59471639E-01
1.282
.2000 4.1946755
Z8
-.5341365577
.94896126E-01
-5.629
.0000 3.9317804
Tobit(0,4)
++
|Partialderivativesofexpectedval.with|
|respecttothevectorofcharacteristics.|
|TheyarecomputedatthemeansoftheXs.|
|ObservationsusedformeansareAllObs.|
|ConditionalMeanatSamplePoint.2257|
|ScaleFactorforMarginalEffects.1229|
++
+++++++
|Variable|Coefficient|StandardError|b/St.Er.|P[|Z|>z]|MeanofX|
+++++++
Constant.9712865866.343466282.828.0047
Z2.2183257607E01.95804001E022.279.022732.487521
Z3.6543718214E01.16101450E014.064.00008.1776955
Z5.1987000414.48288948E014.115.00003.1164725
Z7.3985302304E01.31004563E011.285.19874.1946755
Z8.2713127494.48803373E015.559.00003.9317804
332
/*=================================================================
Example 20.13. Incidental Truncation
No computations
*/=================================================================
/*=================================================================
Example 20.14. A Model of Labor Supply
No computations
*/=================================================================
/*=================================================================
Example 20.15. A Migration Model
No computations
*/=================================================================
/*=================================================================
Example 20.16. The Migration Model (Continued)
No computations
*/=================================================================
/*=================================================================
Example 20.17. Log-Linear Survival Models for Strike Duration
*/=================================================================
Read ; Nobs = 62 ; Nvar = 2 ; Names = T,Prod $
T
7.00000
14.0000
52.0000
37.0000
52.0000
17.0000
72.0000
114.000
216.000
98.0000
85.0000
1.00000
3.00000
8.00000
23.0000
33.0000
43.0000
5.00000
12.0000
21.0000
42.0000
Prod
.0113800
.0113800
.0113800
.0229900
.0229900
-.0395700
-.0395700
-.0395700
-.0395700
-.0546700
.0053500
.0645000
.0645000
.0645000
.0645000
.0645000
.0645000
-.104430
-.0070000
-.0070000
-.0070000
9.00000
26.0000
130.000
41.0000
119.000
19.0000
99.0000
152.000
15.0000
2.00000
3.00000
2.00000
3.00000
11.0000
27.0000
35.0000
44.0000
49.0000
12.0000
27.0000
117.000
.0113800
.0113800
.0113800
.0229900
.0229900
-.0395700
-.0395700
-.0395700
-.0546700
.0053500
.0742700
.0645000
.0645000
.0645000
.0645000
.0645000
.0645000
-.104430
-.0070000
-.0070000
-.0070000
13.0000
29.0000
9.00000
49.0000
3.00000
28.0000
104.000
153.000
61.0000
25.0000
10.0000
3.00000
4.00000
22.0000
32.0000
43.0000
100.000
2.00000
21.0000
38.0000
.0113800
.0113800
.0229900
.0229900
-.0395700
-.0395700
-.0395700
-.0395700
-.0546700
.0053500
.0742700
.0645000
.0645000
.0645000
.0645000
.0645000
.0645000
-.0070000
-.0070000
-.0070000
?
? Four survival models for duration
?
Create;logT=Log(T)$
Surv;Lhs=logT;Rhs=One;Model=Exponential;Plot$
Surv;Lhs=logT;Rhs=One;Model=Weibull;Plot$
Surv;Lhs=logT;Rhs=One;Model=Logistic;Plot$
Surv;Lhs=logT;Rhs=One;Model=Normal;Plot$
333
+---------------------------------------------+
| Loglinear survival model: WEIBULL
|
| Log likelihood function
-101.9264
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 3.716202530
.14454149
25.710
.0000
Sigma
1.081447686
.13079440
8.268
.0000
+----------------------------------------------------------------+
| Parameters of underlying density at data means:
|
| Parameter
Estimate
Std. Error
Confidence Interval
|
| -----------------------------------------------------------|
| Lambda
.02433
.00352
.0174 to
.0312
|
| P
.92469
.11184
.7055 to
1.1439
|
| Median
27.65587
3.99742
19.8209 to
35.4908
|
| Percentiles of survival distribution:
|
| Survival
.25
.50
.75
.95
|
| Time
58.52
27.66
10.68
1.66
|
+----------------------------------------------------------------+
+---------------------------------------------+
| Loglinear survival model: EXPONENTIAL
|
| Log likelihood function
-102.2512
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 3.753669960
.11920158
31.490
.0000
Sigma
1.000000000
........(Fixed Parameter)........
+----------------------------------------------------------------+
| Parameters of underlying density at data means:
|
| Parameter
Estimate
Std. Error
Confidence Interval
|
| -----------------------------------------------------------|
| Lambda
.02343
.00279
.0180 to
.0289
|
| P
1.00000
.00000
1.0000 to
1.0000
|
| Median
29.58173
3.52619
22.6704 to
36.4931
|
| Percentiles of survival distribution:
|
| Survival
.25
.50
.75
.95
|
| Time
59.16
29.58
12.28
2.19
|
+----------------------------------------------------------------+
+---------------------------------------------+
| Loglinear survival model: LOGISTIC
|
| Log likelihood function
-104.7823
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
Constant 3.183714072
.16828937
18.918
.0000
Sigma
.7457267951
.96707673E-01
7.711
.0000
+----------------------------------------------------------------+
| Parameters of underlying density at data means:
|
| Parameter
Estimate
Std. Error
Confidence Interval
|
| -----------------------------------------------------------|
| Lambda
.04143
.00697
.0278 to
.0551
|
| P
1.34097
.17390
1.0001 to
1.6818
|
| Median
24.13623
4.06187
16.1750 to
32.0975
|
| Percentiles of survival distribution:
|
| Survival
.25
.50
.75
.95
|
| Time
54.76
24.14
10.64
2.69
|
+----------------------------------------------------------------+
+---------------------------------------------+
| Loglinear survival model: NORMAL
|
334
.030
.029
.027
HazardFn
HazardFn
.025
.025
.022
.020
.020
.015
43
86
130
Duration
Exponential
173
216
.018
43
86
130
173
216
Duration
Weibull
335
.040
.035
.035
.030
.030
HazardFn
HazardFn
.025
.025
.020
.020
.015
.015
.010
.010
.005
43
86
130
Duration
LogLogistic
173
216
.005
43
86
130
173
216
Duration
LogNormal
336
Survival
.8
.6
.4
.2
.0
-.2
43
86
130
173
216
Duration
/*=================================================================
Example 20.18. Weibull Model with a Covariate
*/=================================================================
?
Surv; Lhs=logT ; Rhs = One,Prod ; Model=Weibull ;plo$
/*
+---------------------------------------------+
| Log likelihood function
-97.28542
|
+---------------------------------------------+
+---------+--------------+----------------+--------+---------+----------+
|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|
+---------+--------------+----------------+--------+---------+----------+
RHS of hazard model
Constant 3.779774234
.13833256
27.324
.0000
PROD
-9.332198509
2.9542845
-3.159
.0016 .11023065E-01
337
338
.026
1.2
1.0
.026
Survival
HazardFn
.8
.025
.025
.6
.4
.2
.025
.025
.0
0
43
86
130
Duration
173
216
-.2
43
86
130
173
216
Duration
/*=================================================================
Example 20.19. A Conditional Moment Test for the
Weibull Distribution
*/=================================================================
?
Create
; logT = Log(T) $
?
? Regression results appear in previous example
?
Surv
; Lhs=logT ; Rhs = One,Prod ; Model=Weibull ; Res = ei $
Create
; ma1 = ei*ei-2
; ma2 = log(ei)-psi(1)
; mb1 = ma1
; mb2 = ei^3-6
; mb3 = ei^4-24
; wi = 1/s * (logt - b(1) - b(2)*prod)
; d1 = 1*(exp(wi)-1)
; d2 = prod*d1
; d3 = wi*d1 - 1$
Dstat
; Rhs = ei,d1,d2,d3 $
Namelist ; MA = ma1,ma2
; MB = mb1,mb2,mb3
; D = d1,d2,d3 $
Matrix
; TA = Ma'Ma - Ma'D*<D'D>*D'Ma
; List ; ca = 1'Ma*<TA>*Ma'1 $
Matrix
; TB = Mb'Mb - Mb'D*<D'D>*D'Mb
; List ; cb = 1'Mb*<TB>*Mb'1 $
==============================================================================
=
Variable
Mean
Std.Dev.
Minimum
Maximum
Cases
==============================================================================
=
EI
.999999954
.967115120
.406475110E-01 4.21453002
62
339
D1
-.462634525E-07 .967115120
-.959352489
62
D2
.119931366E-08 .451554174E-01 -.966042817E-01
62
D3
-.401444958E-07 1.07450762
-.998216246
62
Matrix CA
has 1 rows and 1 columns.
1
+-------------1| .1597104D+02
Matrix CB
has 1 rows and 1 columns.
1
+-------------1| .5021590D+02
3.21453002
.207337186
3.62422385
340
/*=================================================================
Example 20.20. Kaplan - Meier Hazard Functions
*/=================================================================
?
Survival ; Lhs = T ; Plot $
Estimated Survival Function
Duration variable is
T
Status is given by variable ONE
Number of observations in stratum =
62
Number of observations exiting
=
62
Number of observations censored
=
0
Survival
Enter Cnsrd At Risk Exited
Survival Rate
Hazard Rate
.0- 21.6
62
0
62
26 1.0000 ( .000)
.0246 ( .005)
21.6- 43.2
36
0
36
17
.5806 ( .063)
.0286 ( .007)
43.2- 64.8
19
0
19
6
.3065 ( .059)
.0174 ( .007)
64.8- 86.4
13
0
13
2
.2097 ( .052)
.0077 ( .005)
86.4- 108.0
11
0
11
4
.1774 ( .049)
.0206 ( .010)
108.0- 129.6
7
0
7
3
.1129 ( .040)
.0253 ( .014)
129.6- 151.2
4
0
4
1
.0645 ( .031)
.0132 ( .013)
151.2- 172.8
3
0
3
2
.0484 ( .027)
.0463 ( .028)
172.8- 194.4
1
0
1
0
.0161 ( .016)
.0000 ( .000)
194.4- 216.0
1
0
1
1
.0161 ( .016)
.0926 ( .000)
Estimated Survival Function
1.2
1.0
1.0
.8
.8
Survival
HazardFn
.6
.4
.6
.4
.2
.2
.0
.0
-.2
-50
50
100
Duration
150
200
250
-.2
-50
50
100
150
200
250
Duration
341
/*=================================================================
Example 20.21. Proportional Hazard Model
*/=================================================================
?
? Coxs Proportional Hazard Model
?
Survival ; Lhs = T ; Rhs = Prod ; Plot $
?
++
|CoxProportionalHazardModel|
|DurationvariableisT|
|StatusisgivenbyvariableONE|
|TotalNumberofObservations=62|
|TotalNumberofObservationsExiting=62|
|TotalNumberofObservationsCensored=0|
|TotalNumberofDistinctExitTimes=49|
++
++
|CoxProportionalHazardModel|
|Loglikelihoodfunction193.2722|
|Restrictedloglikelihood197.3651|
|Chisquared8.185853|
|Degreesoffreedom1|
|Significancelevel.4221833E02|
|Logranktestwith1degreesoffreedom:|
|Chisquared=8.064,Prob=.0045|
++
+++++++
|Variable|Coefficient|StandardError|b/St.Er.|P[|Z|>z]|MeanofX|
+++++++
PROD9.0730348503.22529892.813.0049.11023065E01
Estimated Survival Function
1.2
1.0
Survival
.8
.6
.4
.2
.0
-.2
43
87
130
174
217
Duration
342