On Tue, 15 Nov 2011, Qi Shi wrote:
Dear all,
I want to reproduce Verbeek's Table 5.4, below is my scripts:
There are a few problems with your script, but the most important one is
that once you have defined a series as a function of a parameter, the
contents of that series don't change just because you change the
parameter's value; that is the way a spreadsheet works, not a programming
language like hansl. For example: after
<hansl>
scalar delta=0.5
scalar gamma=0.5
series e0=delta*cons^(-gamma)*(1+rf)-1
</hansl>
the contents of e0 are set to
e0
1959:02 -0.4993965
1959:03 -0.5020569
1959:04 -0.4966915
1959:05 -0.5009903
1959:06 -0.4981722
1959:07 -0.4983170
1959:08 -0.4984926
1959:09 -0.4996040
1959:10 -0.4966996
1959:11 -0.4982402
...
Then, the parameters delta and gamma are iteratively changed within the
gmm block, but that doesn't change the contents of e0 (and e1, e2 etc, for
that matter).
To replicate Verbeek's example, take a look at the script below:
<hansl>
function series mrate(series cons, scalar discrat, scalar riskad)
return discrat * cons ^ (-riskad)
end function
open pricing.gdt --quiet
set force_hc on # not terribly correct, but
# necessary to replicate exactly
# build the instruments
list exlist = null
loop i=1..10 --quiet
series ex$i = r$i - rf
exlist += ex$i
end loop
series gf = 1 + rf
scalar d = 0.5
scalar g = 10
matrix V = I(11)
series m oc1 # initialize the series with the
# orthogonality conditions
/* first step */
gmm
series m = mrate(cons,d,g)
series oc1 = m * gf - 1
orthog oc1 ; const
orthog m ; exlist
weights V
params d g
end gmm
/* iterated GMM */
gmm
series m = mrate(cons,d,g)
series oc1 = m * gf - 1
orthog m ; exlist
orthog oc1 ; const
weights V
params d g
end gmm --iterate
</hansl>
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti