sdm {estimateW}R Documentation

A Markov Chain Monte Carlo (MCMC) sampler for the panel spatial Durbin model (SDM) with exogenous spatial weight matrix.

Description

The sampler uses independent Normal-inverse-Gamma priors for the slope and variance parameters, as well as a four-parameter prior for the spatial autoregressive parameter \rho. The function is used as an illustration on using the beta_sampler, sigma_sampler, and rho_sampler classes.

Usage

sdm(
  Y,
  tt,
  W,
  X = matrix(0, nrow(Y), 0),
  Z = matrix(1, nrow(Y), 1),
  niter = 200,
  nretain = 100,
  rho_prior = rho_priors(),
  beta_prior = beta_priors(k = ncol(X) * 2 + ncol(Z)),
  sigma_prior = sigma_priors()
)

Arguments

Y

numeric N \times 1 matrix containing the dependent variables, where N = nT is the number of spatial (n) times the number of time observations (T, with tt=T). Note that the observations have organized such that Y = [Y_1',...,Y_T']'.

tt

single number greater or equal to 1. Denotes the number of time observations. tt = T.

W

numeric, non-negative and row-stochastic n by n exogenous spatial weight matrix. Must have zeros on the main diagonal.

X

numeric N \times k_1 design matrix of independent variables. These will be automatically spatially lagged. If no spatially lagged variable is included in the model a matrix with N rows and zero columns should be supplied (the default value). Note: either X or Z has to be a matrix with at least one column.

Z

numeric N \times k_3 design matrix of independent variables which are not spatially lagged. The default value is a N \times 1 vector of ones (i.e. an intercept for the model). Note: either X or Z has to be a matrix with at least one column.

niter

single number greater or equal to 1, indicating the total number of draws. Will be automatically coerced to integer. The default value is 200.

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 100.

rho_prior

list of prior settings for estimating \rho, generated by the smart constructor rho_priors

beta_prior

list containing priors for the slope coefficients \beta, generated by the smart constructor beta_priors. The ordering of the priors is: (1) priors of X, (2) priors of spatially lagged X, (3) priors of Z.

sigma_prior

list containing priors for the error variance \sigma^2, generated by the smart constructor sigma_priors

Details

The considered panel spatial Durbin model (SDM) takes the form:

Y_t = \rho W Y_t + X_t \beta_1 + W X_t \beta_2 + Z \beta_3 + \varepsilon_t,

with \varepsilon_t \sim N(0,I_n \sigma^2). The row-stochastic n by n spatial weight matrix W is non-negative and has zeros on the main diagonal. \rho is a scalar spatial autoregressive parameter.

Y_t (n \times 1) collects the n cross-sectional (spatial) observations for time t=1,...,T. X_t (n \times k_1) and Z_t (n \times k_2) are matrices of explanatory variables, where the former will also be spatially lagged. \beta_1 (k_1 \times 1), \beta_2 (k_1 \times 1) and \beta_3 (k_2 \times 1) are unknown slope parameter vectors.

After vertically staking the T cross-sections Y=[Y_1',...,Y_T']' (N \times 1), X=[X_1',...,X_T']' (N \times k_1) and Z=[Z_1', ..., Z_T']' (N \times k_2), with N=nT, the final model can be expressed as:

Y = \rho \tilde{W}Y + X \beta_1 + \tilde{W} X \beta_2 + Z \beta_3 + \varepsilon,

where \tilde{W}=I_T \otimes W and \varepsilon \sim N(0,I_N \sigma^2). Note that the input data matrices have to be ordered first by the cross-sectional spatial units and then stacked by time.

Examples

n = 20; tt = 10
dgp_dat = sim_dgp(n = n, tt = tt, rho = .5, beta1 = c(.5,1), beta2 = c(-1,.5),
                  beta3 = c(1.5), sigma2 = .5)
res = sdm(Y = dgp_dat$Y, tt = tt,  W = dgp_dat$W, X = dgp_dat$X,
          Z = dgp_dat$Z, niter = 100, nretain = 50)

[Package estimateW version 0.0.1 Index]