On Tue, 6 Jan 2015, Daniel Bencik wrote:
I am struggling with my variable lists once again. I expected the
following
two ML estimations to give the same results, but they don't. Any ideas?
#estimation 1
scalar c_ = 0.1
scalar rng = 0.1
scalar err = 0.2
mle ll = -ln(lambda) - sqrtPark/lambda
series lambda = mean(sqrtPark)
series lambda = c_ + rng * sqrtPark(-1) + err * lambda(-1)
params c_ rng err
end mle --robust
#estimation 2
list xDepVars = sqrtPark
list xExpVars = sqrtPark(-1)
c_ = 0.1
rng = 0.1
err = 0.2
series xDepVar = xDepVars[1]
series xExpVar = xExpVars[1]
mle ll2 = -ln(lambda2) - xDepVar/lambda2
series lambda2 = mean(xDepVar)
series lambda2 = c_ + rng * xExpVar + err * lambda2(-1)
params c_ rng err
end mle --robust
Sorry, I realize that the answer I gave yesterday in
http://lists.wfu.edu/pipermail/gretl-users/2015-January/010564.html
will not do!
My explanation was that an expression such as "xDepVars[1]" gives the
integer ID number of the series at position 1 in the named list, not
the series itself. Well, that was true, but it's not consistent with
the documentation I added recently on indexing into a list, and it's
surely not what users will expect.
So today I've modified the result of indexing into a list to match the
doc and the most likely expectation. You now get a series, and your ML
script should behave as you intended. That's in CVS and snapshots.
Note that if you wish to retrieve the ID number of the series at a
certain position in a list this can be done by converting the list
into a matrix. The following little script illustrates this point as
well as the effect of indexing into a list directly.
<hansl>
open data4-1
list L = sqft price
series x = L[1]
print sqft x --byobs
ols L[2] 0 L[1]
matrix m = L
printf "The series at position 1 in L has ID %d\n", m[1]
</hansl>
Allin