sim_dgp | R Documentation |
This function can be used to generate data from a data generating process for SDM, SAR, SEM, and SLX type models.
sim_dgp(
n,
tt,
rho,
beta1 = c(),
beta2 = c(),
beta3 = c(),
sigma2,
n_neighbor = 4,
W = NULL,
do_symmetric = FALSE,
intercept = FALSE,
spatial_error = FALSE
)
n |
Number of spatial observations |
tt |
Number of time observations |
rho |
The true |
beta1 |
Vector of dimensions |
beta2 |
Vector of dimensions |
beta3 |
Vector of dimensions |
sigma2 |
The true |
n_neighbor |
Number of neighbors for the generated |
W |
Exogeneous spatial weight matrix for the data generating process. Defaults to
|
do_symmetric |
Should the generated spatial weight matrix be symmetric? (default: FALSE) |
intercept |
Should the first column of |
spatial_error |
Should a spatial error model be constructed? Defaults to |
For the SDM, SAR, and SLX models the generated spatial panel model takes the form
Y = \rho W Y + X \beta_1 + W X \beta_2 + Z \beta_3 + \epsilon,
with \epsilon \sim N(0,I_n\sigma^2)
.
For the SEM model the generated spatial panel model takes the form
Y = X \beta_1 + W X \beta_2 + Z \beta_3 + \epsilon,
with \epsilon \sim N(0,(I_n - \rho W)\sigma^2)
.
The function generates the N \times 1
vector Y
. The elements of the explanatory variable matrices X
(N \times k_1
) and Z
(N \times k_2
) are randomly generated from a Gaussian
distribution with zero mean and unity variance (N(0,1)
).
The non-negative, row-stochastic n
by n
matrix W
is constructed using a k-nearest neighbor specification
based on a randomly generated spatial location pattern, with coordinates sampled from a standard normal distribution.
Values for the parameters \beta_1
, \beta_2
, and \beta_3
, as well as
\rho
and \sigma^2
have to be provided by the user. The length of \beta_1
and
\beta_2
have to be equal.
A spatial Durbin model (SDM) is constructed if \rho
is not equal to zero,
spatial_error
is FALSE
, and \beta_1
, \beta_2
, and \beta_3
are all supplied by the user.
A spatial autoregressive model is constructed if \rho
is not equal to zero,
spatial_error
is FALSE
, and only \beta_3
is supplied by the user.
An SLX type model is constructed if \rho
is equal to zero, spatial_error
is FALSE
,
and \beta_1
, \beta_2
are supplied by the user.
An SEM type model is constructed if spatial_error
is TRUE
and either only
\beta_3
or \beta_1
, \beta_2
, and \beta_3
are supplied by the user.
A list with the generated X
, Y
and W
and a list of parameters.
# SDM data generating process
dgp_dat = sim_dgp(n =20, tt = 10, rho = .5, beta1 = c(1,-1),
beta2 = c(0,.5),beta3 = c(.2),sigma2 = .5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.