R 多元模型估计

R 多元模型估计,r,kalman-filter,mle,state-space,R,Kalman Filter,Mle,State Space,我试图使用R中的dlmMLE函数作为dlm库的一部分来估计多元状态空间模型,但不断得到以下错误 Error in fit < dlmMLE(Y, parm = c(rep(0, 10)), build = model) : comparison of these types is not implemented 我已在R中指定型号,如下所示 model <- function(x) { FF <- matrix(c(x[1:3],rep(0,3),diag(3))

我试图使用R中的
dlmMLE
函数作为
dlm
库的一部分来估计多元状态空间模型,但不断得到以下错误

Error in fit < dlmMLE(Y, parm = c(rep(0, 10)), build = model) : 
  comparison of these types is not implemented
我已在R中指定型号,如下所示

model <- function(x) {

  FF <- matrix(c(x[1:3],rep(0,3),diag(3)), nr=3)
  V  <- diag(c(exp(x[4:6])))

  TL <- matrix(c(x[7],1,x[8],0),nr=2)
  TR <- matrix(c(rep(0,2*3)),nr=2)
  BL <- matrix(c(rep(0,2*3)), nc=2)
  BR <- diag(3)

  GG <- rbind(cbind(TL,TR),cbind(BL,BR))
  W  <- diag(c(exp(x[9]),0,exp(x[10]),rep(0,2)))

  m0 <- rep(0,5)
  C0 <- 100*diag(5)

  dlm(FF=FF, V=V, GG=GG, W=W, m0=m0,C0=C0)
}

# where x[1:10] correspond to beta[1:3], e[1:3], phi[1:2], v and w, respectively.

fit < dlmMLE(Y, parm=c(rep(0,10)), build=model)
#Y is the matrix containing time series for observable variables y1, y2, y3

model试试
谢谢。我真不敢相信我错过了。
model <- function(x) {

  FF <- matrix(c(x[1:3],rep(0,3),diag(3)), nr=3)
  V  <- diag(c(exp(x[4:6])))

  TL <- matrix(c(x[7],1,x[8],0),nr=2)
  TR <- matrix(c(rep(0,2*3)),nr=2)
  BL <- matrix(c(rep(0,2*3)), nc=2)
  BR <- diag(3)

  GG <- rbind(cbind(TL,TR),cbind(BL,BR))
  W  <- diag(c(exp(x[9]),0,exp(x[10]),rep(0,2)))

  m0 <- rep(0,5)
  C0 <- 100*diag(5)

  dlm(FF=FF, V=V, GG=GG, W=W, m0=m0,C0=C0)
}

# where x[1:10] correspond to beta[1:3], e[1:3], phi[1:2], v and w, respectively.

fit < dlmMLE(Y, parm=c(rep(0,10)), build=model)
#Y is the matrix containing time series for observable variables y1, y2, y3