Description Usage Arguments Details Value Author(s) See Also Examples
Does Kalman filtering using KFS
.
1 | Fkfilter(ss, tvar)
|
ss |
object of class |
tvar |
vector with four elements indicating the dynamic nature of
matrices in the object |
The Kalman filter implemented in KFAS provides faster computations than
kfilter
, however requires alternative specification of
the state space model. This function transform an object of class
SS
into an object on which the filter implemented in KFAS
may be applied.
List with two objects. An object kfas
with components as specified in KFS
, as well as the input object ss
with updated m
, C
and loglik
.
Anette Luther Christensen and Claus Dethlefsen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Formulates Gaussian state space model:
## Trend: local linear
## Seasonal variation: sine function with frequency = 1
m1 <- SS( Fmat = function(tt, x, phi) {
Fmat <- matrix(NA, nrow=3, ncol=1)
Fmat[1,1] <- 1
Fmat[2,1] <- cos(2*pi*tt/12)
Fmat[3,1] <- sin(2*pi*tt/12)
return(Fmat)
},
Gmat = function(tt, x, phi) {
matrix(c(1,0,0,0,1,0,0,0,1), nrow=3)
},
Wmat = function(tt, x, phi) {matrix(c(0.01,0,0,0,0.1,0,0,0,0.1), nrow=3)},
Vmat = function(tt, x, phi) {matrix(1)},
m0 = matrix(c(0,0,0), nrow=1),
C0 = matrix(c(1,0,0,0,0.001,0,0,0,0.001), nrow=3, ncol=3)
)
## Simulates 100 observation from m1
m1 <- recursion(m1, 100)
#filtered <- Fkfilter(m1, tvar=c(m1$n, 1, 1, 1))
filtered <- kfilter(m1)
#plot(filtered$ss)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.