On Mon, 2 Jun 2014, Daniel Bencik wrote:
Dear all, I am trying to ML estimate a model
from
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1884237 and the
following code, with Rng being the variable of interest,
RANGE = Rng
scalar rng = 0.1
scalar err = 0.2
scalar gamma = 1
mle ll = 0.5*ln(theta) - theta*lambda + RANGE *(ln(RANGE)-1) -
lngamma(RANGE+1) + theta*RANGE( 1 + ln(lambda/RANGE))
series lambda = mean(RANGE)
series lambda = c + rng*RANGE(-1) + err*lambda(-1)
params gamma c rng err
end mle --robust
returns "lag order: argument 2 should be scalar, is series. Data types not
conformable for operation". As far as I undestand, the problem is the first
element of LL, but have no clue how to correct it. Any hint is much
appreciated.
I think there's a "*" missing in the rightmost element of the
loglikelihood. The following seems to work quite nicely here (of course,
this isn't supposed to be right, it's just something you can take
inspiration from).
<hansl>
function series loglik(series y, scalar theta,
scalar c, scalar a, scalar b, scalar m0)
series ret = NA
if (a<=0) || (b<0)
return ret
endif
series m = m0
series m = c + b*m(-1) + a*y(-1)
series k = 0.5*ln(theta) - theta*m
series ret = k + y*(ln(y)-1) - lngamma(y+1) + theta*y*(1 + ln(m/y))
return ret
end function
include yahoo_get.gfn
nulldata 2500
setobs 5 2005-01-01
list X = yahoo_full("IBM")
range = gap_filler(IBM_h - IBM_l, 2)
scalar a = 0.1
scalar b = 0.8
scalar c = 0.01
scalar theta = 1
#scalar gamma = 1
scalar m0 = mean(range)
mle ll = loglik(range, theta, c, a, b, m0)
params theta c a b
end mle --robust --verbose
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------