****
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)
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
# 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
## [1] 25
## [1] 5
## Y X latitude longitude B0 B1
## 1 -1.04999209 0.5688909 0 0 0.0000000 0.0000000
## 2 -0.33613849 0.2066181 1 0 0.1666667 0.3333333
## 3 0.46843679 0.7377698 2 0 0.3333333 0.6666667
## 4 1.45644327 0.9679425 3 0 0.5000000 1.0000000
## 5 2.61933220 0.3240950 4 0 0.6666667 1.3333333
## 6 -0.15832903 0.7895902 0 1 0.1666667 0.0000000
## 7 1.15595752 0.6699069 1 1 0.3333333 0.3333333
## 8 1.96838091 0.0117268 2 1 0.5000000 0.6666667
## 9 0.56979384 0.7746404 3 1 0.6666667 1.0000000
## 10 1.03853611 0.1867964 4 1 0.8333333 1.3333333
## 11 0.04567946 0.1639049 0 2 0.3333333 0.0000000
## 12 0.52532013 0.3162450 1 2 0.5000000 0.3333333
## 13 0.72395549 0.3271833 2 2 0.6666667 0.6666667
## 14 0.20215094 0.2178065 3 2 0.8333333 1.0000000
## 15 0.73299090 0.0786765 4 2 1.0000000 1.3333333
## 16 -0.14003316 0.7554128 0 3 0.5000000 0.0000000
## 17 0.69731115 0.6730101 1 3 0.6666667 0.3333333
## 18 1.05998285 0.4072683 2 3 0.8333333 0.6666667
## 19 1.61097887 0.6747239 3 3 1.0000000 1.0000000
## 20 1.91563524 0.9238567 4 3 1.1666667 1.3333333
## 21 -0.43173167 0.7429480 0 4 0.6666667 0.0000000
## 22 1.84545775 0.7984763 1 4 0.8333333 0.3333333
## 23 1.83861785 0.7675928 2 4 1.0000000 0.6666667
## 24 2.34375913 0.4682227 3 4 1.1666667 1.0000000
## 25 0.99197406 0.4909171 4 4 1.3333333 1.3333333