ResampleMLSpawExact: Spatially weighted multilevel analysis with stratified...

Description Usage Arguments Value Author(s) References Examples

Description

This step-3 function performs multilevel analyses with spatially weighted context data based on precise macro-level measures. The context data created in step 2 are combined with additional individual outcome and (optional) predictor variables, to test a user-defined model. An ad hoc stratified bootstrap resampling procedure generates robust point estimates for regression coefficients and model fit indicators, and computes confidence intervals adjusted for measurement dependency. For each tested model, contextual residuals can be stored for later re-use.

Usage

1
2
3
4
5
6
7
8
9
ResampleMLSpawExact(individual.level.data,
 context.id,
 formula,
 precise.data,
 confidence.intervals = c(0.95),
 nb.resamples = 1000,
 individual.sample.seed = NULL,
 verbose = TRUE,
 ...)

Arguments

individual.level.data

A data.frame containing the individual level predictor and outcome variables. The data must be numeric (logical, integer, or plain numeric). There must not be any missing values, NaNs, NULLs or NAs.

context.id

This variable allows matching contextual units from different data sets (precise.data, individual.level.data). Values can by of any type but need to be defined consitently across data sets.

formula

Formula description of the model.The formula is handed down to lmer function of the package lme4. Refer to the documentation of lmer for details.

precise.data

A data.frame containing the precise contextual data.There must not be any missing values, NaNs, NULLs or NAs. By default set to NULL.

confidence.intervals

vector of confidence intervals. Defaults to c(.95) which corresponds to 95 %.

nb.resamples

number of resamples to be evaluated. By default set to 1000.

individual.sample.seed

Seed used to generate the random sampling of the individual data Is one of three things

  1. NULL, in which case whatever the current random seed is is used

  2. an integer, which will be used to set the random seed. This allows reproducible random samples

  3. a saved .Random.seed which allows reproducible random samples as well. The reason why both 2 and 3 are present is because .Random.seed can be saved a posteriori.

Defaults to NULL.

verbose

if TRUE, progress information and an estimate of the remaining computing time is shown at the screen. Defaults to TRUE

...

All additional named arguments are handed through to the function lme:lmer (for example, REML=TRUE).

Value

An object of class SpawAggregateOutput-class.

Author(s)

Till Junge, Sandra Penic, Guy Elcheroth

References

Elcheroth, G., Penic, S., Fasel, R., Giudici, F., Glaeser, S., Joye, D., Le Goff, J.-M., Morselli, D., & Spini, D. (2012). Spatially weighted context data: a new approach for modelling the impact of collective experiences. LIVES Working Papers, 19.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Spatially weighted multilevel analysis, with resampled individual
# level indicators and precise contextual indicator. 

## It is step-2 function

## Data preparation

##  load individual level data, remove collective guilt assignment from the
## data frame, and remove NA's 
data(traces_ind)
traces_ind <- traces_ind[,-7]
traces_ind <- na.exclude(traces_ind)

## load precise contextual indicator
data(homog_census)

## load distance matrix 
data(d_geo)

## Step 1: Create spatial weights
geow.100 <- WeightMatrix(d_geo, bandwidth=100)

## Step 2: Create spatially weighted precise contextual indicator
homog.100 <- SpawExact(precise.data=homog_census,
                       context.id="area.name",
                       contextual.names="Homog_00",
                       contextual.weight.matrices=geow.100)
## rename weighted variable names so they reflect the used weighting
## matrix
names(homog.100)[2] <- "Homog.100"                       

## Step 3: Perform ResampleMLSpawExact
acc_homog100 <-
  ResampleMLSpawExact(
    individual.level.data=traces_ind,
    context.id="area.name",
    formula=cg_acc ~ victim_d + comb_d + male + age_1990 + high_school +
    higher_edu + Homog.100 + (1|area.name), precise.data=homog.100,
    nb.resamples=10)

spacom documentation built on May 1, 2019, 7:35 p.m.