# StempCens v0.1.0

0

Monthly downloads

0th

Percentile

## Spatio-Temporal Estimation and Prediction for Censored/Missing Responses

It estimates the parameters of a censored or missing data in spatio-temporal models using the SAEM algorithm (Delyon et al., 1999 <doi:10.1214/aos/1018031103>). This algorithm is a stochastic approximation of the widely used EM algorithm and an important tool for models in which the E-step does not have an analytic form. Besides the expressions obtained to estimate the parameters to the proposed model, we include the calculations for the observed information matrix using the method developed by Louis (1982) <https://www.jstor.org/stable/2345828>. To examine the performance of the fitted model, case-deletion measure are provided.

# StempCens

The goal of StempCens is to estimates the parameters of a censored or missing data in spatio-temporal models using the SAEM algorithm. This algorithm is a stochastic approximation of the widely used EM algorithm and an important tool for models in which the E-step does not have an analytic form. Besides the expressions obtained to estimate the parameters to the proposed model, we include the calculations for the observed information matrix using the method developed by Thomas (1982). To examine the performance of the fitted model, case-deletion measure are provided. Moreover, it computes the spatio-temporal covariance matrix.

## Installation

You can install the released version of StempCens from CRAN with:

install.packages("StempCens")


## Example

This is a basic example which shows you how to solve a common problem:

 # Initial parameter values
beta <- c(-1,1.50); phi <- 5; rho <- 0.45; tau2 <- 0.80; sigma2 <- 1.5
# Simulating data
n1 <- 5    # Number of spatial locations
n2 <- 5    # Number of temporal index
set.seed(1000)
x.coord <- round(runif(n1,0,10),9)   # X coordinate
y.coord <- round(runif(n1,0,10),9)   # Y coordinate
coordenadas <- cbind(x.coord,y.coord) # Cartesian coordinates without repetitions
coord2 <- cbind(rep(x.coord,each=n2),rep(y.coord,each=n2)) # Cartesian coordinates with repetitions
time <- as.matrix(seq(1,n2,1))      # Time index without repetitions
time2 <- as.matrix(rep(time,n1))    # Time index with repetitions
x1 <- rexp(n1*n2,2)
x2 <- rnorm(n1*n2,2,1)
x <- cbind(x1,x2)
media <- x%*%beta
# Covariance matrix
H <- as.matrix(dist(coordenadas)) # Spatial distances
Mt <- as.matrix(dist(time))       # Temporal distances
Cov <- CovarianceM(phi,rho,tau2,sigma2,distSpa=H,disTemp=Mt,kappa=0,type.S="exponential")
# Data
require(mvtnorm)
y <- as.vector(rmvnorm(1,mean=as.vector(media),sigma=Cov))
perc <- 0.2
aa=sort(y);  bb=aa[1:(perc*n1*n2)];  cutof<-bb[perc*n1*n2]
cc=matrix(1,(n1*n2),1)*(y<=cutof)
y[cc==1] <- cutof
# Estimation
est <- EstStempCens(y, x, cc, time2, coord2, inits.phi=3.5, inits.rho=0.5, inits.tau2=0.7,
type.Data="balanced", cens.type="left", method="nlminb", kappa=0,
type.S="exponential",
IMatrix=TRUE, lower.lim=c(0.01,-0.99,0.01), upper.lim=c(30,0.99,20), M=20,
perc=0.25, MaxIter=300, pc=0.2, error = 10^-6)


For the diagnostic analysis in the EstStempCens function the parameter input IMatrix needs to be TRUE.

diag <- DiagStempCens(est, type.diag="location", diag.plot = TRUE, ck=1)


## Functions in StempCens

 Name Description EstStempCens ML estimation in spatio-temporal model with censored/missing responses PredStempCens Prediction in spatio-temporal model with censored/missing responses DiagStempCens Diagnostic in spatio-temporal model with censored/missing responses CovarianceM Covariance matrix for spatio-temporal model CrossStempCens Cross-Validation in spatio-temporal model with censored/missing responses No Results!

## Details

 Type Package License GPL (>= 2) RoxygenNote 6.1.1 NeedsCompilation no Packaged 2019-02-04 13:51:30 UTC; larissam Repository CRAN Date/Publication 2019-02-08 17:43:18 UTC
 imports distances , ggplot2 , grid , gridExtra , Matrix , MCMCglmm , mvtnorm , optimx , sp , spTimer , ssym , tmvtnorm suggests testthat Contributors Victor Lachos, Larissa Matos, Katherine L. Valeriano