1

I have this linear gaussian state space model using KFAS package in R, I want to estimate the NA matrix of Ht and Qt with random initialization using multivariate uniform distribution then choose the maximal likelihood of that initialization, so I will find the best estimate.

How to modify the fitSSM function to do that? I still don't understand the argument of updatefn and optim in the fitSSM function.

Thankyou!

# Define initial state and covariance matrix
Zt <- matrix(c(1,rep(0,8)),1,9)
Tt <- t(matrix(c(rep(0,8),1,1,rep(0,9),1,rep(0,9),1,rep(0,9),1,rep(0,9),1,rep(0,9),1,rep(0,9),1,rep(0,9),1,0),9,9))
Rt <- matrix(c(1, rep(0,8)), 9,1)
Ht <- matrix(NA)
Qt <- matrix(NA)
P1 <- 10^(6)*diag(1,9,9)
a1 <- matrix(c(rep(0,9)),9,1)
P1inf <- diag(0,9,9)


# Define model
model <- SSModel(dt~-1+SSMcustom(Z = Zt, T = Tt, R = Rt, Q = Qt, P1 = P1,a1=a1,P1inf=P1inf), H = Ht)
fit<- fitSSM(model,inits=c(Ht=0,Qt=0),method="BFGS")
out<-KFS(fit$model, filtering = "state", smoothing = "state")
Rapiddoing
  • 11
  • 1

0 Answers0