Skip to content
Prev 14145 / 15274 Next

Estimating a one-factor model using the DLM package

Hannu,

The MARSS package could solve your problem, but it seems like over-kill for a simple model like this.

I wrote some R code to demonstrate using dlm to fit your model. You can see the code here.

http://bit.ly/spreadModel-dlm

The code fits all three parameters: a, b, and c; plus the variances and initial value.

I did not have much time to test the code, but it seems to run correctly. To use dlm, I
had to put your model into this matrix form:

#                  _    _
#                 |      |
#   y[t] = [a, b] * |   1  | + u[t]
#                 |      |
#                 | s[t] |
#                 |_    _|
#
#  _    _     _    _     _      _     _    _
#   |      |   |      |   |        |   |      |
#   |   1  |   | 1  0 |   |   1    |   |   0  |
#   |      |  =  |      | * |        | + |      |
#   | s[t] |   | 0  c |   | s[t-1] |   | v[t] |
#   |_    _|   |_    _|   |_      _|   |_    _|
#

Good luck. I hope your model works well.

Paul


 
Paul Teetor, Elgin, IL  USA
http://quantdevel.com/public
On Tuesday, February 7, 2017 10:57 AM, Hannu Kahra <hkahra at gmail.com> wrote:
I specify the problem more clearly. My model is

y(t) = a + b*s(t) + u(t)
s(t) = c*s(t-1) + v(t)

that is a stochastic linear trend model in the DLM package obtained by
setting dlmModPoly(order = 2). The parameters b and c are fixed to 1 by
construction. In my problem I can allow b = 1, but I would like to estimate
c in the state equation. In other applications, I want to estimate
parameter b in the signal equation, as well.

I have had a look at the MARSS package and it seems that b and c can be
free parameters in estimation.

Hannu
On Tue, Feb 7, 2017 at 3:53 PM, ce <zadig_1 at excite.com> wrote:

            

            
_______________________________________________
R-SIG-Finance at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.