Tải bản đầy đủ (.pdf) (10 trang)

SAS/ETS 9.22 User''''s Guide 130 pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (264.94 KB, 10 trang )

1282 ✦ Chapter 18: The MODEL Procedure
do i=1 to 500;
x = rannor( 1013 );
Y = 2 + 1.5
*
x + 1.5
*
rannor( 1013 );
output;
end;
run;
proc model data=regdata;
parms a b s;
instrument x;
ysim = (a+b
*
x) + s
*
rannor( 8003 );
y = ysim;
eq.ysq = y
*
y - ysim
*
ysim;
fit y ysq / gmm ndraw;
bound s > 0;
run;
Alternatively, the MOMENT statement can be used to specify the moments using the following
syntax:
proc model data=regdata;


parms a b s;
instrument x;
ysim = (a+b
*
x) + s
*
rannor( 8003 );
y = ysim;
moment y = (2);
fit y / gmm ndraw;
bound s > 0;
run;
The output of the MODEL procedure is shown in Output 18.15.1:
Output 18.15.1 PROC MODEL Output
Simple regression model
The MODEL Procedure
Model Summary
Model Variables 1
Parameters 3
Equations 2
Number of Statements 4
Model Variables Y
Parameters a b s
Equations ysq Y
Example 18.16: Simulated Method of Moments—AR(1) Process ✦ 1283
Output 18.15.1 continued
The 2 Equations to Estimate
Y = F(a(1), b(x), s)
ysq = F(a, b, s)
Instruments 1 x

Nonlinear GMM Parameter Estimates
Approx Approx
Parameter Estimate Std Err t Value Pr > |t|
a 2.065983 0.0657 31.45 <.0001
b 1.511075 0.0565 26.73 <.0001
s 1.483358 0.0498 29.78 <.0001
Example 18.16: Simulated Method of Moments—AR(1) Process
This example illustrates how to use SMM to estimate an AR(1) regression model for the following
process:
y
t
D a C bx
t
C u
t
u
t
D ˛u
t1
C 
t

t
 i id N.0; s
2
/
In the following SAS statements,
ysim
is simulated by using this model, and the endogenous variable
y

is set to be equal to
ysim
. The MOMENT statement creates two more moments for the estimation.
One is the second moment, and the other is the first-order autocovariance. The NPREOBS=10
option instructs PROC MODEL to run the simulation 10 times before
ysim
is compared to the first
observation of
y
. Because the initial
zlag.u/
is zero, the first
ysim
is
a C b x C s  rannor.8003/
.
Without the NPREOBS option, this
ysim
is matched with the first observation of
y
. With NPREOBS,
this
ysim
and the next nine
ysim
are thrown away, and the moment match starts with the eleventh
ysim
with the first observation of
y
. This way, the initial values do not exert a large influence on the

simulated endogenous variables.
%let nobs=500;
data ardata;
lu =0;
do i=-10 to &nobs;
x = rannor( 1011 );
e = rannor( 1011 );
u = .6
*
lu + 1.5
*
e;
Y = 2 + 1.5
*
x + u;
lu = u;
if i > 0 then output;
end;
1284 ✦ Chapter 18: The MODEL Procedure
run;
title1 'Simulated Method of Moments for AR(1) Process';
proc model data=ardata ;
parms a b s 1 alpha .5;
instrument x;
u = alpha
*
zlag(u) + s
*
rannor( 8003 );
ysim = a + b

*
x + u;
y = ysim;
moment y = (2) lag1(1);
fit y / gmm npreobs=10 ndraw=10;
bound s > 0, 1 > alpha > 0;
run;
The output of the MODEL procedure is shown in Output 18.16.1:
Output 18.16.1 PROC MODEL Output
Simulated Method of Moments for AR(1) Process
The MODEL Procedure
Model Summary
Model Variables 1
Parameters 4
Equations 3
Number of Statements 8
Program Lag Length 1
Model Variables Y
Parameters(Value) a b s(1) alpha(0.5)
Equations _moment_2 _moment_1 Y
The 3 Equations to Estimate
_moment_2 = F(a, b, s, alpha)
_moment_1 = F(a, b, s, alpha)
Y = F(a(1), b(x), s, alpha)
Instruments 1 x
Nonlinear GMM Parameter Estimates
Approx Approx
Parameter Estimate Std Err t Value Pr > |t|
a 1.632798 0.1038 15.73 <.0001
b 1.513197 0.0698 21.67 <.0001

s 1.427888 0.0984 14.52 <.0001
alpha 0.543985 0.0809 6.72 <.0001
Example 18.17: Simulated Method of Moments—Stochastic Volatility Model ✦ 1285
Example 18.17: Simulated Method of Moments—Stochastic Volatility
Model
This example illustrates how to use SMM to estimate a stochastic volatility model as in Andersen
and Sorensen (1996):
y
t
D 
t
z
t
log.
2
t
/ D a C b log.
2
t1
/ C su
t
.z
t
; u
t
/  i id N.0; I
2
/
This model is widely used in modeling the return process of stock prices and foreign exchange rates.
This is called the stochastic volatility model because the volatility is stochastic as the random variable

u
t
appears in the volatility equation. The following SAS statements use three moments: absolute
value, the second-order moment, and absolute value of the first-order autoregressive moment. Note
the ADJSMMV option in the FIT statement to request the SMM covariance adjustment for the
parameter estimates. Although these moments have closed form solution as shown by Andersen and
Sorensen (1996), the simulation approach significantly simplifies the moment conditions.
%let nobs=1000;
data _tmpdata;
a = -0.736; b=0.9; s=0.363;
ll=sqrt( exp(a/(1-b)));;
do i=-10 to &nobs;
u = rannor( 101 );
z = rannor( 101 );
lnssq = a+b
*
log(ll
**
2) +s
*
u;
st = sqrt(exp(lnssq));
ll = st;
y = st
*
z;
if i > 0 then output;
end;
run;
title1 'Simulated Method of Moments for Stochastic Volatility Model';

proc model data=_tmpdata ;
parms a b .5 s 1;
instrument _exog_ / intonly;
u = rannor( 8801 );
z = rannor( 9701 );
lsigmasq = xlag(sigmasq,exp(a));
lnsigmasq = a + b
*
log(lsigmasq) + s
*
u;
sigmasq = exp( lnsigmasq );
ysim = sqrt(sigmasq)
*
z;
eq.m1 = abs(y) - abs(ysim);
eq.m2 = y
**
2 - ysim
**
2;
eq.m5 = abs(y
*
lag(y))-abs(ysim
*
lag(ysim));
1286 ✦ Chapter 18: The MODEL Procedure
fit m1 m2 m5 / gmm npreobs=10 ndraw=10 adjsmmv;
bound s > 0, 1 > b > 0;
run;

The output of the MODEL procedure is shown in Output 18.17.1.
Output 18.17.1 PROC MODEL Output
Simulated Method of Moments for Stochastic Volatility Model
The MODEL Procedure
Model Summary
Parameters 3
Equations 3
Number of Statements 10
Program Lag Length 1
Parameters(Value) a b(0.5) s(1)
Equations m1 m2 m5
The 3 Equations to Estimate
m1 = F(a, b, s)
m2 = F(a, b, s)
m5 = F(a, b, s)
Instruments 1
Nonlinear GMM Parameter Estimates
Approx Approx
Parameter Estimate Std Err t Value Pr > |t|
a -2.2299 1.1357 -1.96 0.0499
b 0.695469 0.1554 4.47 <.0001
s 0.747779 0.1648 4.54 <.0001
Example 18.18: Duration Data Model with Unobserved Heterogeneity
All of the previous three models actually have closed-form moment conditions, so the simulation
approach is not necessarily required for the estimation. This example illustrates how to use SMM to
estimate a model for which there is no closed-form solution for the moments and thus the traditional
GMM method does not apply. The model is the duration data model with unobserved heterogeneity
in Gourieroux and Monfort (1993):
y
i

D exp.bx
i
 u
i
/log.v
i
/
u
i
 N.0; 1/ v
i
 U
Œ0;1
Example 18.18: Duration Data Model with Unobserved Heterogeneity ✦ 1287
The SAS statements are:
title1 'SMM for Duration Model with Unobserved Heterogeneity';
%let nobs=1000;
data durationdata;
b=0.9; s=0.5;
do i=1 to &nobs;
u = rannor( 1011 );
v = ranuni( 1011 );
x = 2
*
ranuni( 1011 );
y = -exp(-b
*
x + s
*
u)

*
log(v);
output;
end;
run;
proc model data=durationdata;
parms b .5 s 1;
instrument x;
u = rannor( 1011 );
v = ranuni( 1011 );
y = -exp(-b
*
x + s
*
u)
*
log(v);
moment y = (2 3 4);
fit y / gmm ndraw=10 ;
*
maxiter=500;
bound s > 0, b > 0;
run;
The output of the MODEL procedure is shown in Output 18.18.1.
Output 18.18.1 PROC MODEL Output
SMM for Duration Model with Unobserved Heterogeneity
The MODEL Procedure
Model Summary
Model Variables 1
Parameters 2

Equations 4
Number of Statements 9
Model Variables y
Parameters(Value) b(0.5) s(1)
Equations _moment_3 _moment_2 _moment_1 y
1288 ✦ Chapter 18: The MODEL Procedure
Output 18.18.1 continued
The 4 Equations to Estimate
_moment_3 = F(b, s)
_moment_2 = F(b, s)
_moment_1 = F(b, s)
y = F(b, s)
Instruments 1 x
Nonlinear GMM Parameter Estimates
Approx Approx
Parameter Estimate Std Err t Value Pr > |t|
b 0.92983 0.0331 28.08 <.0001
s 0.341825 0.0608 5.62 <.0001
Example 18.19: EMM Estimation of a Stochastic Volatility Model
The efficient method of moments (EMM), introduced by Bansal et al. (1993 and 1995) and Gallant
and Tauchen (2001), can be considered a variant of SMM. The idea is to match the efficiency of the
maximum likelihood (ML) estimation with the flexibility of the SMM procedure. ML itself can be
interpreted as a method of moments procedure, where the score vector, the vector of derivatives of
the log-likelihood function with respect to the parameters, provides the exactly identifying moment
conditions. EMM employs an auxiliary (or pseudo) model that closely matches the true model. The
score vector of the auxiliary model provides the moment conditions in the SMM step.
This example uses the SMM feature of PROC MODEL to estimate the simple stochastic volatility
(SV) model of Example 18.17 with the EMM method.
Suppose that your data are the time series
fy

1
; y
2
; : : : ; y
n
g
, and the model that you want to estimate,
or the structural model, is characterized by the vector of parameters
Â
. For the SV model,
Â
is given
by .a; b; s/.
The first step of the EMM method is to fit the data with an auxiliary model (or score generator)
that has transition density
f .y
t
jY
t1
; Á/
, parametrized by the pseudo parameter
Á
, where
Y
t1
D
fy
t1
; : : : ; y
1

g
. The auxiliary model must approximate the true data-generating process as closely
as possible and be such that ML estimation is feasible.
The only identification requirement is that the dimension of the pseudo parameter
Á
be greater than
or equal to that of the structural parameter Â.
Andersen, Chung, and Sorensen (1999) showed that the GARCH(1,1) is an appropriate auxiliary
model that leads to a good performance of the EMM estimator for the SV model.
Example 18.19: EMM Estimation of a Stochastic Volatility Model ✦ 1289
The analytical expression for the GARCH(1,1) model with mean zero is
y
t
D 
t
z
t

2
t
D ! C ˛y
t1
C ˇ
2
t1
The pseudo parameter vector Á is given by .!; ˛; ˇ/.
One advantage of such a class of models is that the conditional density of y
t
is Gaussian—that is,
f .y

t
jY
t1
; Á/ /
1

t
exp
Â

y
2
t
2
2
t
Ã
Therefore the score vector can easily be computed analytically.
The AUTOREG procedure provides the ML estimates,
O
Á
n
. The output is stored in the garchout data
set, while the estimates are stored in the garchest data set.
title1 'Efficient Method of Moments for Stochastic Volatility Model';
/
*
estimate GARCH(1,1) model
*
/

proc autoreg data=svdata(keep=y)
outest=garchest
noprint covout;
model y = / noint garch=(q=1,p=1);
output out=garchout cev=gsigmasq r=resid;
run;
If the pseudo model is close enough to the structural model, in a suitable sense, Gallant and Long
(1997) showed that a consistent estimator of the asymptotic covariance matrix of the sample pseudo-
score vector can be obtained from the formula
O
V
n
D
1
n
n
X
tD1
s
f
.Y
t
;
O
Á
n
/s
f
.Y
t

;
O
Á
n
/
0
where
s
f
.Y
t
;
O
Á
n
/ D .@=@Á
n
/ log f .y
t
jY
t1
;
O
Á
n
/
denotes the score function of the auxiliary model
computed at the ML estimates.
The ML estimates of the GARCH(1,1) model are used in the following SAS statements to compute
the variance-covariance matrix

O
V
n
.
/
*
compute the V matrix
*
/
data vvalues;
set garchout(keep=y gsigmasq resid);
/
*
compute scores of GARCH model
*
/
score_1 = (-1 + y
**
2/gsigmasq)/ gsigmasq;
score_2 = (-1 + y
**
2/gsigmasq)
*
lag(gsigmasq) / gsigmasq;
score_3 = (-1 + y
**
2/gsigmasq)
*
lag(y
**

2) / gsigmasq;
array score{
*
} score_1-score_3;
array v_t{
*
} v_t_1-v_t_6;
array v{
*
} v_1-v_6;
1290 ✦ Chapter 18: The MODEL Procedure
/
*
compute external product of score vector
*
/
do i=1 to 3;
do j=i to 3;
v_t{j
*
(j-1)/2 + i} = score{i}
*
score{j};
end;
end;
/
*
average them over t
*
/

do s=1 to 6;
v{s}+ v_t{s}/&nobs;
end;
run;
The
O
V
matrix must be formatted to be used with the VDATA= option of the MODEL procedure. See
the section “VDATA= Input data set” on page 1158 for more information about the VDATA= data
set.
/
*
Create a VDATA dataset acceptable to PROC MODEL
*
/
/
*
Transpose the last obs in the dataset
*
/
proc transpose data=vvalues(firstobs=&nobs keep=v_1-v_6)
out=tempv;
run;
/
*
Add eq and inst labels
*
/
data vhat;
set tempv(drop=_name_);

value = col1;
drop col1;
input _type_ $ eq_row $ eq_col $ inst_row $ inst_col $;
*
$;
datalines;
gmm m1 m1 1 1 /
*
intcpt is the only inst we use
*
/
gmm m1 m2 1 1
gmm m2 m2 1 1
gmm m1 m3 1 1
gmm m2 m3 1 1
gmm m3 m3 1 1
;
The last step of the EMM procedure is to estimate
Â
by using SMM, where the moment conditions
are given by the scores of the auxiliary model.
Given a fixed value of the parameter vector
Â
and an arbitrarily large T, one can simulate a series
f Oy
1
.Â/; Oy
2
.Â/; : : : ; Oy
T

.Â/g
from the structural model. The EMM estimator is the value
O
Â
n
that
minimizes the quantity
m
T
.Â;
O
Á
n
/
0
O
V
1
n
m
T
.Â;
O
Á
n
/
where
m
T
.Â;

O
Á
n
/ D
1
T
T
X
kD1
s
f
.
O
Y
k
.Â/;
O
Á
n
/
Example 18.19: EMM Estimation of a Stochastic Volatility Model ✦ 1291
is the sample moment condition evaluated at the fixed estimated pseudo parameter
O
Á
n
. Note that the
target function depends on the parameter  only through the simulated series Oy
k
.
The following statements generate a data set that contains

T D 20; 000
replicates of the estimated
pseudo parameter
O
Á
n
and that is then input to the MODEL procedure. The EMM estimates are found
by using the SMM option of the FIT statement. The
O
V
n
matrix computed above serves as weighting
matrix by using the VDATA= option, and the scores of the GARCH(1,1) auxiliary model evaluated
at the ML estimates are the moment conditions in the GMM step.
Since the number of structural parameters to estimate (3) is equal to the number of moment equations
(3) times the number of instruments (1), the model is exactly identified and the objective function
has value zero at the minimum.
For simplicity, the starting values are set to the true values of the parameters.
/
*
USE SMM TO FIND EMM ESTIMATES
*
/
/
*
Generate dataset of length T
*
/
data emm;
set garchest(obs=1 keep = _ah_0 _ah_1 _gh_1 _mse_);

do i=1 to 20000;
output;
end;
drop i;
run;
title2 'EMM estimates';
/
*
Find the EMM estimates
*
/
proc model data=emm maxiter=1000;
parms a -0.736 b 0.9 s 0.363;
instrument _exog_ / intonly;
/
*
Describe the structural model
*
/
u = rannor( 8801 );
z = rannor( 9701 );
lsigmasq = xlag(sigmasq,exp(a));
lnsigmasq = a + b
*
log(lsigmasq) + s
*
u;
sigmasq = exp( lnsigmasq );
ysim = sqrt(sigmasq)
*

z;
/
*
Volatility of the GARCH model
*
/
gsigmasq = _ah_0 + _gh_1
*
xlag(gsigmasq, _mse_)
+ _ah_1
*
xlag(ysim
**
2, _mse_);
/
*
Use scores of the GARCH model as moment conditions
*
/
eq.m1 = (-1 + ysim
**
2/gsigmasq)/ gsigmasq;
eq.m2 = (-1 + ysim
**
2/gsigmasq)
*
xlag(gsigmasq, _mse_) / gsigmasq;
eq.m3 = (-1 + ysim
**
2/gsigmasq)

*
xlag(ysim
**
2, _mse_) / gsigmasq;
/
*
Fit scores using SMM and estimated Vhat
*
/
fit m1 m2 m3 / gmm npreobs=10 ndraw=1 /
*
smm options
*
/
vdata=vhat /
*
use estimated Vhat
*
/
kernel=(bart,0,) /
*
turn smoothing off
*
/;

×