sdmw {estimateW} | R Documentation |
A Markov Chain Monte Carlo (MCMC) sampler for the panel spatial Durbin model (SDM) with unknown spatial weight matrix
Description
The sampler uses independent Normal-inverse-Gamma priors for the slope and variance parameters, as well as a four-parameter
beta prior for the spatial autoregressive parameter . It is a wrapper around
W_sampler
.
Usage
sdmw(
Y,
tt,
X = matrix(0, nrow(Y), 0),
Z = matrix(1, nrow(Y), 1),
niter = 100,
nretain = 50,
W_prior = W_priors(n = nrow(Y)/tt),
rho_prior = rho_priors(),
beta_prior = beta_priors(k = ncol(X) * 2 + ncol(Z)),
sigma_prior = sigma_priors()
)
Arguments
Y |
numeric |
tt |
single number greater or equal to 1. Denotes the number of time observations. |
X |
numeric |
Z |
numeric |
niter |
single number greater or equal to 1, indicating the total number of draws. Will be automatically coerced to integer. The default value is 100. |
nretain |
single number greater or equal to 0, indicating the number of draws kept after the burn-in. Will be automatically coerced to integer. The default value is 50. |
W_prior |
list containing prior settings for estimating the spatial weight matrix |
rho_prior |
list of prior settings for estimating |
beta_prior |
list containing priors for the slope coefficients |
sigma_prior |
list containing priors for the error variance |
Details
The considered panel spatial Durbin model (SDM) with unknown ( by
) spatial weight
matrix
takes the form:
with and
. The
by
matrix
is an unknown binary adjacency matrix with zeros on the main diagonal and
is the (optional) row-standardization function.
is a scalar spatial autoregressive parameter.
(
) collects the
cross-sectional (spatial) observations for time
.
(
) and
(
) are
matrices of explanatory variables, where the former will also be spatially lagged.
(
),
(
) and
(
)
are unknown slope parameter vectors.
After vertically staking the cross-sections
(
),
(
) and
(
),
with
. The final model can be expressed as:
where and
. Note that the input
data matrices have to be ordered first by the cross-sectional spatial units and then stacked by time.
Estimation usually even works well in cases of . However, note that for applications with
the
estimation process becomes computationally demanding and slow. Consider in this case reducing
niter
and
nretain
and carefully check whether the posterior chains have converged.
Value
List with posterior samples for the slope parameters, ,
,
,
and average direct, indirect, and total effects.
Examples
n = 20; tt = 10
dgp_dat = sim_dgp(n =n, tt = tt, rho = .75, beta1 = c(.5,1),beta2 = c(-1,.5),
beta3 = c(1.5), sigma2 = .05,n_neighbor = 3,intercept = TRUE)
res = sdmw(Y = dgp_dat$Y,tt = tt,X = dgp_dat$X,Z = dgp_dat$Z,niter = 20,nretain = 10)