## VIP: The output of the whole set of the examples can be examined
## by executing demo(demo_dgp_spsur, package="spsur")
################################################
### PANEL DATA (Tm = 1 or G = 1) ##
################################################
################################################
#### Example 1: DGP SLM model. G equations
################################################
rm(list = ls()) # Clean memory
Tm <- 1 # Number of time periods
G <- 3 # Number of equations
N <- 200 # Number of spatial elements
p <- 3 # Number of independent variables
Sigma <- matrix(0.3, ncol = G, nrow = G)
diag(Sigma) <- 1
Betas <- c(1, 2, 3, 1, -1, 0.5, 1, -0.5, 2)
rho <- 0.5 # level of spatial dependence
lambda <- 0.0 # spatial autocorrelation error term = 0
## random coordinates
co <- cbind(runif(N,0,1),runif(N,0,1))
lw <- spdep::nb2listw(spdep::knn2nb(spdep::knearneigh(co, k = 5,
longlat = FALSE)))
DGP <- dgp_spsur(Sigma = Sigma, Betas = Betas,
rho = rho, lambda = lambda, Tm = Tm,
G = G, N = N, p = p, listw = lw)
# \donttest{
SLM <- spsurml(X = DGP$X, Y = DGP$Y, Tm = Tm, N = N, G = G,
p = c(3, 3, 3), listw = lw, type = "slm")
summary(SLM)
################################################
### MULTI-DIMENSIONAL PANEL DATA G>1 and Tm>1 ##
################################################
rm(list = ls()) # Clean memory
Tm <- 10 # Number of time periods
G <- 3 # Number of equations
N <- 100 # Number of spatial elements
p <- 3 # Number of independent variables
Sigma <- matrix(0.5, ncol = G, nrow = G)
diag(Sigma) <- 1
Betas <- rep(1:3, G)
rho <- c(0.5, 0.1, 0.8)
lambda <- 0.0 # spatial autocorrelation error term = 0
## random coordinates
co <- cbind(runif(N,0,1),runif(N,0,1))
lw <- spdep::nb2listw(spdep::knn2nb(spdep::knearneigh(co, k = 5,
longlat = FALSE)))
DGP4 <- dgp_spsur(Sigma = Sigma, Betas = Betas, rho = rho,
lambda = lambda, Tm = Tm, G = G, N = N, p = p,
listw = lw)
SLM4 <- spsurml(Y = DGP4$Y, X = DGP4$X, G = G, N = N, Tm = Tm,
p = p, listw = lw, type = "slm")
summary(SLM4)
# }
Run the code above in your browser using DataLab