EMalgo {sspir} | R Documentation |
Estimates variance matrices of the observation- and latent process in a Gaussian state space model given as input, using the EM algorithm.
EMalgo(ss, epsilon = 1e-06, maxiter = 50, Vstruc = function(V) { return(V)}, Wstruc = function(W) { return(W)}, print.ite = F)
ss |
an object of class SS . |
epsilon |
a (small) positive numeric giving the tolerance of the
maximum relative differences of Vmat and Wmat between iterations. |
maxiter |
a positive integer giving the maximum number of iterations to run. |
Vstruc |
a function specifying the structure of the variance matrix of the observation model if such is available. |
Wstruc |
a function specifying the structure of the variance matrix of the state model if such is available. |
print.ite |
A logical specifying whether information should be printed after each iteration. |
The initial variance matrices are to be specified in the model specification and structures of the variance matrices may be specified by the user by the functions Vstruc
and Wstruc
. As default these are assigned NA
, if not specified they are not estimated, hence it is possible to estimate only the observation variance matrix or the evolution variance matrix. The EM algorithm requires the variance matrices to be estimated are constant, however if a variance matrix is not be estimated it may be non-constant.
The output provided by the function is the smoothed Gaussian model along with the estimated variance matrices, maximum values of the log likelihood function for each iterations and the number of iteration upon convergence.
|
the value from smoother . |
|
the estimate of the observation variance matrix, which is provided if the input of Vstruc is of class function , otherwise as input of Vmat . |
|
the estimate of the observation variance matrix, which is provided if the input of Wstruc is of class function , otherwise as input of Wmat . |
|
maximum value of log likelihood function for each iteration. |
|
number of iterations upon convergence. |
Anette Luther Christensen
m1 <- SS( Fmat = function(tt,x,phi) { Fmat <- matrix(NA,3,1) Fmat[1,1] <- 1 Fmat[2,1] <- cos(2*pi*tt/12) Fmat[3,1] <- sin(2*pi*tt/12) return(Fmat) }, Gmat = function(tt,x,phi) { return(matrix(c(1,0,0,0,1,0,0,0,1),nrow=3)) }, Wmat = matrix(c(0.01,0,0,0,0.1,0,0,0,0.1),nrow=3), Vmat = matrix(1), m0 = matrix(c(0,0,0),nrow=1), C0 = matrix(c(1,0,0,0,0.001,0,0,0,0.001),nrow=3,ncol=3) ) m1 <- recursion(m1,100) Wstruc <- function(W){ W[1,2:3]<-0 W[2:3,1]<-0 W[2,2]<-(W[2,2]+W[3,3])/2 W[3,3]<-W[2,2] W[2,3]<-0 W[3,2]<-0 return(W)} estimates <- EMalgo(m1,Wstruc=Wstruc) plot(estimates$model)