****
In this R package, a spatial dataset can be generated under the assumption that observations are collected from a two dimensional uniform grid consists of (m2) lattice points having unit distance between any two neighbouring points along the horizontal and vertical directions.
****
****
generation of spatial coordinates of locations
The size of the population is N= m2. The spatial coordinates of the locations of observations can be computed by the following expressions
( Latitudei, Longitudei )= ( mod(i-1,m), [(i-1)/m] ), i= 1,…, m2
where, mod(i-1,m) is the remainder of (i-1) divided by m and [(i-1)/m] is the integer part of the number (i-1)/m
generation of auxiliary variable from uniform distribution
X =runif(N,0,1)
error term drawn independently from normal distribution i.e. N(0,1)
e =rnorm(N, mean=0, sd=1)
generation of spatially varying regression coefficients
B0=(Latitudei+Longitudei)/6
B1=(Latitudei/3)
spatially varying regression model for generating the response variable
Yi = B0( Latitudei,Longitudei ) + B1( Latitudei,Longitudei )*Xi + ei ; i= 1,…, N
# Examples: generate an uniform two dimensional grid of lattice points
library(SpatialPOP)
=spatial_grid(c(1:5),c(1:5))
coord_grid=as.data.frame(coord_grid)
coord_gridnames(coord_grid)=cbind("x","y")
coord_grid
## x y
## 1 1 1
## 2 2 1
## 3 3 1
## 4 4 1
## 5 5 1
## 6 1 2
## 7 2 2
## 8 3 2
## 9 4 2
## 10 5 2
## 11 1 3
## 12 2 3
## 13 3 3
## 14 4 3
## 15 5 3
## 16 1 4
## 17 2 4
## 18 3 4
## 19 4 4
## 20 5 4
## 21 1 5
## 22 2 5
## 23 3 5
## 24 4 5
## 25 5 5
plot(coord_grid)
# Examples: simulated data along with spatial coordinates and spatially varying model parameters
library(SpatialPOP)
=spatial_grid(c(1:5),c(1:5))
coord_grid=as.data.frame(coord_grid)
coord_gridnames(coord_grid)=cbind("x","y")
coord_grid
## x y
## 1 1 1
## 2 2 1
## 3 3 1
## 4 4 1
## 5 5 1
## 6 1 2
## 7 2 2
## 8 3 2
## 9 4 2
## 10 5 2
## 11 1 3
## 12 2 3
## 13 3 3
## 14 4 3
## 15 5 3
## 16 1 4
## 17 2 4
## 18 3 4
## 19 4 4
## 20 5 4
## 21 1 5
## 22 2 5
## 23 3 5
## 24 4 5
## 25 5 5
<-nrow(coord_grid)
N N
## [1] 25
<-sqrt(nrow(coord_grid))
m m
## [1] 5
<-spatialPOP(25,5,c(1:5),c(1:5))
spatial_data spatial_data
## Y X latitude longitude B0 B1
## 1 1.26605154 0.006507932 0 0 0.0000000 0.0000000
## 2 1.91073017 0.831351819 1 0 0.1666667 0.3333333
## 3 1.77223415 0.775538277 2 0 0.3333333 0.6666667
## 4 0.98887579 0.030592480 3 0 0.5000000 1.0000000
## 5 1.93925956 0.299020177 4 0 0.6666667 1.3333333
## 6 -0.78809243 0.493949025 0 1 0.1666667 0.0000000
## 7 0.36148401 0.112926966 1 1 0.3333333 0.3333333
## 8 2.59411089 0.165608979 2 1 0.5000000 0.6666667
## 9 0.42654596 0.548260471 3 1 0.6666667 1.0000000
## 10 0.08807018 0.341807150 4 1 0.8333333 1.3333333
## 11 0.24545099 0.591042310 0 2 0.3333333 0.0000000
## 12 0.49500650 0.878522104 1 2 0.5000000 0.3333333
## 13 2.03860208 0.988028942 2 2 0.6666667 0.6666667
## 14 -0.02443551 0.128406113 3 2 0.8333333 1.0000000
## 15 0.89838614 0.274969956 4 2 1.0000000 1.3333333
## 16 0.90267101 0.718683174 0 3 0.5000000 0.0000000
## 17 -0.07287275 0.190991892 1 3 0.6666667 0.3333333
## 18 1.89283723 0.961637693 2 3 0.8333333 0.6666667
## 19 1.61050756 0.705824186 3 3 1.0000000 1.0000000
## 20 0.96746652 0.215200857 4 3 1.1666667 1.3333333
## 21 1.00901668 0.285288519 0 4 0.6666667 0.0000000
## 22 -1.41153583 0.371939152 1 4 0.8333333 0.3333333
## 23 0.96834603 0.480729702 2 4 1.0000000 0.6666667
## 24 2.78982231 0.310368277 3 4 1.1666667 1.0000000
## 25 0.37798502 0.623950482 4 4 1.3333333 1.3333333