Logl: Order of Evaluation

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

maxchen
Posts: 191
Joined: Fri Oct 10, 2008 4:03 pm

Logl: Order of Evaluation

Postby maxchen » Tue Dec 02, 2008 4:35 am

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?

trubador
Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

Re: Logl: Order of Evaluation

Postby trubador » Tue Dec 02, 2008 8:03 am

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...

maxchen
Posts: 191
Joined: Fri Oct 10, 2008 4:03 pm

Re: Logl: Order of Evaluation

Postby maxchen » Tue Dec 02, 2008 4:14 pm

thanks for your reply.
I like to understand the mechanism of @byobs.


Return to “Programming”

Who is online

Users browsing this forum: Google [Bot] and 26 guests