## 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 raking with auxiliary variables
auxVars = c("Z1", "Z2", "Z3")
Weighted_rake = rake_wt(svysmpl = samples, svypopu = population, auxVars = auxVars,
svyVar = "Y1", subset = NULL, family = gaussian(),
invlvls = c(0.95), weights = ipw, maxiter = 50)
Weighted_rake
## Perform unweighted raking
Unweighted_rake = rake_wt(svysmpl = samples, svypopu = population, auxVars = auxVars,
svyVar = "Y1", subset = NULL, family = gaussian(),
invlvls = c(0.95), weights = NULL, maxiter = 50)
Unweighted_rake
Run the code above in your browser using DataLab