Learn R Programming

spacom (version 0.9-4)

ExploreSpawML: Exploratory multilevel analysis with spatially weighted context data

Description

Performs exploratory multilevel analysis with spatially weighted context data for a series of different bandwidth values.

Usage

ExploreSpawML(individual.level.data, 
 contextual.name, 
 contextual.data, 
 context.id, formula, 
 distance.matrix, 
 multilevel.bandwidths, 
 precise.data = NULL, 
 individual.weight.names = NULL, 
 aggregation.function = "mean", 
 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 must not be any missing values, NaNs, NULLs o
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.
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$
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
individual.weight.names
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 individu
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{

Value

    Examples

    Run this code
    #### ExploreSpawML
    # Exploratory spatially weighted multilevel with standard estimates of
    # standard errors. 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 precise contextual indicator
    data(homog_census) 
    
    # load distance matrix
    data(d_geo) 
    
    # perform ExploreSpawML
    acc_homog <- ExploreSpawML(individual.level.data=traces_ind,
      contextual.name="Homog_00", contextual.data=NULL, context.id="area",
      formula=cg_acc ~ victim_d + comb_d + male + age_1990 + high_school +
      higher_edu + (1|area), precise.data=homog_census, distance.matrix=d_geo,
      multilevel.bandwidths=c(50,100,200))

    Run the code above in your browser using DataLab