This is the development repository of the R
package
estimateW
.
The package provides methods to estimate spatial weight matrices in spatial autoregressive type models.
Type into your R
session:
if (!require("remotes")) {
install.packages("remotes")
}::install_github(
remotesrepo = "https://github.com/tkrisztin/estimateW")
# Load the package
library(estimateW)
require(dplyr)
= length(unique(covid$date))
tt = length(unique(covid$ISO3))
n
# reorder by date and longitude
= covid %>%
covid arrange(date, LON) %>%
mutate(date = as.factor(date))
# Benchmark specification from Krisztin and Piribauer (2022) SEA
= as.matrix(covid$infections_pc - covid$infections_pc_lag)
Y = model.matrix(~infections_pc_lag + stringency_2weekly +
X + temperatureMax + ISO3 + as.factor(date) + 0,data = covid)
precipProbability
# use a flat prior for W
= W_priors(n = n,nr_neighbors_prior = rep(1/n,n))
flat_W_prior
# Estimate a Bayesian model using covid infections data
= sarw(Y = Y,tt = tt,Z = X,niter = 200,nretain = 50,
res W_prior = flat_W_prior)
# Plot the posterior of the spatial weight matrix
dimnames(res$postw)[[2]] = dimnames(res$postw)[[1]] = covid$ISO3[1:n]
plot(res,font=3,cex.axis=0.75,las=2)
Tamás Krisztin & Philipp Piribauer (2022) A Bayesian approach for
the estimation of weight matrices in spatial autoregressive models,
Spatial Economic Analysis, DOI: 10.1080/17421772.2022.2095426