# Stem.Estimation: ML Estimation In Stem: Spatio-temporal models in R

## Description

The function computes the maximum likelihood estimates of the unknown parameters of a hierarchical spatio-temporal model of class “Stem.Model”. The estimates are obtained using Kalman filtering and EM algorithm.

## Usage

 ```1 2``` ```Stem.Estimation(StemModel, precision = 0.01, max.iter = 50, flag.Gdiag = TRUE, flag.Sigmaetadiag = TRUE, cov.spat = Sigmastar.exp) ```

## Arguments

 `StemModel` an object of class “Stem.Model” given as output by the `Stem.Model` function. `precision` a small positive number used for the algorithm convergence. Default is equal to 0.01. See `DETAILS` below. `max.iter` maximum number of iterations for the EM algorithm. Default is equal to 50. `flag.Gdiag` logical, indicating whether the transition matrix G is diagonal. `flag.Sigmaetadiag` logical, indicating whether the variance-covariance matrix of the state equation Σ_η is diagonal. `cov.spat` type of spatial covariance function. For the moment only the exponential function is implemented.

## Details

This function estimates the vector parameter `phi` of the hierarchical spatio-temporal model of class “Stem.Model” using Kalman filtering and EM algorithm. The algorithm details and formulas are given in Fasso' and Cameletti (2007, 2009). Note that some parameters (`beta`, `sigma2omega`, `G`, `Sigmaeta` and `m0`) are updated using closed form solutions while `theta` and `sigma2epsilon` using the Newton-Raphson algorithm.

For initializing the algorithm the values contained in `StemModel\$skeleton\$phi` are used as initial values. The algorithm converges when the following convergence criteria (named in the output as `conv.par` and `conv.log` respectively) are jointly met

||φ^{i+1}-φ^{i} || / ||φ^{i}|| < π

||log L(φ^{i+1}-log L(φ^{i})|| / ||log L(φ^{i})||<π

where π is given by the `precision` option and i is the number of iteration. The use of these relative criteria instead of some other absolute ones makes it possible to correct for the different parameter scales.

## Value

The function returns an object of class “Stem.Model” which is a list given by:

 `skeleton` As the `skeleton` component of the `StemModel` object given in input. `data` As the `data` component of the `StemModel` object given in input. `estimates` A list of four objects: `phi.hat`, `y.smoothed`, `loglik`, `convergence.par` here described. `phi.hat` is a list with the parameter ML estimates (`sigma2omega`, `beta`, `G`, `Sigmaeta`, `m0`, `C0`, `theta`, `sigma2eps`). `y.smoothed` is a `ts` object (n by p) which is the output of the Kalman filtering procedure. `loglik` is the log-likehood value. `convergence.par` is a list of 4 objects with some information about the convergence of the algorithm: `conv.log` and `conv.par` are logical values for the two convergence criteria described above; `iterEM` is the number of iterations for the EM algorithm and `iterNR` is the number of Newton-Raphson iterations for each EM algorithm iteration.

## Author(s)

Michela Cameletti [email protected]

## References

Amisigo, B.A., Van De Giesen, N.C. (2005) Using a spatio-temporal dynamic state-space model with the EM algorithm to patch gaps in daily riverflow series. Hydrology and Earth System Sciences 9, 209–224.

Fasso, A., Cameletti, M., Nicolis, O. (2007) Air quality monitoring using heterogeneous networks. Environmetrics 18, 245–264.

Fasso', A., Cameletti, M. (2007) A general spatio-temporal model for environmental data. Tech.rep. n.27 Graspa - The Italian Group of Environmental Statistics - http://www.graspa.org.

Fasso', A., Cameletti, M. (2009) A unified statistical approach for simulation, modelling, analysis and mapping of environmental data. Accepted for publication by Simulation: transaction of the Society for Modeling and Simulation International.

Mc Lachlan, G.J., Krishnan, T. (1997) The EM Algorithm and Extensions. Wiley, New York.

Shumway, R.H., Stoffer, D.S. (2006) Time Series Analysis and Its Applications: with R Examples. Springer, New York.

Xu, K., Wikle, C.K. (2007) Estimation of parameterized spatio-temporal dynamic models. Journal of Statistical Inference and Planning 137, 567–588.

See Also `Stem.Model` and `pm10`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30``` ```#load the data data(pm10) #extract the data coordinates <- pm10\$coords covariates <- pm10\$covariates z <- pm10\$z #build the parameter list #(the phi list is used for the algorithm starting values) phi <- list(beta=matrix(c(3.65,0.046,-0.904),3,1), sigma2eps=0.1, sigma2omega=0.2, theta=0.01, G=matrix(0.77,1,1), Sigmaeta=matrix(0.3,1,1), m0=as.matrix(0), C0=as.matrix(1)) K <-matrix(1,ncol(z),1) mod1 <- Stem.Model(z=z,covariates=covariates, coordinates=coordinates,phi=phi,K=K) class(mod1) is.Stem.Model(mod1) #mod1 is given as output by the Stem.Model function mod1.est <- Stem.Estimation(mod1) phi.estimates <- unlist(mod1.est\$estimates\$phi.hat) ```

### Example output

```Loading required package: mvtnorm
[1] "Stem.Model"
[1] TRUE
****************EM Algorithm - iteration n. 1
***NR Algorithm - iteration n. 1
***NR Algorithm - iteration n. 2
***NR Algorithm - iteration n. 3
***NR Algorithm - iteration n. 4
***NR Algorithm - iteration n. 5
****************EM Algorithm - iteration n. 2
***NR Algorithm - iteration n. 1
***NR Algorithm - iteration n. 2
***NR Algorithm - iteration n. 3
***NR Algorithm - iteration n. 4
****************EM Algorithm - iteration n. 3
***NR Algorithm - iteration n. 1
***NR Algorithm - iteration n. 2
***NR Algorithm - iteration n. 3
***NR Algorithm - iteration n. 4
***NR Algorithm - iteration n. 5
****************EM Algorithm - iteration n. 4
***NR Algorithm - iteration n. 1
***NR Algorithm - iteration n. 2
****************EM Algorithm - iteration n. 5
***NR Algorithm - iteration n. 1
***NR Algorithm - iteration n. 2
****************EM Algorithm - iteration n. 6
***NR Algorithm - iteration n. 1
***NR Algorithm - iteration n. 2
****************EM Algorithm - iteration n. 7
```

Stem documentation built on May 29, 2017, 11:12 p.m.