Page 1 of 1

Logl: Order of Evaluation

Posted: Tue Dec 02, 2008 4:35 am
by maxchen
Dear all

When evaluating by obs, check the following code

Code: Select all

'create workfile !T = 100 wfcreate(page=OLS) u 1 !T 'genr the data rndseed(type=mt) 12357 genr x = rnd genr y = 5 +3*x +nrnd 'Logl obj logl L11 L11.append @logl L 'L11.append @byeqn L11.append e = y -c(1) -c(2)*x L11.append v = @sum(e^2)/!T L11.append L = log(@dnorm(e/@sqrt(v))) - log(v)/2 'init the series !init = 1 if !init then genr e = 0 genr v = 1 endif 'estimate L11.ml(showopts)
Questions
  • There will be an error. However, check the series e and v, e(1)=@elem(y,@otod(1)), v(1)=0! why not v(1) = (@elem(y,@otod(1)))^2 /100 ?
  • if !init = 1 change to !init = 0, then after the running error, the series e=y, and v=na, why e is evaluated for all obs?

Re: Logl: Order of Evaluation

Posted: Tue Dec 02, 2008 8:03 am
by trubador
First of all, you do not need to define the variance as a function of other series, if it is actually a fixed value. You can simply express it in terms of another coefficient (positive definite) and estimate it along with other fixed parameters.

Your specification requires the calculation of aggregate statistics based on intermediate series. In other words, the series v is sum of the series e. Therefore you should evaluate your likelihood by equation instead of by observation. Or you can drop the @sum function and try to modify the likelihood function. However, the results will be different then, since your specification of variance is dynamic and depends on the residual.

You do not need the "if condition" by the way...

Re: Logl: Order of Evaluation

Posted: Tue Dec 02, 2008 4:14 pm
by maxchen
thanks for your reply.
I like to understand the mechanism of @byobs.