# Spatially weighted multilevel analysis, with resampled both individual
# level indicators and contextual predictors for aggregation. It may
# include non-resampled precise contextual indicator. Predicting
# collective guilt acceptance.
# load individual level data, remove collective guilt assignment for the
# data frame, and remove NA's
data(traces_ind)
traces_ind <- traces_ind[,-7]
traces_ind <- na.exclude(traces_ind)
# load contextual indicator for aggregation
data(traces_event)
# load precise contextual indicator
data(homog_census)
# load distance matrix and create weights
data(d_geo)
geow_100 <- WeightMatrix(d_geo, bandwidth=100)
# perform ResampleAggregateSpawML
acc_w_homog_100 <-
ResampleAggregateSpawML(individual.level.data=traces_ind,
contextual.names=c("w_all", "Homog_00"), context.id="area",
formula=cg_acc ~ victim_d + comb_d + male + age_1990 + high_school +
higher_edu + (1|area), contextual.data=traces_event,
precise.data=homog_census, contextual.weight.matrices=list(geow_100,
geow_100), individual.weight.names="weight",
aggregation.functions="weighted.mean", nb.resamples=10)Run the code above in your browser using DataLab