Hello,

I apologize for such a basic question, but I have been trying to do this in
multiple packages without much success.  I am trying to set up a state
space model for Kalman filtering.  I am using package dlm.  The DLM is
specified by:

observation: y(t) = F(t)*theta(t) + v(t)
state: theta(t) = G(t)*theta(t-1) + w(t)

I have no problem setting up a simple example where F is constant.  I am
trying to set up a model where F(t) (the output matrix) has time varying
values (x1(t),x2(t)).  I keep getting an incompatible dimension error
despite trying a number of different permutations.  I do have a copy of the
Petris book, but I haven't had a chance to give it a thorough read at this
point.  Any assistance would be greatly appreciated:

Example code:
#n x p  output matrix
FMat<-cbind(rnorm(123),rnorm(123))

#p x p state transition matrix
GMat<-matrix(c(1,0,0,1),ncol=2)

#p x p system noise distribution
WMat<-matrix(c(0.02,0,0,0.02),ncol=2)

# nxn measurement noise
Vmat<-matrix(0,ncol=123,nrow=123)
diag(Vmat)<-0.02

#initial state mean and variance
m0Vec<-c(1,1)
c0Vec<-c(0.05,0.05)
ssMod<-dlm(FF=FMat,V=Vmat,GG=GMat,W=WMat,m0=m0Vec,C0=c0Vec)

Resulting error:

Error in dlm(FF = FMat, V = Vmat, GG = GMat, W = WMat, m0 = m0Vec, C0
= c0Vec) :
  Incompatible dimensions of matrices

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to