if (FALSE) {
data(DemoData2)
data(DemoMap2)
library(survey)
des0 <- svydesign(ids = ~clustid+id, strata = ~strata,
weights = ~weights, data = DemoData2, nest = TRUE)
Xmat <- aggregate(age~region, data = DemoData2, FUN = mean)
# EXAMPLE 1: Continuous response model
cts.res <- smoothArea(tobacco.use ~ 1,
domain = ~region,
design = des0,
adj.mat = DemoMap2$Amat,
pc.u = 1,
pc.alpha = 0.01,
pc.u.phi = 0.5,
pc.alpha.phi = 2/3)
# EXAMPLE 2: Including area level covariates
cts.cov.res <- smoothArea(tobacco.use ~ age,
domain = ~region,
design = des0,
adj.mat = DemoMap2$Amat,
X.domain = Xmat,
pc.u = 1,
pc.alpha = 0.01,
pc.u.phi = 0.5,
pc.alpha.phi = 2/3)
# EXAMPLE 3: Binary response model
bin.res <- smoothArea(tobacco.use ~ 1,
domain = ~region,
design = des0,
adj.mat = DemoMap2$Amat,
transform = "logit",
pc.u = 1,
pc.alpha = 0.01,
pc.u.phi = 0.5,
pc.alpha.phi = 2/3)
# EXAMPLE 4: Including area level covariates in binary response model
bin.cov.res <- smoothArea(tobacco.use ~ age,
domain = ~region,
design = des0,
adj.mat = DemoMap2$Amat,
transform = "logit",
X.domain = Xmat,
pc.u = 1,
pc.alpha = 0.01,
pc.u.phi = 0.5,
pc.alpha.phi = 2/3)
}
Run the code above in your browser using DataLab