The function `Stem.Model`

is used to create an object of class “Stem.Model”.

1 2 3 |

`...` |
List with named elements: |

`x` |
an object of class Stem.Model |

The hierarchical spatio-temporal model is given by

*z_t = X_t * β + K * y_t + e_t , e_t ~ N(0, Σ_e )*

*y_t = G * y_{t-1} + η_t , η_t ~ N(0,Σ_{η})*

for *t=1,...,n*.
The initialization is given by * y_0 ~ N(m0,C0).*

Note that *z_t* has dimension *d* by 1, where *d* is the number of spatial locations and *y_t* has dimension *p* by 1, where *p*
is the dimension of the latent process. The matrix *X_t* is the known covariate matrix and has dimension *d* by *r*, where *r* is the number of covariates.
Moreover, the *d*-dimensional square matrix *Σ_e* is given by *σ^2_ε+σ^2_ω* in the diagonal (for spatial distance *h* equal to 0), while the off-diagonal entries are given by
*σ^2_ω * C(h,θ)*, where *C(h,θ)* is the spatial covariance function. Using the default
*exponential* spatial covariance function, it is *C(h,theta)=\exp(-θ* h)*.

So the parameter vector *φ* is composed by *β*, *σ^2_ε*, *σ^2_ω*, *θ*, *G*,
*Σ_η* and *m0* (*C0* is supposed fixed).

The elements required by the function **must** have the following characteristics:

- phi
is a list composed by:

`beta`

(matrix*r * 1*),`sigma2eps`

(scalar),`sigma2omega`

(scalar),`theta`

(scalar),`G`

(matrix*p * p*),`Sigmaeta`

(matrix*p * p*),`m0`

(matrix*p * 1*),`C0`

(matrix*p*p*). Note that these values will be used as the true parameter values in the`Stem.Simulation`

function and as initial values for the EM algorithm in the`Stem.Estimation`

function

.

- K
loading matrix

*d*by*p*.- z
observation matrix

*n*by*d*.- coordinates
matrix

*d*by 2 with UTMX-UTMY or LAT-LON coordinates.- covariates
matrix

*(n * d)* r*. It is recommended to build the covariate matrix stacking the data by station. This means that you consider the*n*by*r*matrices related to each spatial location and stack them until you get a*(n * d)* r*matrix.

The function returns a list which is given by:

`skeleton` |
a list with components |

`data` |
a list with components |

No missing values are admitted in the observation matrix `z`

, in the covariates matrix `covariates`

and in the `coordinates`

matrix.

Michela Cameletti michela.cameletti@unibg.it

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.

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 | ```
#load the data
data(pm10)
names(pm10)
#extract the data
coordinates <- pm10$coords
covariates <- pm10$covariates
z <- pm10$z
#build the parameter list
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)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.