Learn R Programming

SUMMER (version 0.2.3)

fitSpace: Fit INLA models to perform simple space smoothing.

Description

This function calculates the direct estimates by region and fit a simple spatial smoothing model to the direct estimates adjusting for survey design.

Usage

fitSpace(data, geo, Amat, family, responseVar, strataVar = "strata",
  weightVar = "weights", regionVar = "region",
  clusterVar = "~v001+v002", hyper = NULL, hyper.besag = c(0.5,
  5e-05), hyper.iid = c(0.5, 5e-05), CI = 0.95, FUN = NULL,
  newformula = NULL, timeVar = NULL, time.model = c("rw1", "rw2")[1],
  hyper.time = NULL, type.st = 0)

Arguments

data

data frame with region and strata information.

geo

Geo file

Amat

Adjacency matrix for the regions

family

Link function specification, currently supports 'binomial' (default with logit link function) or 'gaussian'.

responseVar

the response variable

strataVar

the strata variable

weightVar

the weights variable

regionVar

Variable name for region, typically 'v024', for older surveys might be 'v101'

clusterVar

Variable name for cluster, typically '~v001 + v002'

hyper

the vector of two hyper parameters if specified by user

hyper.besag

the vector of two hyper parameters for the structured spatial random effects in Gaussian model, if specified by user

hyper.iid

the vector of two hyper parameters for the unstructured spatial random effects in Gaussian model, if specified by user

CI

the desired posterior credible interval to calculate

FUN

the function to transform the posterior draws. Default to be identify function for normal variable and inverse logit transformation for binomial variables

newformula

a string of user-specified random effects model to be used in the INLA call

timeVar

The variable indicating time period. If set to NULL then the temporal model and space-time interaction model are ignored.

time.model

the model for temporal trends and interactions. It can be either "rw1" or "rw2".

hyper.time

the vector of two hyper parameters for the structured temporal random effects in Gaussian model, if specified by user

type.st

can take values 0 (no interaction), or 1 to 4, corresponding to the type I to IV space-time interaction.

Value

HT

Direct estimates

smooth

Spatially smoothed estimates

fit

a fitted INLA object

geo

input argument

Amat

input argument

CI

input argument

family

input argument

FUN

input argument

Details

Normal or binary variables are currently supported. For binary variables, the logit transformation is performed on the direct estimates of probabilities, and a Gaussian additive model is fitted on the logit scale using INLA.

See Also

countrySummary_mult, fitINLA

Examples

Run this code
# NOT RUN {
data(DemoData2)
data(DemoMap2)
fit <- fitSpace(data=DemoData2, geo=DemoMap2$geo, 
Amat=DemoMap2$Amat, family="binomial", 
responseVar="tobacco.use", strataVar="strata", 
weightVar="weights", regionVar="region", 
clusterVar = "~clustid+id", 
hyper=NULL, CI = 0.95)
# }

Run the code above in your browser using DataLab