Learn R Programming

spacom (version 0.9-3)

ResampleExactSpawML: Spatially weighted multilevel analysis with stratified resampling for exact context data

Description

Performs multilevel analysis with spatially weighted context data based on precise contextual measures. Provides robust point estimates and adjusted standard errors, obtained by stratified bootstrap resampling.

Usage

ResampleExactSpawML(individual.level.data,
 contextual.names,
 context.id,
 formula,
 precise.data,
 contextual.weight.matrices = NULL,
 confidence.intervals = c(0.95),
 nb.resamples = 1000,
 individual.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.
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
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

Value

    Examples

    Run this code
    # Spatially weighted multilevel analysis, with resampled individual
    # level indicators and 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 precise contextual indicator
    data(homog_census)
    
    # load distance matrix and create weights
    data(d_geo)
    geow_100 <- WeightMatrix(d_geo, bandwidth=100)
    
    # perform ResampleExactSpawML
    acc_homog00_100 <- ResampleExactSpawML(individual.level.data=traces_ind,
      contextual.names="Homog_00", context.id="area", formula=cg_acc ~
      victim_d + comb_d + male + age_1990 + high_school + higher_edu +
      (1|area), precise.data=homog_census,
      contextual.weight.matrices=geow_100, nb.resamples=10)

    Run the code above in your browser using DataLab