This is the tool to help us with the M step.
This is connected to optim, so we can use that as well.
We are still using the model
x_0 ~ N(m0, C0)
x_t = GG x_{t-1} + w_t v_t ~ N(0, W)
Y_t = FF x_t + v_t w_t ~ N(0, V)
function dlmMLE
Input:
Data:
The time series data.
Parameters:
The parameters subject to the Likelihood optimization
build:
function that returns a dlm object. That is,
build=function(x) will make the objective function the likelihood function of the dlm governed by parameter x.
Example:
buildTest <- function(x){
m <- dlmModPoly(1, dV = exp(x[1]))
m$JW <- matrix(1)
m$X <- matrix(exp(x[2]), nc = 1, nr = length(Nile))
j <- which(time(Nile) == 1899)
m$X[j,1] <- m$X[j,1] * (1+ exp(x[3]))
return(m)
}
buildTest will give me dlm dependent on three parameters, in which W is given by
exp(x[2])*(1+ exp(x[3])).