? Chapters E2 - E5 Desriptive Statistics and Plot ? summarized by Junsoo Lee
reset;
? === Reading data files
Read ; Nobs = 90 ; Nvar = 6 ; Names = 1 ; file = airline.dat $
/*Alternatively, Read ; Nobs = 90 ; Nvar = 6 ; Names = 1 $ I, T, C, Q, PF, LF comma or space between variable names 1 1 1140640 .952757 106650 .534487 1 2 1215690 .986757 110307 .532328 .... (skip) .... 6 14 804388 .246847 851676 .537791 6 15 1009500 .304013 819476 .525775 */
/* More on Reading files
Read ; file = name ; format = xls ; names $ .. if names at the top of the columns
Read ; nobs = .. ; Nvar = .. ; File = .. ; Names = I,T,C,..
; Recode: Region(North = 1, South = 2, Midwest = 3) /
ses (female = 1, male = 0) $
*/
? === Descriptive Statistics
DSTAT ; Rhs = C, Q, PF, LF ; All ; Output = 3$
? All .. skewness and kurtoisis ? Output 3 .. covariance and correlation coeff
DSTAT ; Rhs = C, Q, PF, LF ; Str = I $
? Str .. stratification
DSTAT ; Rhs = PF, LF ; Quantiles ; Normality test ; Plot $
? Quantiles ? Normality test (Bowman and Shenton chi squared statitics (see p. E2-10 and below) ? Plot
? === Using Procedures (sub-routines)
PROC = Ntest(variable) $
Create ; v3 = Dev(variable)^3
; v4 = Dev(variable)^4 $
Calc ; List
; Term1 = (Sum(v3)/(n-1))/Sdv(variable)^3
; Term2 = (Sum(v4)/(n-1))/Sdv(variable)^4
; cn = n*(term1^2/6 + (term2-3)^2/24)
; p_value = 1 - chi(cn,2) $
Endproc $
Execute ; Proc = Ntest(PF) $ Execute ; Proc = Ntest(LF) $
? === Histogram
HISTPGRAM ; Rhs = LF $
Create ; PF1 = PF / 1000 $ HISTPGRAM ; Rhs = PF1; Int = 8 $
? Int .. # of bars ? See p. E2-14~15 for more details on limits, width, bin and Cross tabulations
? === Analysis of Variance
Regress ; Lhs = PF ; Rhs = One ; Str = I ; Panel$
? Can use Pds = 15 for balanced panel data
? === Matrix Functions for describing panel data
? Gxbr compress a panel data set into a data set of group means ? skip
? === Kernel Density Estimation
KERNEL ; Rhs = LF $
? === Reset
RESET $
? New project
? === Descriptive Statistics for Time Series Data
? GNPM1.DAT
Read ; Nobs=20 ; Nvar=4 ; Names= Year, Interest, Money, GNP $ 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
IDENTIFY ; Rhs = GNP ; Pds = 10 $
? ACF and PACF
SPECTRAL ; Rhs = GNP ; Windows = Bartlett $
? Spectal density function
? === Phillips-Perron Unit root tests
Create ; dy = gnp - gnp[-1] $ Regress ; Lhs = dy ; Rhs = one, GNP[-1] ; PPT ; Pds = 12 $
Create ; tr = Trn(1, 1) $ Regress ; Lhs = dy ; Rhs = one, tr, GNP[-1] ; PPT ; Pds = 12 $
? === Plotting Series
Plot ; Lhs = year ; Rhs = GNP, Money
; Title = Money and GNP
; Yaxis = M & GNP $
? Lhs = horizontal axis ? Rhs = vertical axis
Plot ; Lhs = GNP ; Rhs = Money ; Grid ; Regession $
Dates ; 1966 $ Period ; 1966-1985 $ Plot ; Rhs = gnp, money ; Yaxis = series $
? === Plotting a function
sample ; 1-101 $ create ; t = trn(-4, 0.08) $
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 $
execute ; proc = tdensity(t2, t, 2) $ execute ; proc = tdensity(t10, t, 10) $ create ; tinf = N01(t) $
Plot ; lhs = t ; Rhs = t2, t10, tinf
; Fill intervals
; Yaxis = density
; Title = t densities with diff d.f. $
? === FPLOT
/*
Sample ; 1 $
FPLOT ; Fcn = r*Log(r/3) - Lgm(r) - 1
; Labels = R
; Plot(r)
; Pts = 100
; Start = 5
; Limits = 1,16 $
errors
*/
? Chapters E5 - E7 Regression
? summarized by Junsoo Lee
? Reading the data
reset;
Open ; output = regressionE5_7.out $
Read ; Nobs = 90 ; Nvar = 6 ; Names = 1 ; file = airline.dat $ ? variables => I T C Q PF LF
? Regression
Regress; Lhs = C; Rhs = one, Q, PF, LF ; plot $
? Regression and Regression with Restrictions
? Regression with restrictions
Regress; Lhs = C; Rhs = one, Q, PF, LF ; CLS: B(3) = 1 $
? Regression with matrix algebra
Namelist; x = one, Q, PF, LF $ Namelist; y = C $
Matrix ; list
; beta = XLSQ(X,Y)
; beta1 = <X'X>*X'y $
Matrix ; list ; RSS = y'y - y'x*<x'x>*x'y ; RSS1 = Rcpm(x,y) $
Matrix ; list
; vc = {1/(n-col(x))} * Rcpm(x,y) * <x'x> $
Calc ; list ; Rsq = Rsq(x,y) ; Tss = Tss(x,y) ; Lik = Lik(x,y) $
? Stepwise regression in limdep
Regress; Lhs = C; Rhs = one, Q, PF, LF ; Alg = stepwise $
? Regression with forecase standard errors
Regress; Lhs = C; Rhs = X ; keep = yhat $
Calc ; list ; ct = Ttb(0.975, degfrdm) $
Create ; lowerbnd = yhat - ct * Sqr(ssqrd + Qfr(x,varb)) ; upperbnd = yhat + ct * Sqr(ssqrd + Qfr(x,varb)) $
PLOT;Rhs=YHAT,LOWERBND,UPPERBND$
? Multicollinearity: Variance Inflation Factors (VIFs) (p. E5-17)
MATRIX ;list ;xm0x={n-1}*Xvcm(x)
;vif=Diag(<x'x>)*vecd(xm0x) $
? Regression with extra variables
REGRESS ; Lhs=C; Rhs=ONE,Q; Rh2=PF, LF$
? Regression with CUSUM tests
REGRESS ; Lhs=C; Rhs=ONE,Q, PF, LF
; cusum $
? Robust Variance
REGRESS ; Lhs=C; Rhs=ONE,Q, PF, LF
; Het $
? Newey-West Variance
REGRESS ; Lhs=C; Rhs=ONE,Q, PF, LF
; Het
; Pds = 5 $
? Clustering to accomodate some kinds of correlation within groups of observations
REGRESS ; Lhs=C; Rhs=ONE,Q, PF, LF
; Cluster = I $
REGRESS ; Lhs=C; Rhs=ONE,Q, PF, LF
; Cluster = T $
? LAD estimator
REGRESS ; Lhs=C; Rhs=ONE,Q, PF, LF
; Alg = LAD $
? This provides no std errors or t-stat;
? Alternative variance matrices can be considered: see E5-26
REGRESS ; Lhs=C; Rhs=ONE,Q, PF, LF
; Alg = LAD ; Nbt = 20 $
? Nbt: bootstrapping
REGRESS ; Lhs=C; Rhs = X
; Alg = LAD
; Res = e $
Create ; abslad = Abs(e) $
Matrix ; v1 = {pi/2 * e'e/n}*<x'x>
; v2 = {pi/2}*<x'x>*Bhhh(x,e)*<x'x>
; Stat(b,v1)
; Stat(b,v2) $
? V1 = LAD assuming normal dist ? V2 = White version
? Non-parametric regression
REGress ; Lhs = y; Rhs = one, Q, PF, LF $ NPREG ; Lhs = y; Rhs = one, Q, PF, LF ; Start = b ; Smooth = 20 $
? Inequality restrictions
REGress ; Lhs = y; Rhs = one, Q, PF, LF
; Cls: b(3) <= 0.5 $
? No std errors; thus no t-stat
REGress ; Lhs = y; Rhs = one, Q, PF, LF
; Cls: b(3) <= 1.5
; Nbt = 30 $
? bootstrapping
? Wald test with Non-linear restrictions
REGress ; Lhs = y; Rhs = one, Q, PF, LF $ Wald ; Fn1 = b_Q / b_PF + b_LF = 10 $
? ======= Non-nested Hypothesis
? J-test for the right regressors
? When X1 and Z1 are competing regressors, which one is right? ? J-test for this involves the procedure ? 1st, regress y on x1 and compute fitted values ? 2nd, regress y on z1 and fitted values ? If Z1 is correct regressor vector, then the coeff. of fitted values are close to 0.
Namelist ; x1 = one, Q, PF
; z1 = one, Q, LF $
regress ; lhs = y ; rhs = x1; keep = x1_hat $ regress ; lhs = y ; rhs = z1, x1_hat ; Cls: b(4) = 0 $
? Cox test for the hypothesis that X is a correct regressor vector
CALC ; sz = ess(Z1,y)/n
; sx = ess(X1,y)/n $
REGRESS ; lhs = y ; rhs = x1 ; keep = xb $
REGRESS ; lhs = xb ; rhs = z1 ; res = u $
CALC ; list
; sxz = sx + sumsqdev / n
; c12 = n/2 * Log(sz/sxz)
; v12 = (sx / sxz^2) * ess(X1,u)
; Coxtest= 1 - phi(c12/sqr(v12)) $
? Cox test with two restricted regressions
? skip; see E5-45
? Testing for linearity vs, log-linearity
? skip; see E5-49
? Regression with GARCH
REGress ; Lhs = y; Rhs = one, PF, LF
; Model = GARCH(1,1) $
? REGress ; Lhs = y; Rhs = one, LF ? ; Model = GARCH(1,1,1) $ ? Garch in mean: crash ****
? Insert ; Cvar = variable name to retain estimates of conditional variances.
? Correcting the OLS Covariance Matrix from Autocorrelation
REGress ; Lhs = C; Rhs = one, PF, LF
; Pds=5 $
? Newey-West
? AR1 corrections
REGRESS ; Lhs = C ; Rhs = one, PF, LF ; AR1 $
? for Prais-Winsten algorithm.
? Other options: ? ;AR1 ;alg=Corc (Cochrane-Orcutt - don't use) ? ;AR1 ;alg=MLE ? ;AR1 ;alg=Grid(upper,lower,step) (simple grid search) ? ;AR1 ;rho=specific value (why use this?) ?
REGRESS ; Lhs = C ; Rhs = one, PF, LF
; AR1 ; alg=MLE $
/*E7.4 Autocorrelation with Lagged Dep. Var.
2SLS ; Lhs = … ; Rhs = … ;Inst=instrument set ;AR1 ;Hatanaka $
for Hatanaka's efficient two step estimator.
*/
? === Descriptive Statistics for Time Series Data
? GNPM1.DAT
Read ; Nobs=20 ; Nvar=4 ; Names= Year, Interest, Money, GNP $ 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
? Regression in difference
REGRESS ; Lhs = GNP ; Rhs = one, Money
; Dfr = 1 $
Reset$ ?======================================================================== ? E8 Linear Panel Data Data Estimation ?======================================================================== ? Use the airline data Read; Nobs=90; Nvar=6; Names=1; File=airline.dat $ Create; logc=Log(c); logq=log(q); logf=log(pf) $ Namelist; X=logq,logf,lf $ ?----------------------------------------------------------------------- ?Pooled OLS ?----------------------------------------------------------------------- Regress; Lhs=logc; Rhs=one,X $ ?----------------------------------------------------------------------- ?Fixed Effects ?----------------------------------------------------------------------- Regress; Lhs=logc; Rhs=one,X; Str=i; Panel; Fixed Effects $ ?----------------------------------------------------------------------- ?Fixed Effects with White Type Heteroskdasticity Consisitent Covariance ?I am not sure about the degrees of freedom adjustment in this case. Need ?to check the technical details ?----------------------------------------------------------------------- Regress; Lhs=logc; Rhs=one,X; Str=i; Panel; Fixed Effects; Het $ ?----------------------------------------------------------------------- ?Fixed Effects with New-West Type Heteroskdasticity Serial Correlations ?Consisitent Covariance ?----------------------------------------------------------------------- Regress; Lhs=logc; Rhs=one,X; Str=i; Panel; Fixed Effects; Het; Lags=3 $ ?----------------------------------------------------------------------- ?Random Effects ?----------------------------------------------------------------------- Regress; Lhs=logc; Rhs=one,X; Str=i; Panel; Random Effects $ ?----------------------------------------------------------------------- ?Dynamic Panel Data Estimation (Arellano and Bond type) ?We assume that ? logc = a*logc(-1) + bX + e ?The error term contains time varying and time constant components and the time constant ?error is correlated with the all of X variables. This is the second type regressors in ?Allelano and Bond model among four types. ?First type is the time varying variables uncorrelated with the time constant errors. ?Second type is the time varying variables correlated with the time constant errors. ?Third type is the time constant variables uncorrelated with the time constant errors. ?Fourth type is the time constant variables correlated with the time constant errors. ?We have three of second type regressors. So values in start are 0,3,0,0. ?----------------------------------------------------------------------- Regress; Lhs=logc; Rhs=X; Start=0,3,0,0; Str=i; Panel; Pattern=1; Dpd $ ? This does not yield any estimator because the covarince matrix becomes singular due to ? the presence of too many instrumental variable. Limdep proposes a mehtod to get around ? this problem, but I am not convinced on the method described on p. E8-36. See page 8-36 ? to see how Limdep generate the instrumental variable. It cannot work when you have N ? and T of similar dimension. I need to work on it little further make it work it in limdep.
? summarized by Junsoo Lee
? ARMA_BC_NLS_GMM_System_E9-E13.lim
? GNPM1.DAT
Read ; Nobs=20 ; Nvar=4 ; Names=
Year, Interest, Money, GNP $
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
?===============================
? E9: ARMAX
ARMAX ; Lhs = GNP ; RHS = one, Money
; Model = 1,0,1 $
Sample; 1 - 15 $
ARMAX ; Lhs = GNP ; RHS = one, Money
; Model = 1,0,1
; pds = 5
; plot $ ? # of periods to forecast
Sample; 1 - 20 $
IDENTIFY;Rhs=GNP;Pds=30$
SPECTRAL;Rhs=GNP$
? Geometric lag models; skip
? Stationarity test
Matrix ; List; A = [0.7, -0.5, 0.3] ; Root(A) $ ? AR(3) model
?Eigen values
Matrix ; R = [0.172, -0.051 / 1.511, -0.848]
; list
; Cxrt(R) $
?===============================
? E10 Box-Cox Regression
Create ; lm = Log(money) $
BOXCOX ; lhs = lm ; RHS = one, interest, gnp
; Model = 2 ? transformation applied to RHS
; Lambda = 0, 1 ? low, upper ranges
; list
; mle
; marginal effects $ ? includes predicted values
? Grid search
Matrix ; loglik = Init(51,1,0) ; lam = loglik $
CALC ; i = 0 $
Procedure
Calc ; i = i + 1 $
BOXCOX ; Lhs = money ; RHS = one, interest, gnp
; model = 2
; lambda = value $
Matrix ; loglik(i) = logl ; lam(i) = value $
Endprocedure
Execute ; silent ; value = 0, 5, 0.1 $
MPLOT ; lhs = lam; Rhs = loglik ; Fill ; Endpoints = 0, 6 $
?===============================
? E11: NLS
Reset $
? poisson data
Read ; Nobs=15 ; Nvar=4 ; Names = Y, X1, X2, X3 $
1 -0.545 0.160 0.033
0 0.892 0.125 1.476
2 1.647 0.619 -0.262
2 1.749 -1.446 0.310
2 0.362 -0.589 -1.404
0 0.531 -0.606 0.777
2 0.003 -0.800 -0.897
0 0.260 0.597 -0.640
3 1.502 -0.309 0.112
0 0.613 0.273 -0.845
0 -1.028 -0.307 -1.170
2 0.155 -0.262 -0.534
1 -1.795 -2.051 -0.398
0 -1.007 1.974 0.189
1 0.596 -0.493 -1.369
NLSQ ; lhs = y
; FCN = c0 + c1*x1 + c2*x2 + c3*x3
; start = 0,0,0,0
; labels =c0,c1,c2,c3
; output = 3 $
NAMELIST ; PD = One,X1,X2,X3 $
SAMPLE ; 1-15 $
REGRESS ; lhs = y ; rhs = PD $
NLSQ ; lhs = Y ; start = 0,0,0,0
; labels = b1,b2,b3,b4 ; fcn = b1’Pd $
? The nonlinear regression is based on E[Y³X] = exp(b'x)
REGRESS ; lhs = y ; rhs = PD $
NLSQ ; lhs = y ; start = b
; labels = b1,b2,b3,b4
; fcn = exp(b1’Pd) $
? NLSQ: Exponential function, y = exp(x*b) + e
reset $
SAMPLE ; 1 - 200 $
CREATE ; y=rnn(0,1) ; x1=rnn(0,1) ; x2=rnn(0,1) ; x3=rnn(0,1) $
Namelist ; xall = one,x1,x2,x3 $
NLSQ ; Lhs = y
; start = 0, 0, 0, 0
; labels = b1,b2,b3,b4
; Fcn = Exp(b1'xall)
; Maxit = 1000 $
? Heterogeneity in Probit Models
reset $
SAMPLE ; 1 - 30 $
Read ; Nobs = 30 ; nvar = 4 ; Names = 1 $
JOB AGE SCHOOL GENDER
1 31 16 0
1 34 14 1
1 41 16 1
0 67 9 0
1 25 12 0
0 58 12 1
1 45 14 0
1 55 10 0
0 43 12 0
1 55 8 0
1 25 11 0
1 41 14 0
0 62 12 1
1 51 13 1
0 39 9 1
1 35 10 0
1 40 14 1
0 43 10 1
0 37 12 1
1 27 13 0
1 28 14 0
1 48 12 1
0 66 7 1
0 44 11 1
0 21 12 1
1 40 10 1
1 41 15 0
0 23 10 1
0 31 11 1
1 44 12 1
Namelist ; X2 = ONE , AGE, SCHOOL, GENDER $
? Probit with NLSQ
NLSQ ; lhs= job
; labels = a1, a2, a3, a4
; start = 0, 0, 0, 0
; Fcn = Log(Phi(2*(job-1)*(a1+a2*age+a3*school+a4*gender)))
; Pds = 0 $ ? White; Pds = 5 for Newey-West
? Heterogeneity in Probit (simulating ubobservables)
probit ; lhs = job ; rhs = x2 $
Calc ; kx = Col(x2) $
NLSQ ; lhs = job
; Fcn = Prob = Ntg(1/sqr(Pi)*Phi(b1'x2 + c*u)) | Prob
; start = b, 0
; labels = kx_b, c
; Hrq = u ? Name of variable over which integration is done
; Hpt = 20 $ ? # of points in Hermite quadrature
probit ; lhs = job ; rhs = x2 $
Calc ; kx = Col(x2) $
? This takes time to run.
NLSQ ; lhs = job
; Fcn = Prob = Ntg(1/sqr(Pi)*Phi(b1'x2 + t*Sqr(2)*u)) | Prob
; start = b, 0
; labels = kx_b, t
; Sim = u ? Name of variable over which integration is done
; Pts = 100 $ ? # of points in simulation
?===============================
? E12 Nonlinear 2SLS and GMM
? Klein's Model I =
reset $
READ ; nvar = 10 ; nobs = 22 ; names=
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 -.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
? Variables are
? C = consumption
? P = private profits
? WP = private wage bill
? I = investment
? KLAG = lagged value of capital stock
? X = total demand
? Wg = government wage bill
? G = government spending
? T = indirect business taxes plus net exports
? A = Year - 1931
?
CREATE ; w = wp + wg ; a = year - 1931$
CREATE ; plag = p[-1];xlag=x[-1]$
NAMELIST ; cons = one,p,plag,w
; invs = one,p,plag,klag
; wage = one,x,xlag,a
; exog = one,g,t,wg,a,plag,klag,xlag$
SAMPLE ; 2 - 22$
2SLS ; lhs = c ; rhs = cons ; inst=exog$
2SLS ; lhs = i ; rhs = invs ; inst=exog$
2SLS ; lhs = wp ; rhs = wage ; inst=exog$
? Non-linear 2SLS
? minimizes e'Z(Z'Z)-1Z'e
Read; nobs = 20; nvar = 1; names = 1$
yi
20.5
31.5
47.7
26.2
44.0
8.28
30.8
17.2
19.9
9.96
55.8
25.2
29
85.5
15.1
28.5
21.4
17.7
6.42
84.9
? MLE (Gamma)
Sample ; 1-20$
Maximize ; Fcn = p*Log(lam) - Lgm(p) - lam*yi + (p-1)*Log(yi)
; Labels = lam,p
; start = 0.1, 2 $
? GMM (Gamma)
GMME ; Labels = lam,p
; start = 0.1, 2
; Fn1 = p/lam - yi
; Fn2 = Log(yi) - Psi(p) + Log(lam) $
reset $
LOAD;file="GRUNFELD.lpj"$
NLSQ ; lhs = i
; labels = a1, a2, a3
; start = 0, 0, 0
; Fcn = a1 + a2*f + a3*c
; Dfc $
Minimize
; labels = a1, a2, a3
; start = 0, 0, 0
; Fcn = (i- a1 - a2*f - a3*c)^2 $
? ====================================
? E13: Non-linear System of Equations
reset $
LOAD;file="GRUNFELD.lpj"$
SURE ; Lhs = igm, ic
; Eq1 = one, fgm, cgm
; Eq2 = one, fc, cc
; Cls: b(4) - b(1) = 0, b(5)-b(2)=0, b(6)-b(3)=0 $
reset $
? KLEIN1.DAT
READ ; nvar = 10 ; nobs = 22; names=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 -.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
CREATE ; w=wp+wg;a=year-1931$
SAMPLE ; 2-22$
CREATE ; plag=p[-1]; xlag=x[-1]$
Namelist ; cons = one, p, plag, w
; invs = one, p, plag, klag
; wage = one, x, xlag, a
; exog = one, g, t, wg, a, plag, klag, xlag $
3SLS ; lhs = c,i,wp
; Eq1 = cons
; Eq2 = invs
; Eq3 = wage
; Inst = exog $
? GAS.DAT
read;nobs=36;nvar=10;names=
Year, G, Pg, Y, Pnc, Puc, Ppt, Pd, Pn, Ps$
1960 129.7 .925 6036 1.045 .836 .810 .444 .331 .302
1961 131.3 .914 6113 1.045 .869 .846 .448 .335 .307
1962 137.1 .919 6271 1.041 .948 .874 .457 .338 .314
1963 141.6 .918 6378 1.035 .960 .885 .463 .343 .320
1964 148.8 .914 6727 1.032 1.001 .901 .470 .347 .325
1965 155.9 .949 7027 1.009 .994 .919 .471 .353 .332
1966 164.9 .970 7280 .991 .970 .952 .475 .366 .342
1967 171.0 1.000 7513 1.000 1.000 1.000 .483 .375 .353
1968 183.4 1.014 7728 1.028 1.028 1.046 .501 .390 .368
1969 195.8 1.047 7891 1.044 1.031 1.127 .514 .409 .386
1970 207.4 1.056 8134 1.076 1.043 1.285 .527 .427 .407
1971 218.3 1.063 8322 1.120 1.102 1.377 .547 .442 .431
1972 226.8 1.076 8562 1.110 1.105 1.434 .555 .458 .451
1973 237.9 1.181 9042 1.111 1.176 1.448 .566 .497 .474
1974 225.8 1.599 8867 1.175 1.226 1.480 .604 .572 .513
1975 232.4 1.708 8944 1.276 1.464 1.586 .659 .615 .556
1976 241.7 1.779 9175 1.357 1.679 1.742 .695 .638 .598
1977 249.2 1.882 9381 1.429 1.828 1.824 .727 .671 .648
1978 261.3 1.963 9735 1.538 1.865 1.878 .769 .719 .698
1979 248.9 2.656 9829 1.660 2.010 2.003 .821 .800 .756
1980 226.8 3.691 9722 1.793 2.081 2.516 .892 .894 .839
1981 225.6 4.109 9769 1.902 2.569 3.120 .957 .969 .926
1982 228.8 3.894 9725 1.976 2.964 3.460 1.000 1.000 1.000
1983 239.6 3.764 9930 2.026 3.297 3.626 1.041 1.021 1.062
1984 244.7 3.707 10421 2.085 3.757 3.852 1.038 1.050 1.117
1985 245.8 3.738 10563 2.152 3.797 4.028 1.045 1.075 1.173
1986 269.4 2.921 10780 2.240 3.632 4.264 1.053 1.069 1.224
1987 276.8 3.038 10859 2.321 3.776 4.413 1.085 1.111 1.271
1988 279.9 3.065 11186 2.368 3.939 4.494 1.105 1.152 1.336
1989 284.1 3.353 11300 2.414 4.019 4.719 1.129 1.213 1.408
1990 282.0 3.834 11389 2.451 3.926 5.197 1.144 1.285 1.482
1991 271.8 3.766 11272 2.538 3.942 5.427 1.167 1.332 1.557
1992 280.2 3.751 11466 2.528 4.113 5.518 1.184 1.358 1.625
1993 286.7 3.713 11476 2.663 4.470 6.086 1.200 1.379 1.684
1994 290.2 3.732 11636 2.754 4.730 6.268 1.225 1.396 1.734
1995 297.8 3.789 11934 2.815 5.224 6.410 1.239 1.419 1.786
Create ; pd = pd/.483 ; pn = pn/.375 ; ps = ps/.353 $