****
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 -0.891472527 0.00823234 0 0 0.0000000 0.0000000
## 2 0.391774436 0.23253285 1 0 0.1666667 0.3333333
## 3 0.754636299 0.90342016 2 0 0.3333333 0.6666667
## 4 0.689986013 0.76365119 3 0 0.5000000 1.0000000
## 5 -0.118914927 0.54021183 4 0 0.6666667 1.3333333
## 6 0.006648299 0.85244763 0 1 0.1666667 0.0000000
## 7 0.926334035 0.81978337 1 1 0.3333333 0.3333333
## 8 0.877404503 0.23481600 2 1 0.5000000 0.6666667
## 9 -0.693881009 0.13510860 3 1 0.6666667 1.0000000
## 10 1.725796288 0.49814040 4 1 0.8333333 1.3333333
## 11 1.432545907 0.03277423 0 2 0.3333333 0.0000000
## 12 -1.201911386 0.07815857 1 2 0.5000000 0.3333333
## 13 -0.015836874 0.13549746 2 2 0.6666667 0.6666667
## 14 0.504845273 0.22494198 3 2 0.8333333 1.0000000
## 15 0.175966337 0.19198541 4 2 1.0000000 1.3333333
## 16 2.315683176 0.24268247 0 3 0.5000000 0.0000000
## 17 0.745685334 0.29228764 1 3 0.6666667 0.3333333
## 18 1.899054254 0.28551411 2 3 0.8333333 0.6666667
## 19 2.430815410 0.41682216 3 3 1.0000000 1.0000000
## 20 0.809411423 0.12245057 4 3 1.1666667 1.3333333
## 21 1.052437545 0.56574315 0 4 0.6666667 0.0000000
## 22 -0.052318995 0.93222596 1 4 0.8333333 0.3333333
## 23 0.567859424 0.36221107 2 4 1.0000000 0.6666667
## 24 1.839038191 0.79747388 3 4 1.1666667 1.0000000
## 25 1.320047639 0.02240958 4 4 1.3333333 1.3333333