[R] Help with kalman-filterd betas using the dlm package

tom81 teoolsson at hotmail.com
Fri May 15 10:31:05 CEST 2009


I have studied both the vinguette and other material I've been able to get my
hands on and Im starting to get a better understanding. And I'm defenitly
going to buy Petris, Petrone, and Campagnoli (2009) Dynamic Linear Models
with R. But that's not publish yet so I 'm not getting much help there.

This is the set-up i am using
y[t] = a[t] + b*x[t] + V[t],  
a[t] = a[t-1] + W[t,a] 
b[t] = b[t-1] + W[t,b]

V[t] ~ N(0,V)
W[t] ~ N(0,W)
W = blockdiag(W[a],W[b])


V could be estimated from the data with a non-diagonal variance matrix of
the returns,
W would be the same estimated in the same way but where the effect of past
betas in the transition taken into account. But how do I estimate that
matrix, is that done with a MLE,SUR or some other statistical teqnique.

Im also assuming in this example that a[t] are time invariant, which gives
W[a] = 0

Appriciate any guidence.
Regards Tom
"

spencerg wrote:
> 
>       Have you worked through "vignette('dlm')"?  Vignettes are nice 
> because they provide an Adobe Acrobat Portable Document Format (pdf) 
> file with a companion R script file, which you can get as follows: 
> 
> 
> (dlm. <- vignette('dlm'))
> Stangle(dlm.$file) 
> 
> 
>       The first of these two lines opens the "pdf" file.  The second 
> creates a file "dlm.R" in the working directory (getwd()) containing the 
> R commands discussed in the "pdf" file. 
> 
> 
>       If I remember correctly, your question is answered in this vignette. 
> 
> 
>       You may also be interested in a book that is soon to appear about 
> this package:  Petris, Petrone, and Campagnoli (2009) Dynamic Linear 
> Models with R (Springer;  
> http://www.amazon.com/Dynamic-Linear-Models-R-Use/dp/0387772375/ref=sr_1_4?ie=UTF8&s=books&qid=1242162708&sr=1-4), 
> scheduled to ship in late June.  If you have long-term interest in this 
> subject, as I suspect you may, you might find this book interesting and 
> useful. 
> 
> 
>       Hope this helps.
>       Spencer Graves
> "
> tom81 wrote:
>> Hi all R gurus out there, 
>> Im a kind of newbie to kalman-filters after some research I have found
>> that
>> the dlm package is the easiest to start with. So be patient if some of my
>> questions are too basic.
>>
>> I would like to set up a beta estimation between an asset and a market
>> index
>> using a kalman-filter. Much littarture says it gives superior estimates
>> compared to OLS estimates. So I would like to learn and to use the
>> filter.
>>
>> I would like to run two types of kalman-filters, one with using a
>> random-walk model (RW) and one with a stationary model, in other worlds
>> the
>> transition equition either follow a RW or AR(1) model.
>>
>> This is how I think it would be set up;
>>
>> I will have my time-series Y,X, where Y is the response variable
>>
>> this setup should give me a RW process if I have understood the example
>> correctly
>> mydlmModel = dlmModReg(X)  + dlmModPoly(order=1)
>>
>> and then run on the dlm model
>> dlmFilter(Y,mydlmModel )
>>
>> but setting up a AR(1) process is unclear, should I use dlmModPoly or the
>> dlmModARMA to set up the model.
>>
>> And at last but not the least, how do I set up a proper build function to
>> use with dlmMLE to optimize the starting values.
>>
>> Regards Tom
>>
> 
> ______________________________________________
> R-help at r-project.org 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Help-with-kalman-filterd-betas-using-the-dlm-package-tp23473796p23555576.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list