## Simulate data with nonlinear association (setting 3).
data = simulate(N = 3000, discretize = 3, setting = 3, seed = 123)
population = data$population # Population data (3000 cases)
samples = data$samples # Sample data (600 cases)
ipw = 1 / samples$true_pi # Compute inverse probability weights
## Perform weighted post-stratification with auxiliary variables
auxVars = c("Z1", "Z2", "Z3")
Weighted_postStratify = postStr_wt(svysmpl = samples, svypopu = population, auxVars = auxVars,
svyVar = "Y1", subset = NULL, family = gaussian(),
invlvls = c(0.95), weights = ipw)
Weighted_postStratify
## Perform unweighted post-stratification
Unweighted_postStratify = postStr_wt(svysmpl = samples, svypopu = population, auxVars = auxVars,
svyVar = "Y1", subset = NULL, family = gaussian(),
invlvls = c(0.95), weights = NULL)
Unweighted_postStratify
Run the code above in your browser using DataLab