Page 1 of 1

Estimating a AR(1) process

Posted: Wed Aug 04, 2010 12:12 pm
by xihapipi
Hi,
I'm trying to estimate parameters of a mean-reverting stochastic process, which can be written in the equation as attached in the word document.
I'm very inexperienced with eviews and I'm having problem running the estimation using the maximum likelihood estimation.
I have tried to follow the manual and written the log likelihood specification also shown in the word document attached, but returned syntax error...

Can anyone what I'm doing wrong here please? And how can I do this estimation in eviews?

Any suggestion will be greatlly appreciated. Thanks

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 1:12 pm
by EViews Gareth
Posting your workfile is probably helpful.

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 1:29 pm
by startz
You might begin by just estimating this as a nonlinear regression. The only thing you wouldn't get is the standard errors for sigma^2.

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 1:40 pm
by xihapipi
I have attached my workfile.
Basically the time series y, is the log of oil prices (weekly) data over a period, which I assume that it follows the process

dY(t)=a(b-Y(t))dt+vdWt, which is a Ornstein-Uhlenbek stochastic process.
(sorry i can't type lamda here, so the "a" in this equation is the lamda in the word doc, and the "b" in this equation is the x-bar in the word doc, and v here is the sigma in the word doc)

And in discrete time, I should be able to estimate the parameters of the process by looking at the AR(1) process as in the word document.

Sorry my questions may seem quite stupid, as I have really limited knowledge of Eviews, but I am in desperate need to figure out how to do this...

Many thanks

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 1:44 pm
by xihapipi
You might begin by just estimating this as a nonlinear regression. The only thing you wouldn't get is the standard errors for sigma^2.
Could you elaborate a bit more please? Do I just regress it using "Equation", and enter my regression equation, or is there a functionaliy for non-linear regressio in eviews?

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 1:52 pm
by EViews Gareth
You were missing a multiplication sign in your definition of RES. Also, you probably want to time shift things a bit. I think a working definition of RES would be something like:

Code: Select all

res=y-c(1)*(1-exp(-c(2)*0.02))-exp(-c(2)*0.02)*y(-1)
(note you'll need to set the C vector equal to 1 before hand to get this to estimate)

However, as Startz points out, you're probably better of doing it in an equation, with a specification of:

Code: Select all

Y=C(1)*(1-EXP(-C(2)*0.02))-EXP(-C(2)*0.02)*Y(-1)

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 2:06 pm
by xihapipi
You were missing a multiplication sign in your definition of RES. Also, you probably want to time shift things a bit. I think a working definition of RES would be something like:

Code: Select all

res=y-c(1)*(1-exp(-c(2)*0.02))-exp(-c(2)*0.02)*y(-1)
(note you'll need to set the C vector equal to 1 before hand to get this to estimate)

However, as Startz points out, you're probably better of doing it in an equation, with a specification of:

Code: Select all

Y=C(1)*(1-EXP(-C(2)*0.02))-EXP(-C(2)*0.02)*Y(-1)

Thank you for your answer. But I don't understand what you meant by "setting the vector C equal to 1"... sorry, could you explain to me what this is and how I can do this please? thank you so much.

I don't fully know what's the problem here but I don't think the equation Y=C(1)*(1-EXP(-C(2)*0.02))-EXP(-C(2)*0.02)*Y(-1) works - as I think the residual term depends on c(2), and it generates a very weird result (a very large number for c(2), lamda) when i ran it... What i did was that I ran the above regression with LS criteria using the object/equation. Is there something that I'm doing wrong here?


I apologise for the length of my questions and my limited knowledge...

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 2:09 pm
by EViews Gareth

Code: Select all

c=1
In the command window.
You'll also need to estimate from the second period onwards

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 2:15 pm
by xihapipi
@logl logl1

res=y-c(1)*(1-exp(-c(2)*0.02))-exp(-c(2)*0.02)*y(-1)
var=c(3)*0.14
c=1
logl1=log(@dnorm(res/@sqrt(var)))-log(var)/2

you mean like this?

Re: Estimating a AR(1) process

Posted: Wed Aug 04, 2010 5:24 pm
by startz
You were missing a multiplication sign in your definition of RES. Also, you probably want to time shift things a bit. I think a working definition of RES would be something like:

Code: Select all

res=y-c(1)*(1-exp(-c(2)*0.02))-exp(-c(2)*0.02)*y(-1)
(note you'll need to set the C vector equal to 1 before hand to get this to estimate)

However, as Startz points out, you're probably better of doing it in an equation, with a specification of:

Code: Select all

Y=C(1)*(1-EXP(-C(2)*0.02))-EXP(-C(2)*0.02)*Y(-1)
snip
I don't fully know what's the problem here but I don't think the equation Y=C(1)*(1-EXP(-C(2)*0.02))-EXP(-C(2)*0.02)*Y(-1) works - as I think the residual term depends on c(2), and it generates a very weird result (a very large number for c(2), lamda) when i ran it... What i did was that I ran the above regression with LS criteria using the object/equation. Is there something that I'm doing wrong here?


I apologise for the length of my questions and my limited knowledge...
The residual doesn't depend on c(2), although you would need c(2) to back out the sigma^2 parameter.
You might start out with

Code: Select all

ls y c y(-1)
and then back out lambda and sigma^2 by hand. That's the maximum likelihood estimator.

Re: Estimating a AR(1) process

Posted: Thu Aug 05, 2010 11:29 am
by xihapipi
I think I'm getting what I want now. Thank you so much!