r – How to predict with MARSS model?

I have this code

model.list <- list()
model.list$Q <- "diagonal and unequal"
model.list$R <- "diagonal and unequal"
model.list$U <- "unequal"
model.list$Z <- "identity"
model.list$A <- "unequal"
model.list$D <- "unconstrained"
model.list$d <- t(as.matrix(covariates_jawa_new, 22, 1))

marss_model_jawa_new <- MARSS(jawa_new_ts, model = model.list, method = "BFGS")

predict(marss_model_jawa_new, n.ahead = 49, newdata = list(d = covariates_jawa_predict) )$pred %>% 
  group_by(.rownames) %>% 
  mutate(y = collapse::D(y), 
         estimate = collapse::D(estimate)) %>% 
  ggplot(aes(x = t, group = .rownames)) + 
  geom_line(aes(y = y), color = "black") + 
  geom_line(aes(y = estimate), color = "red") + 
  geom_point(aes(y = estimate), color = "red", alpha = 0.5) + 
  facet_wrap(~.rownames, scales = "free_y")

I am getting the following error while running the predict code

Error in dim(tmp)[1] == 1 && dim(tmp)[2] == 1 && tmp == 0 : 
  'length = 22' in coercion to 'logical(1)'

Read more here: Source link