Description Usage Arguments Details Value Source Examples
Find monadic spatial weights for a cross-sectional time-series data set
1 2 3 4 |
df |
a data frame containing the unit ID variable and time variables as well as location' and dependent variables. |
id_var |
a character string identifying the unit ID variable in
|
time_var |
a character string identifying the time variable in
|
location_var |
a character string identifying the location of the units
in |
y_var |
a character string identifying the dependent variable in
|
location_var_type |
character string allowing you to hard code
the measurement type of the location variable and thus how to determine the
weighting method Can be either |
weight_name |
character string providing a custom weighting variable name. |
method |
the distance measure to be used. Only relevant for numeric
location variables. This must be one of
|
row_standard |
logical. Whether or not to row-standardize the adjacency matrix, i.e. dividing each neighbor weight for a feature by the sum of all neighbor weights for that feature. |
tlsl |
logical whether or not to create a temporally-lagged spatial lag by lagging the spatial weight one time unit. Note, Moran's I statistic refer to the non-lagged spatial weights. |
mc_cores |
The number of cores to use, i.e. at most how many child
processes will be run simultaneously. The option is initialized from
environment variable |
na_rm |
logical whether or not to remove missing values. |
morans_i |
character. Whether to print the p-value of Moran's I
Autocorrelation Index to the console ( |
... |
arguments to pass to methods. |
Finds spatial effects in monadic data. See Neumayer and Plumper (2010, 591) for details.
The weights are found for each unit i given other units k at time t using ∑_{k}w_{kit}y_{kt}.
For continuous location_var
w is the euclidean distance.
You can choose an alternate method with the method
argument. See
dist
for details.
For factor/character location_var
w is 1 if they share the same
location, 0 otherwise. The weight is further found by averaging over the
number of units at t that share the location of i.
A data frame with three columns, one each for id_var
,
time_var
, and the newly created spatial weights.
Neumayer, Eric, and Thomas Plumper. "Making spatial analysis operational: commands for generating spatial effect variables in monadic and dyadic data." Stata Journal 10.4 (2010): 585-605. http://eprints.lse.ac.uk/30750/1/Making%20spatial%20analysis%20operational(lsero).pdf.
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 | # Create fake time series data
faked <- expand.grid(ID = letters, year = 2010:2015)
faked$located_continuous <- nrow(faked):1
faked$located_categorical <- sample(c('E', 'S', 'W', 'N'),
nrow(faked), replace = TRUE)
faked$y <- nrow(faked):1 - 200
# Find weights for continuous data
df_weights_cont <- monadic_spatial_weights(df = faked, id_var = 'ID',
time_var = 'year',
location_var = 'located_continuous',
y_var = 'y', mc_cores = 1)
# Find row standardized weights for continuous data
df_weights_cont_st <- monadic_spatial_weights(df = faked, id_var = 'ID',
time_var = 'year',
row_standard = TRUE,
location_var = 'located_continuous',
y_var = 'y', mc_cores = 1)
# Find weights and TLSL for continuous data
df_weights_cont_tlsl <- monadic_spatial_weights(df = faked, id_var = 'ID',
time_var = 'year',
location_var = 'located_continuous',
y_var = 'y', mc_cores = 1,
tlsl = TRUE)
# Find weights for character data
df_weights_cat <- monadic_spatial_weights(df = faked, id_var = 'ID',
time_var = 'year',
location_var = 'located_categorical',
y_var = 'y', mc_cores = 1)
# Return a table of p-values from Moran's I spatial autocorrelation test statistic
moran_i_table <- monadic_spatial_weights(df = faked, id_var = 'ID',
time_var = 'year',
location_var = 'located_categorical',
y_var = 'y', mc_cores = 1,
morans_i = 'table')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.