Implementing a Kalman filter in R

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Implementing a Kalman filter in R

mala10af
Hi all,

I am a student and I ma writing my master thesis about oil and gasoline options. In my master thesis I would like to estimate some parameter of the oil market. I base my pricing models according to Schwartz (1997). In order to get those data a I need to run a Kalman filter algorith with mximisation of the likelihodd. I am not that familiar with R. Can any of you suggestment a basic code to run the kalman filter´, so I can use it as a starting point to build up more complex one? Does any of you can suggest me a good book about R?

Thank you for your help.

Teo
Reply | Threaded
Open this post in threaded view
|

Re: Implementing a Kalman filter in R

Michael Weylandt
R has four "Kalman" functions -- type apropos("Kalman") to see them --
then you can get info about any of them in particular by typing ?
funcname or running example(funcname) to see worked examples.

Beyond the scope of your question, you also might be interested in
this: http://cran.r-project.org/web/packages/schwartz97/index.html

Best,

Michael

On Sat, May 19, 2012 at 9:57 AM, mala10af <[hidden email]> wrote:

> Hi all,
>
> I am a student and I ma writing my master thesis about oil and gasoline
> options. In my master thesis I would like to estimate some parameter of the
> oil market. I base my pricing models according to Schwartz (1997). In order
> to get those data a I need to run a Kalman filter algorith with mximisation
> of the likelihodd. I am not that familiar with R. Can any of you suggestment
> a basic code to run the kalman filter´, so I can use it as a starting point
> to build up more complex one? Does any of you can suggest me a good book
> about R?
>
> Thank you for your help.
>
> Teo
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Implementing-a-Kalman-filter-in-R-tp4630597.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Implementing a Kalman filter in R

Roy Mendelssohn - NOAA Federal
In reply to this post by mala10af
Hi Teo:

On May 19, 2012, at 6:57 AM, mala10af wrote:

> Hi all,
>
> I am a student and I ma writing my master thesis about oil and gasoline
> options. In my master thesis I would like to estimate some parameter of the
> oil market. I base my pricing models according to Schwartz (1997). In order
> to get those data a I need to run a Kalman filter algorith with mximisation
> of the likelihodd. I am not that familiar with R. Can any of you suggestment
> a basic code to run the kalman filter´, so I can use it as a starting point
> to build up more complex one? Does any of you can suggest me a good book
> about R?
>
> Thank you for your help.
>
> Teo

See:

http://www.jstatsoft.org/v41/i04

and

http://www.jstatsoft.org/v39/i02

-Roy


\**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: [hidden email] (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Implementing a Kalman filter in R

Giovanni Petris

In addition to the papers suggested by Roy, if you are interested in a
book-length treatment of state space models and Kalman filter in R, I
would look at

 http://www.springer.com/978-0-387-77237-0

And I would carry out the implementation in R using package dlm

Just my (biased) 2 cents....

Best,
Giovanni

On Sat, 2012-05-19 at 08:49 -0700, Roy Mendelssohn wrote:

> Hi Teo:
>
> On May 19, 2012, at 6:57 AM, mala10af wrote:
>
> > Hi all,
> >
> > I am a student and I ma writing my master thesis about oil and gasoline
> > options. In my master thesis I would like to estimate some parameter of the
> > oil market. I base my pricing models according to Schwartz (1997). In order
> > to get those data a I need to run a Kalman filter algorith with mximisation
> > of the likelihodd. I am not that familiar with R. Can any of you suggestment
> > a basic code to run the kalman filter´, so I can use it as a starting point
> > to build up more complex one? Does any of you can suggest me a good book
> > about R?
> >
> > Thank you for your help.
> >
> > Teo
>
> See:
>
> http://www.jstatsoft.org/v41/i04
>
> and
>
> http://www.jstatsoft.org/v39/i02
>
> -Roy
>
>
> \**********************
> "The contents of this message do not reflect any position of the U.S. Government or NOAA."
> **********************
> Roy Mendelssohn
> Supervisory Operations Research Analyst
> NOAA/NMFS
> Environmental Research Division
> Southwest Fisheries Science Center
> 1352 Lighthouse Avenue
> Pacific Grove, CA 93950-2097
>
> e-mail: [hidden email] (Note new e-mail address)
> voice: (831)-648-9029
> fax: (831)-648-8440
> www: http://www.pfeg.noaa.gov/
>
> "Old age and treachery will overcome youth and skill."
> "From those who have been given much, much will be expected"
> "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Implementing a Kalman filter in R

reaper3012
This post has NOT been accepted by the mailing list yet.
Hi every one,
I'm a newcomer to R and I currently want to use it to make some estimation with Kalman filter.
My model is as follow:
-Measurement equation: r_t= sv1+sv2*f_t+e_t
-Transition equations: sv1=sv1(-1)+v1_t and sv2=sv2(-1)+v2_t
where sv(-1) and sv(-2) is one-lagged values of sv1 and sv2 (which are the state variables)
So how can I use some R packages to estimate sv1 and sv2? I've read Petris' paper but i think it may not be applied in my model since the sv2 stick with an observation series of f_t.
Help and suggestions are highly appreciated.