Learn R Programming

spacom (version 0.9-3)

ResampleAggregateSpawML: Spatially weighted multilevel analysis with stratified resampling for aggregated context data

Description

Performs multilevel analyses with spatially weighted context data based on aggregations of micro-level measures. Provides robust point estimates and adjusted standard errors, obtained by stratified bootstrap resampling.

Usage

ResampleAggregateSpawML(individual.level.data,
 contextual.names,
 context.id,
 formula,
 contextual.data = NULL,
 precise.data = NULL,
 contextual.weight.matrices = NULL,
 individual.weight.names = NULL,
 aggregation.functions = "mean",
 confidence.intervals = c(0.95),
 nb.resamples = 1000,
 individual.sample.seed = NULL,
 contextual.sample.seed = NULL)

Arguments

individual.level.data
A data.frame containing the individual level data. The data must be numeric (logical, integer, or plain numeric). There may not be any missing values, NaNs, NULLs or
contextual.names
A list of names of contextual variables to be weighted.
context.id
The name of the context ID variable.
formula
Formula description of the model.
contextual.data
A data.frame containing the micro-level data to generate contextual indicators by aggregation. May be NULL, in which case the individual data is used. The data must be numeric (logical, integer,
precise.data
A data.frame containing the precise contextual data. May be NULL, but may not contain any missing values, like NaNs, NULLs or NAs. By default set to NULL, except for
contextual.weight.matrices
A list of weights to be applied to each variable specified in contextual.names. A weight may be a weights matrix as, for instance computed by WeightMatrix, or NU
individual.weight.names
A list of optional design weights at the individual level used for aggregation (for example, for a weighted mean). List must have same length as contextual.names. May contain NULLs for variables which should not be we
aggregation.functions
A list of aggregation functions. Functions take either
  1. 1 argument in which case the corresponding individual design weight isNULL,
  2. 2 arguments in which case the second argument is taken from the co
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. aninteger, which will be used to set the random
contextual.sample.seed
Seed used to generate the random sampling of the contextual data Is one of three things
  1. NULL, in which case whatever the current random seed is is used
  2. aninteger, which will be used to set the random

Value

    Examples

    Run this code
    # 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