I am using the latest KFAS package and it's SSMarima method to build an AR(1). I followed the instruction given in this https://www.jstatsoft.org/article/view/v078i10. Below is my code snippet.
However, after running the fitSSM method, i am getting the error "Error in is.SSModel(do.call(updatefn, args = c(list(inits, model), update_args)), : Matrix P1 contains nonzero diagonal elements for diffuse states." My dataset is a weekly dataset of 52 data points. Any help please?
`model_arima <- SSModel(ssm_total_vol$total_vol ~ SSMarima(ar = 0, d = 1, Q = 1))
update_model <- function(pars, model) {
tmp <- SSMarima(ar = pars[1], d = 0, Q = pars[2])
model["R", states = "arima"] <- tmp$R
model["Q", states = "arima"] <- tmp$Q
model["P1", states = "arima"] <- tmp$P1
model
}
fit_arima <- fitSSM(model_arima, inits = c(0, 1), updatefn = update_model,
method = "L-BFGS-B")`
You have
d=1in your initial model definition (indicating differences), butd=0in theupdate_modelfunction.