Learn R Programming

ProbitSpatial (version 1.0)

sim_binomial_probit: Simulate the dependent variable of a SAR/SEM/SARAR model.

Description

The function sim_binomial_probit is used to generate the dependent variable of a spatial binomial probit model, where all the data and parameters of the model can be modified by the user.

Usage

sim_binomial_probit(W,X,beta,rho,model="SAR",M=NULL,lambda=NULL,
sigma2=1,ord_iW=6,seed=123)

Arguments

W
the spatial weight matrix (works for "SAR" and "SEM" models).
X
the matrix of covariates.
beta
the value of the covariates parameters.
rho
the value of the spatial dependence parameter (works for "SAR" and "SEM" models).
model
the type of model, between "SAR", "SEM", "SARAR" (Default is "SAR").
M
the second spatial weight matrix (only if model is "SARAR").
lambda
the value of the spatial dependence parameter (only if model is "SARAR").
sigma2
the variance of the error term (Defaul is 1).
ord_iW
the order of approximation of the matrix $(I_n-\rho W)^{-1}$.
seed
to set the random generator seed of the error term.

Value

  • a vector of zeros and ones

Details

The sim_binomial_probit generates a vector of dependent variables for a spatial probit model. It allows to simulate the following DGPs (Data Generating Process): SAR $$z = (I_n-\rho W)^{-1}(X\beta+\epsilon)$$ SEM $$z = (X\beta+(I_n-\rho W)^{-1}\epsilon)$$ SARAR $$z = (I_n-\rho W)^{-1}(X\beta+(I_n-\lambda M)^{-1}\epsilon)$$ where $\epsilon$ are independent and normally distributed with mean zero and variance sigma2 (default is 1).

The matrix X of covariates, the corresponding parameters beta, the spatial weight matrix W and the corresponding spatial depndence parameter rho need to be passed by the user. The matrix $(I_n-\rho W)^{-1}$ is computed using the ApproxiW function, that can either invert $(I_n-\rho W)$ exactely, if order_iW=0 (not suitable for n bigger than 1000), or using the Taylor approximation $$(I_n-\rho W)^{-1}= I_n+\rho W+\rho^2 W^2+\ldots$$ of order order_iW (default is approximation of order 6).

See Also

generate_W, SpatialProbitFit.

Examples

Run this code
n <- 1000
nneigh <- 3
rho <- 0.5
beta <- c(4,-2,1)
W <- generate_W(n,nneigh)
X <- cbind(1,rnorm(n,2,2),rnorm(n,0,1))
y <- sim_binomial_probit(W,X,beta,rho,model="SAR") #SAR model
y <- sim_binomial_probit(W,X,beta,rho,model="SEM") #SEM model
M <- generate_W(n,nneigh,seed=1)
lambda <- -0.5
y <- sim_binomial_probit(W,X,beta,rho,model="SARAR",M=M,lambda=lambda) #SARAR

Run the code above in your browser using DataLab