Learn R Programming

geoCount (version 1.150120)

predY: Predict for Unsampled Locations

Description

This function generates posterior predictive samples of latent and response variables for predicting locations.

Usage

predY(res.m, loc, locp, X = NULL, Xp = NULL, Lp = 0, k = 1, rho.family = "rhoPowerExp", Y.family = "Poisson", parallel = NULL, n.cores = getOption("cores"), cluster.type = "SOCK")

Arguments

res.m
a list with elements containing the posterior samples of latent variables and parameters for observed locations
loc
a matrix which indicates the coordinates of the observed locations
locp
a matrix which indicates the coordinates of the predicting locations
X
the covariate matrix for observed locations
Xp
the covariate matrix for predicting locations
Lp
a vector which indicates the time duration during which the Poisson counts are accumulated or the total number of trials for Binomial response; if 0 is found in the vector, 1 will be used to replace all the values in the vector
k
a value for fixed $\kappa$; ignored if there are posterior samples for $\kappa$ in "res.m"
rho.family
take the value of "rhoPowerExp" or "rhoMatern" which indicates the powered exponential or Matern correlation function is used
Y.family
take the value of "Poisson" or "Binomial" which indicates Poisson or Binomial distribution for response variables
parallel
the default input NULL indicates no parallel computing will be applied; any input value indicates parallel computing with the help of {snowfall}
n.cores
the number of CPUs that will be used for parallel computing; used only if parallel isn't NULL
cluster.type
type of cluster to be used for parallel computing; can be "SOCK", "MPI", "PVM", or "NWS"; used only if parallel="snowfall"

Value

A list with elements:
latent.predict
a matrix containing the posterior predictive samples for latent variables
Y.predict
a matrix containing the posterior predictive samples for response variables

Details

This function performs parallel computing with the help of {snowfall} package.

See Also

runMCMC.

Examples

Run this code
## Not run: 
# Ypred <- predY(res.m, loc, locp, X=loc, Xp=locp, k=1, 
#                rho.family = "rhoPowerExp", Y.family = "Poisson")
# # require(snowfall)
# # Ypred <- predY(res.m, loc, locp, X=loc, Xp=locp, 
# #                parallel="snowfall", n.cores = 4)
# Ypred.avg <- rowMeans(Ypred$Y); EYpred.avg <- rowMeans(exp(Ypred$latent))
# ## End(Not run)

Run the code above in your browser using DataLab