fitted | R Documentation |
Generate fitted values of the response variables based on a spatial fusion model.
## S3 method for class 'fusionModel' fitted(object, type = c("link", "summary", "full", "latent"), ...)
object |
object of class |
type |
string. The default "link" gives the median of linear predictors; "summary" gives the mean, standard deviation and quantiles of linear predictors; "full" gives full marginals for INLA or posterior samples for Stan; "latent" gives the median of latent processes with their corresponding locations. |
... |
additional arguments not used. |
For INLA models, no posterior values for point pattern data will be generated.
The returned value is a list containing the fitted results for each response variable.
Craig Wang
fusion
, fusion.dinla
, fusion.dstan
.
## example based on simulated data ## Not run: 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)) fit_inla <- fitted(mod_inla, type = "summary") } ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.