a programming error for matrix in logl

For questions regarding programming in the EViews programming language.

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

liumartin
Posts: 10
Joined: Mon Mar 15, 2010 6:01 pm

a programming error for matrix in logl

Postby liumartin » Sun Oct 17, 2010 9:12 am

Dear there

Recently I am trying to programming a Kalman filter in Eviews 6.0. In this programming, I use matrix and vector operation in logl for likelihood function. However, when I am running it, it always report some errors regarding the matrix and vector as in the following picture. I am wondering if anyone could tell if matrix or vector actually can be used in logl or not. Sometimes I think we only could use series in logl, right??? If this is true, that's really inconvenience. I really appreciate anyone help.
Capture.JPG
error in programming
Capture.JPG (45.33 KiB) Viewed 4197 times
The following is my Eviews code


' Improving out-of-sample equity premium prediction: the role of learning
'David E. Rapach, Tao Zha, and Guofu Zhou

'open oos.wf1 workfile which includes the data imported already
wfopen "C:\Users\MM\Desktop\OOS-Learning materials\oos"

delete s0
delete s1
sample s0 1926m12 2008m12
sample s1 1927m02 2008m12
smpl s0

series y=eret
series x1=dy
series x2=de

'get starting values from ols
equation eq1.ls eret c bm de
'Initialization of parameters and starting values
coef(4) mu
mu(1)= eq1.c(1)
mu(2)=eq1.c(2)
mu(3)=eq1.@se^2
mu(4)=0.1
vector(@rows(y)) alpha
alpha(1)=eq1.c(3)
alpha(2)=0.2
vector(@rows(y)) H
H(1)=0.02
vector(@rows(y)) yy
yy(2)=alpha(2)*x2(1)


vector x22=x2
vector x11=x1
'=================
!mlog2pi = 2*log(2*@acos(-1))
'..............................................................................
'LOG LIKELIHOOD
'set up the likelihood
' 1) open a new blank likelihood object name oos
' 2) specify the log likelihood model by append
'...............................................................................


logl ll1
ll1.append @logl logl1

for !i=3 to @rows(y)
ll1.append H(!i-1)= 1/( 1/H(!i-2) + mu(4)*( x22(!i-2)*x22(!i-2)-1/H(!i-2) ) )
ll1.append alpha(!i)= alpha(!i-1) + mu(4)*H(!i-1)*x22(!i-2)*( x11(!i-1)-x22(!i-2)*alpha(!i-1) )
ll1.append yy(!i)=alpha(!i)*x22(!i-1)
next



ll1.append res1 = y-mu(1)-mu(2)*x1(-1)-yy(-1)
ll1.append logl1 =-0.5*!mlog2pi -0.5*log(mu(3))-0.5*(res1^2/mu(3))

smpl s1
ll1.ml(showopts, m=100, c=1e-5)

'change below to display different output
show ll1.output

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

a programming error for matrix in logl

Postby EViews Gareth » Sun Oct 17, 2010 9:29 am

Matrix objects cannot be used inside a LogL.

liumartin
Posts: 10
Joined: Mon Mar 15, 2010 6:01 pm

Re: a programming error for matrix in logl

Postby liumartin » Mon Oct 18, 2010 9:39 am

Is there any way to work out this matrix loop? something like writing a function or subroutine, then call the subroutine from logl.............

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: a programming error for matrix in logl

Postby EViews Gareth » Mon Oct 18, 2010 10:59 am

LogL objects exist outside of the programming language, so you can not use any programming language constructs (loops, subroutines etc...) inside them.

liumartin
Posts: 10
Joined: Mon Mar 15, 2010 6:01 pm

Re: a programming error for matrix in logl

Postby liumartin » Mon Oct 18, 2010 12:36 pm

Is there a way to not use matrix in my code for logl? I cannot figure out how to do my code if I do not use loops or matrix? Thanks


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests