helske / KFAS

KFAS: R Package for Exponential Family State Space Models
64 stars 17 forks source link

Problem to set a state space model #7

Closed rodrigopmaranhao closed 9 years ago

rodrigopmaranhao commented 9 years ago

Hi. I'm having some issues to set my SSMcustom.

Here is what I'm doing:

y=base1$close
Z=array(rbind(t(base2$close),t(rep(1,length(y)))),dim=c(1,2,length(y)))
matT=diag(1,2,2)
matR=matT
Q=matT*0.01
modeloCustom=SSMcustom(Z=Z,T=matT,R=matR,Q=Q,P1inf=diag(1,2,2),n=length(y))

However, if I check

is.SSModel(modeloCustom)

It returns false.

Also, if I try:

modelo=SSModel(y~-1+modeloCustom)

It shows:

> modelo=SSModel(y~-1+modeloCustom)
Error in model.frame.default(formula = y ~ -1 + modeloCustom, na.action = na.pass) : 
  invalid type (list) for variable 'modeloCustom'

What I'm doing wrong? Someone could help me?

Thank you.

helske commented 9 years ago

Outputs from SSMcustom, SSMregression etc. are just lists, so is.SSModel(modeloCustom) returning FALSE is correct. Those functions are meant to be used inside SSModel call, like this:

 modelo <- SSModel(y~ -1 + SSMcustom(Z=Z,T=matT,R=matR,Q=Q,P1inf=diag(1,2,2)))

You can see multiple examples in the main help page of the package (?KFAS).