sim_dgp {estimateW}R Documentation

Simulating from a data generating process

Description

This function can be used to generate data from a data generating process for SDM, SAR, SLX type models.

Usage

sim_dgp(
  n,
  tt,
  rho,
  beta1 = c(),
  beta2 = c(),
  beta3 = c(),
  sigma2,
  n_neighbor = 4,
  do_symmetric = FALSE,
  intercept = FALSE
)

Arguments

n

Number of spatial observations nn.

tt

Number of time observations TT.

rho

The true ρ\rho parameter

beta1

Vector of dimensions k1×1k_1 \times 1. Provides the values for β1\beta_1 Defaults to c(). Note: has to be of same length as β2\beta_2.

beta2

Vector of dimensions k1×1k_1 \times 1. Provides the values for β2\beta_2 Defaults to c(). Note: has to be fo same length as β1\beta_1.

beta3

Vector of dimensions k2×1k_2 \times 1. Provides the values for β3\beta_3 Defaults to c().

sigma2

The true σ2\sigma^2 parameter for the DGP. Has to be a scalar larger than zero.

n_neighbor

Number of neighbors for the generated n×nn \times n spatial weight WW matrix. Defaults to 4.

do_symmetric

Should the generated spatial weight matrix be symmetric? (default: FALSE)

intercept

Should the first column of ZZ be an intercept? Defaults to FALSE. If intercept = TRUE, β3\beta_3 has to be at least of length 1.

Details

The generated spatial panel model takes the form

Y=ρWY+Xβ1+WXβ2+Zβ3+ϵ, Y = \rho W Y + X \beta_1 + W X \beta_2 + Z \beta_3 + \epsilon,

with ϵN(0,Inσ2)\epsilon \sim N(0,I_n\sigma^2). he function generates the N×1N \times 1 vector YY. The elements of the explanatory variable matrices XX (N×k1N \times k_1) and ZZ (N×k2N \times k_2) are randomly generated from a Gaussian distribution with zero mean and unity variance (N(0,1)N(0,1)).

The non-negative, row-stochastic nn by nn matrix WW 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 β1\beta_1, β2\beta_2, and β3\beta_3, as well as ρ\rho and σ2\sigma^2 have to be provided by the user. The length of β1\beta_1 and β2\beta_2 have to be equal.

Value

A list with the generated XX, YY and WW and a list of parameters.

Examples

# 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)

[Package estimateW version 0.0.1 Index]