smoothUnit: Smooth via unit level model

View source: R/smoothUnit.R

smoothUnitR Documentation

Smooth via unit level model

Description

Generates small area estimates by smoothing direct estimates using a unit level model

Usage

smoothUnit(
  formula,
  domain,
  design,
  family = c("gaussian", "binomial")[1],
  Amat = NULL,
  X.pop = NULL,
  domain.size = NULL,
  pc.u = 1,
  pc.alpha = 0.01,
  pc.u.phi = 0.5,
  pc.alpha.phi = 2/3,
  CI = 0.95,
  n.sample = 250
)

Arguments

formula

an object of class "formula" describing the model to be fitted.

domain

formula specifying variable containing domain labels

design

an object of class "svydesign" containing the data for the model

family

of the response variable, currently supports 'binomial' (default with logit link function) or 'gaussian'.

Amat

Adjacency matrix for the regions. If set to NULL, the IID spatial effect will be used.

X.pop

unit-level covariates data frame. One of the column name needs to match the domain specified, in order to be linked to the data input. Currently only supporting time-invariant domain-level covariates.

domain.size

Domain size data frame. One of the column name needs to match the domain specified, in order to be linked to the data input and there must be a size column containing domain sizes.

pc.u

hyperparameter U for the PC prior on precisions.

pc.alpha

hyperparameter alpha for the PC prior on precisions.

pc.u.phi

hyperparameter U for the PC prior on the mixture probability phi in BYM2 model.

pc.alpha.phi

hyperparameter alpha for the PC prior on the mixture probability phi in BYM2 model.

CI

the desired posterior credible interval to calculate

n.sample

number of draws from posterior used to compute summaries

Value

A list with elements

direct.est

direct estimates

model.fit

fitted INLA object for iid domain effects model

model.est

smoothed estimates

Examples

## Not run: 
library(survey)
data(DemoData2)
data(DemoMap2)
des0 <- svydesign(ids = ~clustid+id, strata = ~strata,
                 weights = ~weights, data = DemoData2, nest = T)
                 
EXAMPLE 1: Continuous response model
cts.res <- smoothUnit(formula = tobacco.use ~ 1,
                      domain = ~region,
                      design = des0, X.pop = DemoData2)
                      
EXAMPLE 2: Binary response model
bin.res <- smoothUnit(formula = tobacco.use ~ 1,
                      family = "binomial",
                      domain = ~region,
                      design = des0, X.pop = DemoData2)

## End(Not run)

SUMMER documentation built on July 8, 2022, 9:05 a.m.