Obtain samples from predictive distribution in space and time given the posterior of the hyperparameters.
1 2 3 4 
y 
Observed data in an T x N matrix with columns and rows corresponding to time and space, respectively. 
x 
Covariates in an array of dimensions p x T X N, where p denotes the number of covariates, T the number of time points, and N the number of spatial points. 
tPred 
Time points where predictions are made.This needs to be a vector if predictions are made at multiple times. For instance, if T is the number of time points in the data 'y', then tPred=c(T+1, T+2) means that predictions are made at time 'T+1' and 'T+2'. If 'xPred' and 'yPred' are empty, then predictions are made at all spatial points for each time point in 'tPred'. Otherwise 'xPred' and 'yPred', or 'sPred, need to have the same length as 'tPred', and predictions are made at the points (tPred,xPred,yPred), ore (tPred, sPred), respectively. 
sPred 
Vector of indices of grid cells (positions of locations in the stacked spatial vector) where predictions are made. This is an alternative to specifying the coordinates 'xPred' and 'yPred'. 
xPred 
Vector of xcoordinates of spatial points where predictions are made. This is an alternative to specifying the grid cell in 'sPred'. 
yPred 
Vector of ycoordinates of spatial points where predictions are made. This is an alternative to specifying the grid cell in 'sPred'. 
spateMCMC 
'spateMCMC' object obtained from 'spate.mcmc' containing the posterior of the hyperparameters and information on the model used. 
Nsim 
Number of samples used to characterize the predictive distribution. 
BurnIn 
Length of burnin period. 
coord 
If specified, this needs to be a matrix of dimension N x 2 with coordinates of the N observation points. Observations in 'y' can either be on a square grid or not. If not, the coordinates of each observation point need to be specified in 'coord'. According to these coordinates, each observation location is then mapped to a grid cell. If 'coord' is not specified, the observations in 'y' are assumed to lie on a square grid with each axis scaled so that it has unit length. 
lengthx 
Use together with 'coord' to specify the length of the xaxis. This is usefull if the observations lie in a rectangular area instead of a square. The length needs to be at least as large as the largest xdistance in 'coord. 
lengthy 
Use together with 'coord' to specify the length of the yaxis. This is usefull if the observations lie in a rectangular area instead of a square. The length needs to be at least as large as the largest ydistance in 'coord. 
Sind 
Vector of indices of grid cells where observations are made, in case, the observation are not made at every grid cell. Alternatively, the coordinates of the observation locations can be specfied in 'coord'. 
n 
Number of point per axis of the square into which the points are mapped. In total, the process is modeled on a grid of size n*n. 
IncidenceMat 
Logical; if 'TRUE' and incidence matrix relating the latent process to observation locations. This is only recommended to use when the observations are relatively lowdimensional and when the latent process is modeled in a reduced dimensional spaceas well. 
DataModel 
Specifies the data model. "Normal" or "SkewTobit". 
DimRed 
Logical; if 'TRUE' dimension reduction is applied. This means that not the full number (n*n) of Fourier functions is used but rather only a reduced dimensional basis of dimension 'NFour'. 
NFour 
If 'DimRed' is 'TRUE', this specifies the number of Fourier functions. 
seed 
Seed for random generator. 
nu 
Smoothness parameter of the Matern covariance function for the innovations. By default this equals 1 corresponding to the Whittle covariance function. 
trace 
Logical; if 'TRUE' tracing information on the progress of the MCMC algorithm is produced. 
Depending on whether 'xPred' and 'yPred' are empty or not, either

an array of size t x s x Nsim where the first index is for time, the second for space, and the third for the number of samples 'Nsim' 
or

a matrix of size length(tPred) x Nsim 
Fabio Sigrist
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 31  par < c(rho0=0.1,sigma2=0.2,zeta=0.5,rho1=0.1,gamma=2,alpha=pi/4,muX=0.2,muY=0.2,tau2=0.01)
##Simulate data
spateSim < spate.sim(par=par,n=20,T=20,seed=4)
w < spateSim$w
data("spateMCMC")
##Make predictions. Takes a couple of seconds
predict < spate.predict(y=w,tPred=(17:25),spateMCMC=spateMCMC,Nsim =200,
BurnIn=10,DataModel="Normal")
Pmean < apply(predict,c(1,2),mean)
Psd < apply(predict,c(1,2),sd)
par(mfrow=c(2,2))
image(1:20,1:20,matrix(w[19,],nrow=20),main="Observed field at t=19",xlab="x",ylab="y")
image(1:20,1:20,matrix(Pmean[3,],nrow=20),main="Fitted field at t=19",xlab="x",ylab="y")
image(1:20,1:20,matrix(w[20,],nrow=20),main="Observed field at t=20",xlab="x",ylab="y")
image(1:20,1:20,matrix(Pmean[4,],nrow=20),main="Fitted field at t=20",xlab="x",ylab="y")
par(mfrow=c(3,3))
zlim=c(min(Pmean),max(Pmean))
for(i in 1:9){
image(1:20,1:20,matrix(Pmean[i,],nrow=20),zlim=zlim,
main=paste("Mean t=",i+16,sep=""),xlab="x",ylab="y")
}
par(mfrow=c(3,3))
zlim=c(min(Psd),max(Psd))
for(i in 1:9){
image(1:20,1:20,matrix(Psd[i,],nrow=20),zlim=zlim,
main=paste("Std.dev. t=",i+16,sep=""),xlab="x",ylab="y")
}

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.