predict: Obtain predictions for the latent processes of spatial fusion...

Description Usage Arguments Value Author(s) Examples

Description

Generate posterior values containing predictions of the latent Gaussian process(es) based on a fitted spatial fusion model and new locations.

Usage

1
2
## S3 method for class 'fusionModel'
predict(object, new.locs, type = c("summary", "full"), ...)

Arguments

object

an object of class fusionModel. Output of fusion().

new.locs

data.frame, SpatialPoints or SpatialPointsDataFrame. Contains the locations where the latent process(es) will be predicted. If data.frame, it must have column names "x" and "y" as coordinates of observations.

type

string, The default "summary" gives posterior median of latent process(es); "full" gives full marginals (for INLA) or posterior samples (for Stan) of latent process(es).

...

additional arguments not used

Value

The returned value is a list containing the posterior values for the latent spatial components.

For INLA models, the output represents the latent components that are associated with each response variable multiplied by the design matrix Z. They are indexed with ij, where i denotes the ith latent process and j denotes the jth variable. The variables are ordered by geostatistical, lattice, point pattern data.

For Stan models, the output represents the original latent components before multiplied by the deisng matrix Z. Each spatial component is indexed with i, where i denotes the ith latent process.

Author(s)

Craig Wang

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
## example based on simulated data

if (require("INLA", quietly = TRUE)) {
dat <- fusionSimulate(n.point = 20, n.area = 10, n.grid = 2,
          psill = 1, phi = 1, nugget = 0, tau.sq = 0.5,
          point.beta = list(rbind(1,5)),
          area.beta = list(rbind(-1, 0.5)),
          distributions = c("normal","poisson"),
          design.mat = matrix(c(1,1,1)))

geo_data <- data.frame(x = dat$mrf[dat$sample.ind, "x"],
                y = dat$mrf[dat$sample.ind, "y"],
                cov.point = dat$data$X_point[,2],
                outcome = dat$data$Y_point[[1]])
lattice_data <- sp::SpatialPolygonsDataFrame(dat$poly,
                    data.frame(outcome = dat$data$Y_area[[1]],
                    cov.area = dat$data$X_area[,2]))

dat_inla <- fusionData(geo.data = geo_data, geo.formula = outcome ~ cov.point,
                lattice.data = lattice_data, lattice.formula = outcome ~ cov.area,
                pp.data = dat$data$lgcp.coords[[1]],
                distributions = c("normal","poisson"), method = "INLA")

mod_inla <- fusion(data = dat_inla, n.latent = 1, bans = 0,
            prior.range = c(1, 0.5), prior.sigma = c(1, 0.5),
            mesh.locs = dat_inla$locs_point, mesh.max.edge = c(0.5, 1))

pred_inla <- predict(mod_inla, dat$pred.loc, type = "summary")
}

spatialfusion documentation built on June 25, 2019, 1:03 a.m.