Learn R Programming

spacom (version 0.9-3)

ResampleExploreSpawML: Exploratory spatially weighted multilevel analysis with stratified resampling

Description

Performs exploratory multilevel analysis with spatially weighted context data for a series of different bandwidth values. Provides robust point estimates and standard errors based on stratified bootstrap resampling.

Usage

ResampleExploreSpawML(individual.level.data, contextual.name,
  contextual.data, context.id, nb.resamples, formula, distance.matrix,
  multilevel.bandwidths, individual.weight.name = NULL,
  aggregation.function = "mean", confidence.intervals = c(0.95),
  individual.sample.seed = NULL, contextual.sample.seed = NULL, kernel =
  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.name
A name of contextual variable to be weighted.
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,
context.id
The name of the context ID variable.
nb.resamples
A number of resamples to be evaluated. By default set to 1000.
formula
Formula description of the model.
distance.matrix
A square matrix of dimension $n\times n$, where $n$ is the number of contextual units.
multilevel.bandwidths
A vector of scalar numeric values specifying the bandwidth $h$
individual.weight.name
A name of optional design weight at the individual level used for aggregation (for example, for a weighted mean). By default set to NULL.
aggregation.function
A name of aggregation function. Function takes 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 corresponding in
confidence.intervals
A vector of confidence intervals. Defaults to c(.95) which corresponds to 95 %.
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
kernel
A function applied to the distance matrix. By default NULL, in which case the kernel function $$w_{ij}=f(d,h) = \left(\frac{1}{2}\right)^{d_{ij}^2/h^2}$$ is used, where $w_{ij}, d_{ij}, h$are elements of the weight matrix $\mathbf{W}$,

Value

    Examples

    Run this code
    #### ResampleExploreSpawML
    # Exploratory spatially weighted multilevel analysis, with resampled
    # both individual level indicators and contextual predictors for
    # aggregation. Accepts only one contextual predictor. Predicting
    # collective guilt acceptance. Contextual predictor weighted with
    # geographical proximity weights, h=50,100,200. 
    
    # 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 distance matrix 
    data(d_geo) 
    
    acc_homog <- ResampleExploreSpawML(individual.level.data=traces_ind,
      contextual.name="w_all", contextual.data=traces_event,
      context.id="area", nb.resamples=5,formula=cg_acc ~ victim_d + comb_d +
      male + age_1990 + high_school + higher_edu + (1|area),
      distance.matrix=d_geo, multilevel.bandwidths=c(50,100,200))

    Run the code above in your browser using DataLab