1

I am using KFAS to fit a dynamic logistic model of the form;

y^=β_t*x+ϵ

Where y is a vector of length n, beta a vector of length p, x a matrix of n*p.

β_t=β_(t−1)+η

So the regression parameters change over time, and act as latent variables to be estimated by the filter.

How can I specify such a model in R? I can't use the MARSS package because I need a logistic link function, but the KFAS package I've been trying to use (which accepts binomial distributions) is very poorly documented.

The key problem appears to be that I have multiple observations per time period, which may be unsupported by this package. For an example of my issue, please see the below code - it should demonstrate ten time period with 2-3 obs in each, but KFAS thinks each row is a seperate time period and that there are 22 of these instead of ten.

library(KFAS)
y = c(1,0,0,0,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1)
i = seq.Date(from = as.Date("2014-01-01"), as.Date("2014-01-10"), length.out = 22)
x = rnorm(n = 22, mean = 1, sd = 2)

a =   model = SSModel(y ~ 
                    SSMregression(~x),
                  distribution = "binomial")

fit = fitSSM(a, inits = c(0,0))
analystic
  • 351
  • 5
  • 17

0 Answers0