simulate.STmodel: Simulate Data from the Spatio-Temporal Model

Description Usage Arguments Value Author(s) See Also Examples

Description

Data is simulated for the space-time locations in object using the parameters in x.

Usage

1
2
3
## S3 method for class 'STmodel'
simulate(object, nsim = 1, seed = NULL, x,
  nugget.unobs = 0, ...)

Arguments

object

A STmodel object to perform unconditional simulation from.

nsim

Number of replicates to simulate.

seed

if !=NULL used in a call to set.seed, allowing for replicatable simulation studies.

x

Parameters to use when simulating the data; both regression and covariance parameters must be given, see loglikeSTgetPars.

nugget.unobs

Value of nugget at unonserved locations, either a scalar or a vector with one element per unobserved site.

...

Additional parameters for set.seed

Value

A list containing:

param

Parameters used in the simulation, i.e. x.

B

The simulated beta fields in a (number of locations) - by - (number of temporal trends) - by - (number of replicates) array.

X

The simulated spatio-temporal fields in a (number of timepoints) - by - (number of locations) - by - (number of replicates) array. Row and column names indicate the time and locations for each point.

obs

A list with one element per replicate, containing the simulated observations extracted at space-time locations matching those in object$obs. To replace the observations with the i:th simulated values do:
object$obs <- res$obs[[i]].

Author(s)

Johan Lindstrom

See Also

Other STmodel methods: MCMC.STmodel, c.STmodel, createSTmodel, estimate.STmodel, estimateCV.STmodel, plot.STdata, predict.STmodel, print.STmodel, print.summary.STmodel, qqnorm.predCVSTmodel, scatterPlot.predCVSTmodel, summary.STmodel

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
##load the data
data(mesa.model)
data(est.mesa.model)

##Get estimated parameters
x <- coef(est.mesa.model)$par

##Simulate 5 replicates from these parameters
sim.data <- simulate(mesa.model, nsim=5, x=x)

##compute average beta fields
beta <- calc.mu.B(mesa.model$LUR, loglikeSTgetPars(x, mesa.model)$alpha)

##plot the simulated observations as a function of time
par(mfrow=c(2,2), mar=c(4,4,.5,.5))
plot(sim.data$obs[[1]]$date, sim.data$obs[[1]]$obs,
     type="n", ylab="obs", xlab="Date")
for(i in 1:5){
  points(sim.data$obs[[i]]$date, sim.data$obs[[i]]$obs, col=i)
}
##and the latent beta-fields
for(i in 1:3){
  plot(sim.data$B[,i,1], ylim=range(sim.data$B[,i,]), type="n",
       xlab="loc", ylab=paste("beta",colnames(sim.data$B)[i]))
  for(j in 1:5){
    points(sim.data$B[,i,j], col=j)
  }
  lines( beta[,i], col="grey")
}

Example output

Loading required package: Matrix

SpatioTemporal documentation built on May 2, 2019, 8:49 a.m.