SpatialPOP: package for generation of spatial data along with spatial coordinates and spatially varying model parameters

Introduction

****
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 simulated dataset based on spatially varying regression model

****

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)
coord_grid=spatial_grid(c(1:5),c(1:5))
coord_grid=as.data.frame(coord_grid)
names(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)

coord_grid=spatial_grid(c(1:5),c(1:5))
coord_grid=as.data.frame(coord_grid)
names(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
N<-nrow(coord_grid)
N
## [1] 25
m<-sqrt(nrow(coord_grid))
m
## [1] 5
spatial_data<-spatialPOP(25,5,c(1:5),c(1:5))
spatial_data
##              Y          X latitude longitude        B0        B1
## 1  -0.09036574 0.91416432        0         0 0.0000000 0.0000000
## 2   2.00336187 0.24996962        1         0 0.1666667 0.3333333
## 3  -0.40821779 0.32837207        2         0 0.3333333 0.6666667
## 4   0.94348782 0.67031801        3         0 0.5000000 1.0000000
## 5   2.05243495 0.54335601        4         0 0.6666667 1.3333333
## 6   1.38693555 0.21026237        0         1 0.1666667 0.0000000
## 7  -0.27211172 0.05739187        1         1 0.3333333 0.3333333
## 8   2.31933055 0.50813546        2         1 0.5000000 0.6666667
## 9   0.36960799 0.29021876        3         1 0.6666667 1.0000000
## 10  1.08190039 0.47325103        4         1 0.8333333 1.3333333
## 11  0.62293420 0.80592874        0         2 0.3333333 0.0000000
## 12  0.28289018 0.67826374        1         2 0.5000000 0.3333333
## 13  2.24279593 0.89029969        2         2 0.6666667 0.6666667
## 14  2.44773816 0.81179440        3         2 0.8333333 1.0000000
## 15  3.82959508 0.09154762        4         2 1.0000000 1.3333333
## 16 -0.88985431 0.11119743        0         3 0.5000000 0.0000000
## 17  0.75665933 0.79464957        1         3 0.6666667 0.3333333
## 18  3.27277815 0.70842163        2         3 0.8333333 0.6666667
## 19  1.86216707 0.03714377        3         3 1.0000000 1.0000000
## 20  2.64382874 0.47663032        4         3 1.1666667 1.3333333
## 21  1.12548736 0.55948127        0         4 0.6666667 0.0000000
## 22  0.91673155 0.18721948        1         4 0.8333333 0.3333333
## 23  2.32869598 0.73549713        2         4 1.0000000 0.6666667
## 24  1.89653303 0.78204512        3         4 1.1666667 1.0000000
## 25  0.86462394 0.20929364        4         4 1.3333333 1.3333333