SpPOP: Package for Generation of Spatial Population under Different Levels of Relationships among Variables

Introduction

****
The developed package can be used to generate a spatial population for different levels of relationships among the dependent and auxiliary variables along with spatially varying model parameters. A spatial layout is designed as a [0,k-1]x[0,k-1] square region on which observations are collected at (k x k) lattice points with a unit distance between any two neighbouring points along the horizontal and vertical axes. Regression coefficients of the spatially varying regression model are generated using both linear and non-linear function of locations. In total eight different types of population can be generated. Details of which are given below.

****

Generation of simulated spatial population based on spatially varying regression model where the model parameters are generated based on both linear and non-linear functions of latitudes and longitudes

****

Generation of spatial coordinates of locations

The size of the population is N= k2. The spatial coordinates of the locations of observations can be expressed by the following equations

( Latitudei, Longitudei )= ( mod(i-1,k), [(i-1)/k] ), i= 1,…, k2

where, mod(i-1,k) is the remainder of (i-1) divided by k and [(i-1)/k] is the integer part of the number (i-1)/k

Generation of auxiliary variable from uniform distribution

Auxiliary variables has been generated independently from the uniform distribution i.e. U(0,1)

X =runif(N,0,1)

Error term drawn independently from normal distribution i.e. N(0,1)

e =rnorm(N, mean=0, sd=1)

For the function SpPOP_linear1

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and one explanatory variable (i.e. X). The auxiliary variable has been generated following U(0,1) and the regression coefficients are generated as linear function of latitudes and longitudes

Generation of spatially varying regression coefficients as linear function of latitudes and longitudes

B0=(Latitudei+Longitudei)/18

B1=(Latitudei/9)

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(SpPOP)
coords_grid=expand.grid(c(1:5),c(1:5))
coords_grid=as.data.frame(coords_grid)
names(coords_grid)=cbind("x","y")
coords_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(coords_grid)

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)

coords_grid=expand.grid(c(1:5),c(1:5))
coords_grid=as.data.frame(coords_grid)
names(coords_grid)=cbind("x","y")
coords_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(coords_grid)
N
## [1] 25
k<-sqrt(nrow(coords_grid))
k
## [1] 5
sp_linear1<-SpPOP_linear1(25,5,c(1:5),c(1:5))
sp_linear1
##               Y          X latitude longitude         B0        B1
## 1  -0.523708461 0.60703066        0         0 0.00000000 0.0000000
## 2   1.159740262 0.37300179        1         0 0.05555556 0.1111111
## 3   0.250019903 0.26099197        2         0 0.11111111 0.2222222
## 4  -1.594087336 0.32260345        3         0 0.16666667 0.3333333
## 5   0.656736485 0.47591851        4         0 0.22222222 0.4444444
## 6   0.442106287 0.86478162        0         1 0.05555556 0.0000000
## 7  -0.820608679 0.22371606        1         1 0.11111111 0.1111111
## 8   1.041726490 0.74897492        2         1 0.16666667 0.2222222
## 9   1.344643501 0.52010363        3         1 0.22222222 0.3333333
## 10  0.811535492 0.22939285        4         1 0.27777778 0.4444444
## 11  0.596534782 0.99393956        0         2 0.11111111 0.0000000
## 12  0.772570739 0.90293107        1         2 0.16666667 0.1111111
## 13  0.009259283 0.37863158        2         2 0.22222222 0.2222222
## 14 -0.076612751 0.34758800        3         2 0.27777778 0.3333333
## 15  2.600180317 0.50353028        4         2 0.33333333 0.4444444
## 16 -0.194575079 0.28818347        0         3 0.16666667 0.0000000
## 17  0.544261031 0.81658645        1         3 0.22222222 0.1111111
## 18  1.348535989 0.11851774        2         3 0.27777778 0.2222222
## 19  2.409983610 0.71387180        3         3 0.33333333 0.3333333
## 20  0.679766240 0.24941098        4         3 0.38888889 0.4444444
## 21 -0.094518545 0.50075355        0         4 0.22222222 0.0000000
## 22 -0.573326185 0.74441117        1         4 0.27777778 0.1111111
## 23  1.612816529 0.03045594        2         4 0.33333333 0.2222222
## 24  1.487048843 0.10620518        3         4 0.38888889 0.3333333
## 25  1.519190587 0.18594914        4         4 0.44444444 0.4444444

For the function SpPOP_linear2

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and three explanatory variables (i.e. X1,X2 and X3). The auxiliary variables have been generated independently from the uniform distribution U(0,1) and the regression coefficients are generated as linear function of latitudes and longitudes

Generation of spatially varying regression coefficients as linear function of latitudes and longitudes

B0=(Latitudei+Longitudei)/6

B1=(Latitudei/3)

B2=(Longitudei/3)

B3=(2*Longitudei)

Generation of auxiliary variables independently from the uniform distribution

X1 =runif(N,0,1), X2 =runif(N,0,1) and X3 =runif(N,0,1)

Spatially varying regression model for generating the response variable

Yi = B0( Latitudei,Longitudei ) + B1( Latitudei,Longitudei )* X1i + B2(Latitudei,Longitudei)* X2i + B3( Latitudei,Longitudei )*X3i + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_linear2<-SpPOP_linear2(25,5,c(1:5),c(1:5))
sp_linear2
##            Y         X1        X2         X3 latitude longitude        B0
## 1  0.2680836 0.56096521 0.7845377 0.91129871        0         0 0.0000000
## 2  1.5037569 0.08139527 0.7225658 0.54841358        1         0 0.1666667
## 3  2.1637387 0.35059319 0.8689103 0.19771965        2         0 0.3333333
## 4  0.7251062 0.63692477 0.6173284 0.51960961        3         0 0.5000000
## 5  0.5341853 0.82517538 0.7756285 0.15683968        4         0 0.6666667
## 6  4.2336923 0.44719716 0.4838516 0.95194733        0         1 0.1666667
## 7  0.5170109 0.96609624 0.4190949 0.45030047        1         1 0.3333333
## 8  2.9610509 0.20030414 0.4657155 0.81808435        2         1 0.5000000
## 9  3.6483474 0.75769615 0.9590858 0.89448709        3         1 0.6666667
## 10 4.5852949 0.61682082 0.7401986 0.19968194        4         1 0.8333333
## 11 1.6146907 0.37791512 0.6780373 0.78876829        0         2 0.3333333
## 12 1.8830973 0.37193936 0.7268256 0.60908234        1         2 0.5000000
## 13 2.9085054 0.85054386 0.1084043 0.08598896        2         2 0.6666667
## 14 3.5800913 0.83715631 0.7821508 0.72595454        3         2 0.8333333
## 15 3.9082313 0.08397725 0.1851677 0.74543995        4         2 1.0000000
## 16 1.8707802 0.37722871 0.2399849 0.62071853        0         3 0.5000000
## 17 4.6664376 0.21805740 0.6620871 0.62672834        1         3 0.6666667
## 18 7.9715864 0.77065756 0.5710769 0.96321238        2         3 0.8333333
## 19 1.9628586 0.06898979 0.3934157 0.30085003        3         3 1.0000000
## 20 3.9904576 0.91390650 0.3120867 0.52858004        4         3 1.1666667
## 21 3.2914075 0.26366344 0.8433465 0.27076959        0         4 0.6666667
## 22 5.6511076 0.10122944 0.1102671 0.57907932        1         4 0.8333333
## 23 2.0382903 0.48864424 0.9972828 0.14990658        2         4 1.0000000
## 24 8.5186217 0.08894110 0.3329409 0.77963639        3         4 1.1666667
## 25 2.8787377 0.98253064 0.6023541 0.23280971        4         4 1.3333333
##           B1        B2 B3
## 1  0.0000000 0.0000000  0
## 2  0.3333333 0.0000000  0
## 3  0.6666667 0.0000000  0
## 4  1.0000000 0.0000000  0
## 5  1.3333333 0.0000000  0
## 6  0.0000000 0.3333333  2
## 7  0.3333333 0.3333333  2
## 8  0.6666667 0.3333333  2
## 9  1.0000000 0.3333333  2
## 10 1.3333333 0.3333333  2
## 11 0.0000000 0.6666667  4
## 12 0.3333333 0.6666667  4
## 13 0.6666667 0.6666667  4
## 14 1.0000000 0.6666667  4
## 15 1.3333333 0.6666667  4
## 16 0.0000000 1.0000000  6
## 17 0.3333333 1.0000000  6
## 18 0.6666667 1.0000000  6
## 19 1.0000000 1.0000000  6
## 20 1.3333333 1.0000000  6
## 21 0.0000000 1.3333333  8
## 22 0.3333333 1.3333333  8
## 23 0.6666667 1.3333333  8
## 24 1.0000000 1.3333333  8
## 25 1.3333333 1.3333333  8

For the function SpPOP_linear3

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and one explanatory variable (i.e. X). The auxiliary variable has been generated from the uniform distribution U(0,2) and the regression coefficients are generated as linear function of locations

Generation of spatially varying regression coefficients as linear function of latitudes and longitudes

B0=(2*(Latitudei+Longitudei))/6

B1=(Latitudei/3)

Generation of auxiliary variable from the uniform distribution

X =runif(N,0,2),

Spatially varying regression model for generating the response variable

Yi = B0( Latitudei,Longitudei ) + B1( Latitudei,Longitudei )* Xi + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_linear3<-SpPOP_linear3(25,5,c(1:5),c(1:5))
sp_linear3
##             Y           X latitude longitude        B0        B1
## 1   1.0885733 0.238343054        0         0 0.0000000 0.0000000
## 2   0.6420699 1.779253904        1         0 0.3333333 0.3333333
## 3   2.3606802 0.422775195        2         0 0.6666667 0.6666667
## 4   0.9539875 1.558555946        3         0 1.0000000 1.0000000
## 5   1.9710414 0.837349381        4         0 1.3333333 1.3333333
## 6   2.2113158 1.183688673        0         1 0.1666667 0.0000000
## 7   1.0708322 0.980430864        1         1 0.5000000 0.3333333
## 8  -0.3286423 0.007568986        2         1 0.8333333 0.6666667
## 9   2.5660041 0.316243629        3         1 1.1666667 1.0000000
## 10  3.6916986 0.776685741        4         1 1.5000000 1.3333333
## 11  0.4076708 0.542295384        0         2 0.3333333 0.0000000
## 12  0.1934347 1.219906504        1         2 0.6666667 0.3333333
## 13  1.7123027 1.440498914        2         2 1.0000000 0.6666667
## 14  3.3636199 1.742941547        3         2 1.3333333 1.0000000
## 15  0.8960916 0.360181401        4         2 1.6666667 1.3333333
## 16 -0.3667573 0.286730488        0         3 0.5000000 0.0000000
## 17  2.0988108 0.845700020        1         3 0.8333333 0.3333333
## 18  1.9864357 1.593124469        2         3 1.1666667 0.6666667
## 19  2.9504246 1.789877117        3         3 1.5000000 1.0000000
## 20  2.8071480 1.058246323        4         3 1.8333333 1.3333333
## 21  1.1720664 0.355766476        0         4 0.6666667 0.0000000
## 22  1.0337497 1.075867105        1         4 1.0000000 0.3333333
## 23  1.3702905 0.725779292        2         4 1.3333333 0.6666667
## 24  2.9804434 1.908143233        3         4 1.6666667 1.0000000
## 25  3.9054127 1.072526257        4         4 2.0000000 1.3333333

For the function SpPOP_linear4

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and one explanatory variable (i.e. X). The auxiliary variable has been generated from the uniform distribution U(0,2) and the regression coefficients are generated as linear function of locations. In this function, we have used non-linear model for generating the response variable i.e. the relationship between the response and auxiliary variable is non-linear in nature.

Generation of spatially varying regression coefficients as linear function of latitudes and longitudes

B0=(2*(Latitudei+Longitudei))/6

B1=(Latitudei/3)

Generation of auxiliary variable from the uniform distribution

X =runif(N,0,2),

Spatially varying regression model for generating the response variable The relation between Y and X is non-linear in the model

Yi = B0( Latitudei,Longitudei ) + exp[B1( Latitudei,Longitudei )* Xi] + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_linear4<-SpPOP_linear4(25,5,c(1:5),c(1:5))
sp_linear4
##            Y          X latitude longitude        B0        B1
## 1  0.2602665 0.70250391        0         0 0.0000000 0.0000000
## 2  1.8373870 0.91097365        1         0 0.3333333 0.3333333
## 3  1.2133237 0.66470788        2         0 0.6666667 0.6666667
## 4  3.9625301 1.51653121        3         0 1.0000000 1.0000000
## 5  6.5669184 1.21527068        4         0 1.3333333 1.3333333
## 6  3.1500097 0.75809633        0         1 0.1666667 0.0000000
## 7  1.4887148 1.57728027        1         1 0.5000000 0.3333333
## 8  4.1626338 1.44930210        2         1 0.8333333 0.6666667
## 9  6.5222347 1.66868191        3         1 1.1666667 1.0000000
## 10 2.2453146 0.09901408        4         1 1.5000000 1.3333333
## 11 1.4351102 0.50857768        0         2 0.3333333 0.0000000
## 12 2.8440490 1.53770161        1         2 0.6666667 0.3333333
## 13 5.2705601 1.97839628        2         2 1.0000000 0.6666667
## 14 3.0405436 0.66779715        3         2 1.3333333 1.0000000
## 15 4.9639868 0.60292956        4         2 1.6666667 1.3333333
## 16 0.7820484 1.83316059        0         3 0.5000000 0.0000000
## 17 1.4526544 1.57767344        1         3 0.8333333 0.3333333
## 18 5.2160730 1.97387085        2         3 1.1666667 0.6666667
## 19 3.3280626 0.13329474        3         3 1.5000000 1.0000000
## 20 5.3562055 0.86915280        4         3 1.8333333 1.3333333
## 21 2.0281716 0.41755617        0         4 0.6666667 0.0000000
## 22 1.5257592 0.12720120        1         4 1.0000000 0.3333333
## 23 3.8330486 1.47945445        2         4 1.3333333 0.6666667
## 24 4.9047629 1.12847674        3         4 1.6666667 1.0000000
## 25 5.7685097 0.97865085        4         4 2.0000000 1.3333333

For the function SpPOP_linear5

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and two explanatory variables (i.e. X1 and X2). The auxiliary variables are drawn independently from the uniform distribution U(0,2) and normal distribution N(1,1) and the regression coefficients are generated as linear function of locations. In this function, we have used non-linear model for generating the response variable i.e. the relationship between the response and auxiliary variables are non-linear in nature.

Generation of spatially varying regression coefficients as linear function of latitudes and longitudes

B0=(Latitudei+Longitudei)/6

B1=(Latitudei/3)

B2=(Longitudei/3)

Generation of auxiliary variables independently from the uniform and normal distribution

X1 =runif(N,0,2) and X2 =rnorm(N,1,1)

Spatially varying regression model for generating the response variable

Yi = B0( Latitudei,Longitudei ) + exp[(B1( Latitudei,Longitudei )* X1i)+(B2( Latitudei,Longitudei )* X2i)] + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_linear5<-SpPOP_linear5(25,5,c(1:5),c(1:5))
sp_linear5
##            Y         X1          X2 latitude longitude        B0        B1
## 1   1.725059 1.07581458  0.97916571        0         0 0.0000000 0.0000000
## 2   2.359311 0.46970269 -0.48107750        1         0 0.1666667 0.3333333
## 3   1.535438 0.36195442  1.51239983        2         0 0.3333333 0.6666667
## 4   3.263073 0.60670640  0.58987214        3         0 0.5000000 1.0000000
## 5  13.890669 1.82886201 -2.48266538        4         0 0.6666667 1.3333333
## 6   1.352267 0.17072278 -0.77131006        0         1 0.1666667 0.0000000
## 7   2.737575 1.13716912  0.03284537        1         1 0.3333333 0.3333333
## 8   2.945421 1.39602573  0.33434966        2         1 0.5000000 0.6666667
## 9   3.296661 0.77600740  2.27514313        3         1 0.6666667 1.0000000
## 10  8.100165 1.11492662  1.60281968        4         1 0.8333333 1.3333333
## 11  3.811418 0.23889923  1.30947514        0         2 0.3333333 0.0000000
## 12  2.931275 0.86779827  1.03579231        1         2 0.5000000 0.3333333
## 13  7.333650 1.58900169  0.97153567        2         2 0.6666667 0.6666667
## 14  6.366891 0.85006776  1.31626935        3         2 0.8333333 1.0000000
## 15 66.771263 1.96070597  2.29623389        4         2 1.0000000 1.3333333
## 16  1.812046 1.29718163  0.24262519        0         3 0.5000000 0.0000000
## 17  6.353842 1.41825095  1.25776015        1         3 0.6666667 0.3333333
## 18  3.565772 1.09748650  0.50347183        2         3 0.8333333 0.6666667
## 19  3.738564 0.88714177  0.17940913        3         3 1.0000000 1.0000000
## 20  2.968831 0.87384293 -1.11724932        4         3 1.1666667 1.3333333
## 21  4.358707 0.05308814  1.11062707        0         4 0.6666667 0.0000000
## 22  4.211346 0.68852619  1.04255305        1         4 0.8333333 0.3333333
## 23  4.464039 0.95726332  0.62266074        2         4 1.0000000 0.6666667
## 24 35.057228 1.22228063  1.70619523        3         4 1.1666667 1.0000000
## 25  3.586407 0.40277103 -0.65954914        4         4 1.3333333 1.3333333
##           B2
## 1  0.0000000
## 2  0.0000000
## 3  0.0000000
## 4  0.0000000
## 5  0.0000000
## 6  0.3333333
## 7  0.3333333
## 8  0.3333333
## 9  0.3333333
## 10 0.3333333
## 11 0.6666667
## 12 0.6666667
## 13 0.6666667
## 14 0.6666667
## 15 0.6666667
## 16 1.0000000
## 17 1.0000000
## 18 1.0000000
## 19 1.0000000
## 20 1.0000000
## 21 1.3333333
## 22 1.3333333
## 23 1.3333333
## 24 1.3333333
## 25 1.3333333

For the function SpPOP_nonlinear1

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and one explanatory variable (i.e. X). The auxiliary variable has been generated from the uniform distribution U(0,1) and the regression coefficients are generated as non-linear function of locations.

Generation of spatially varying regression coefficients as non-linear function of latitudes and longitudes

B0= 2* sin((pi * Latitudei)/6)

B1=(Latitudei2+Longitudei2)/18

Generation of auxiliary variable from the uniform distribution

X =runif(N,0,1),

Spatially varying regression model for generating the response variable

Yi = B0( Latitudei,Longitudei ) + B1( Latitudei,Longitudei )* Xi + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_nonlinear1<-SpPOP_nonlinear1(25,5,c(1:5),c(1:5))
sp_nonlinear1
##              Y           X latitude longitude       B0         B1
## 1  -0.11732249 0.832725241        0         0 0.000000 0.00000000
## 2   0.79217982 0.881660752        1         0 1.000000 0.05555556
## 3   1.94986347 0.536264517        2         0 1.732051 0.22222222
## 4   1.71714350 0.700439711        3         0 2.000000 0.50000000
## 5   0.04511574 0.169875944        4         0 1.732051 0.88888889
## 6  -0.44349460 0.361124205        0         1 0.000000 0.05555556
## 7   1.46117776 0.973060822        1         1 1.000000 0.11111111
## 8   2.47065162 0.945222880        2         1 1.732051 0.27777778
## 9   1.68313483 0.859373069        3         1 2.000000 0.55555556
## 10  2.52354362 0.006984981        4         1 1.732051 0.94444444
## 11  1.49349740 0.735515547        0         2 0.000000 0.22222222
## 12 -0.20812706 0.424704973        1         2 1.000000 0.27777778
## 13  0.44051867 0.083770276        2         2 1.732051 0.44444444
## 14  2.50279951 0.878467132        3         2 2.000000 0.72222222
## 15  2.44254616 0.031319811        4         2 1.732051 1.11111111
## 16  0.67799050 0.953534487        0         3 0.000000 0.50000000
## 17 -0.38288168 0.915305328        1         3 1.000000 0.55555556
## 18  1.04553626 0.534169179        2         3 1.732051 0.72222222
## 19  4.62781873 0.680281734        3         3 2.000000 1.00000000
## 20  0.93212499 0.553818084        4         3 1.732051 1.38888889
## 21  1.44800070 0.988553812        0         4 0.000000 0.88888889
## 22  2.04901597 0.636977593        1         4 1.000000 0.94444444
## 23  1.85082727 0.745512075        2         4 1.732051 1.11111111
## 24  2.25361013 0.519462935        3         4 2.000000 1.38888889
## 25  2.24122685 0.144622801        4         4 1.732051 1.77777778

For the function SpPOP_nonlinear2

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and one explanatory variable (i.e. X). The auxiliary variable has been generated from the uniform distribution U(0,1) and the regression coefficients are generated as non-linear function of locations.

Generation of spatially varying regression coefficients as non-linear function of latitudes and longitudes

B0= 2 * sin(pi * (Latitudei+Longitudei)/6)

B1=(1/2)* exp[Latitudei+Longitudei]

Generation of auxiliary variable from the uniform distribution

X =runif(N,0,1),

Spatially varying regression model for generating the response variable

Yi = B0( Latitudei,Longitudei ) + B1( Latitudei,Longitudei )* Xi + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_nonlinear2<-SpPOP_nonlinear2(25,5,c(1:5),c(1:5))
sp_nonlinear2
##                Y          X latitude longitude            B0          B1
## 1    -0.02047176 0.77767728        0         0  0.000000e+00    0.500000
## 2     3.12954408 0.78773049        1         0  1.000000e+00    1.359141
## 3     3.07333112 0.07530529        2         0  1.732051e+00    3.694528
## 4     6.77604784 0.65316816        3         0  2.000000e+00   10.042768
## 5    19.17766850 0.65737622        4         0  1.732051e+00   27.299075
## 6     2.75759395 0.58935794        0         1  1.000000e+00    1.359141
## 7     2.15839050 0.27104620        1         1  1.732051e+00    3.694528
## 8     7.81851836 0.60151533        2         1  2.000000e+00   10.042768
## 9    27.11755142 0.92625930        3         1  1.732051e+00   27.299075
## 10    9.20221470 0.12674161        4         1  1.000000e+00   74.206580
## 11    0.83155578 0.16007768        0         2  1.732051e+00    3.694528
## 12    3.00113863 0.14192044        1         2  2.000000e+00   10.042768
## 13   18.72854391 0.68672336        2         2  1.732051e+00   27.299075
## 14   57.22949791 0.76230609        3         2  1.000000e+00   74.206580
## 15   35.26100645 0.17074687        4         2  2.449294e-16  201.714397
## 16    4.01859302 0.12282429        0         3  2.000000e+00   10.042768
## 17    7.27704133 0.15429721        1         3  1.732051e+00   27.299075
## 18   40.92574667 0.53215472        2         3  1.000000e+00   74.206580
## 19  114.75863771 0.57069568        3         3  2.449294e-16  201.714397
## 20  345.70312016 0.63100385        4         3 -1.000000e+00  548.316579
## 21   27.10778804 0.90515424        0         4  1.732051e+00   27.299075
## 22   64.86753179 0.86345552        1         4  1.000000e+00   74.206580
## 23   48.96395955 0.23696885        2         4  2.449294e-16  201.714397
## 24  531.80163557 0.97087702        3         4 -1.000000e+00  548.316579
## 25 1271.18667905 0.85347649        4         4 -1.732051e+00 1490.478994

For the function SpPOP_nonlinear3

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and three explanatory variables (i.e. X1,X2 and X3). The auxiliary variables have been generated independently from the uniform distribution U(0,1) and the regression coefficients are generated as non-linear function of latitudes and longitudes

Generation of spatially varying regression coefficients as non-linear function of latitudes and longitudes

B0= 2* sin((pi * Latitudei)/6)

B1=(Latitudei2+Longitudei2)/18

B2= 4 * sin(pi * (Latitudei+Longitudei)/6)

B3=(1/2)* exp[Latitudei+Longitudei]

Generation of auxiliary variables independently from the uniform distribution

X1 =runif(N,0,1), X2 =runif(N,0,1) and X3 =runif(N,0,1)

Spatially varying regression model for generating the response variable

Yi = B0( Latitudei,Longitudei ) + B1( Latitudei,Longitudei )* X1i + B2(Latitudei,Longitudei)* X2i + B3( Latitudei,Longitudei )*X3i + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_nonlinear3<-SpPOP_nonlinear3(25,5,c(1:5),c(1:5))
sp_nonlinear3
##              Y          X1         X2         X3 latitude longitude       B0
## 1    0.2859024 0.161582365 0.67775091 0.88946824        0         0 0.000000
## 2    3.5072366 0.055958722 0.70662310 0.95601026        1         0 1.000000
## 3    3.7047298 0.653811397 0.66504208 0.08011251        2         0 1.732051
## 4   12.2494895 0.335760579 0.72037598 0.87552569        3         0 2.000000
## 5   24.5751355 0.545851475 0.35946109 0.79903300        4         0 1.732051
## 6    2.2257344 0.364169041 0.43300089 0.46449942        0         1 0.000000
## 7    6.6703922 0.134760688 0.58766550 0.97623036        1         1 1.000000
## 8    7.8936614 0.004195288 0.11476012 0.46418798        2         1 1.732051
## 9   22.2238792 0.201058046 0.16018025 0.78157794        3         1 2.000000
## 10  22.8310213 0.302867056 0.27103396 0.25174748        4         1 1.732051
## 11   5.0706432 0.678862125 0.22983302 0.85050041        0         2 0.000000
## 12   8.7493740 0.659755270 0.73175017 0.20951229        1         2 1.000000
## 13  22.3696791 0.335357123 0.66285151 0.61003620        2         2 1.732051
## 14   7.5692774 0.895883575 0.40215899 0.06938359        3         2 2.000000
## 15 173.8712222 0.471073666 0.70294527 0.85468519        4         2 1.732051
## 16   6.6767246 0.314581291 0.57034693 0.57266441        0         3 0.000000
## 17  11.3098774 0.495757556 0.26821489 0.42579996        1         3 1.000000
## 18  62.3674022 0.153168979 0.30520683 0.83553756        2         3 1.732051
## 19  83.9359126 0.624227112 0.56631669 0.40987038        3         3 2.000000
## 20 476.8162988 0.946116726 0.26992089 0.86581360        4         3 1.732051
## 21  24.2927281 0.272098442 0.34190275 0.79457943        0         4 0.000000
## 22  42.7771623 0.033037232 0.23501262 0.55708660        1         4 1.000000
## 23 100.6089357 0.173365080 0.08658056 0.49263728        2         4 1.732051
## 24 325.9885199 0.862657502 0.22046046 0.59101412        3         4 2.000000
## 25 953.0429845 0.004293672 0.43324324 0.64041385        4         4 1.732051
##            B1            B2          B3
## 1  0.00000000  0.000000e+00    0.500000
## 2  0.05555556  2.000000e+00    1.359141
## 3  0.22222222  3.464102e+00    3.694528
## 4  0.50000000  4.000000e+00   10.042768
## 5  0.88888889  3.464102e+00   27.299075
## 6  0.05555556  2.000000e+00    1.359141
## 7  0.11111111  3.464102e+00    3.694528
## 8  0.27777778  4.000000e+00   10.042768
## 9  0.55555556  3.464102e+00   27.299075
## 10 0.94444444  2.000000e+00   74.206580
## 11 0.22222222  3.464102e+00    3.694528
## 12 0.27777778  4.000000e+00   10.042768
## 13 0.44444444  3.464102e+00   27.299075
## 14 0.72222222  2.000000e+00   74.206580
## 15 1.11111111  4.898587e-16  201.714397
## 16 0.50000000  4.000000e+00   10.042768
## 17 0.55555556  3.464102e+00   27.299075
## 18 0.72222222  2.000000e+00   74.206580
## 19 1.00000000  4.898587e-16  201.714397
## 20 1.38888889 -2.000000e+00  548.316579
## 21 0.88888889  3.464102e+00   27.299075
## 22 0.94444444  2.000000e+00   74.206580
## 23 1.11111111  4.898587e-16  201.714397
## 24 1.38888889 -2.000000e+00  548.316579
## 25 1.77777778 -3.464102e+00 1490.478994

For the function SpPOP_nonlinear4

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and one explanatory variable (i.e. X). The auxiliary variable has been generated from the uniform distribution U(0,2) and the regression coefficients are generated as non-linear function of locations. In this function, we have used non-linear model for generating the response variable i.e. the relationship between the response and auxiliary variable is non-linear in nature.

Generation of spatially varying regression coefficients as non-linear function of latitudes and longitudes

B0= 2* sin((pi * Latitudei)/6)

B1=(Latitudei2+Longitudei2)/18

Generation of auxiliary variable from the uniform distribution

X =runif(N,0,2),

Spatially varying regression model for generating the response variable The relation between Y and X is non-linear in the model

Yi = B0( Latitudei,Longitudei ) + exp[B1( Latitudei,Longitudei )* Xi] + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_nonlinear4<-SpPOP_nonlinear4(25,5,c(1:5),c(1:5))
sp_nonlinear4
##             Y          X latitude longitude       B0         B1
## 1   0.8076436 0.51916017        0         0 0.000000 0.00000000
## 2   1.0617922 0.37012345        1         0 1.000000 0.05555556
## 3   2.0699950 0.02364800        2         0 1.732051 0.22222222
## 4   3.6745054 0.06381373        3         0 2.000000 0.50000000
## 5   4.2687611 0.87546862        4         0 1.732051 0.88888889
## 6   1.2534735 1.71633046        0         1 0.000000 0.05555556
## 7   2.0938149 1.12754956        1         1 1.000000 0.11111111
## 8   4.3911723 0.81214457        2         1 1.732051 0.27777778
## 9   2.1687335 0.14465546        3         1 2.000000 0.55555556
## 10  6.1270876 1.78651287        4         1 1.732051 0.94444444
## 11  2.3184981 0.82264854        0         2 0.000000 0.22222222
## 12  1.0218896 0.73827092        1         2 1.000000 0.27777778
## 13  5.2334730 1.23638000        2         2 1.732051 0.44444444
## 14  3.6043670 0.69154940        3         2 2.000000 0.72222222
## 15  8.1263966 1.85172144        4         2 1.732051 1.11111111
## 16  2.8225611 0.92475814        0         3 0.000000 0.50000000
## 17  3.1478383 0.73497994        1         3 1.000000 0.55555556
## 18  7.4297802 1.99795864        2         3 1.732051 0.72222222
## 19  3.6736239 0.10008307        3         3 2.000000 1.00000000
## 20  8.7719424 1.32412669        4         3 1.732051 1.38888889
## 21  4.3853157 1.80326999        0         4 0.000000 0.88888889
## 22  2.6084303 0.94803831        1         4 1.000000 0.94444444
## 23  8.2285422 1.83176597        2         4 1.732051 1.11111111
## 24  4.9327299 0.75339933        3         4 2.000000 1.38888889
## 25 27.3010968 1.78221301        4         4 1.732051 1.77777778

For the function SpPOP_nonlinear5

The developed function returns a spatial population consist of simulated response variable (i.e. Y) along with their spatial coordinates,spatially varying coefficients and two explanatory variables (i.e. X1 and X2). The auxiliary variables are drawn independently from the uniform distribution U(0,2) and normal distribution N(1,1) and the regression coefficients are generated as non-linear function of locations. In this function, we have used non-linear model for generating the response variable i.e. the relationship between the response and auxiliary variable is non-linear in nature.

Generation of spatially varying regression coefficients as non-linear function of latitudes and longitudes

B0= 2* sin((pi * Latitudei)/6)

B1=(Latitudei2+Longitudei2)/18

B2= 4 * sin(pi * (Latitudei+Longitudei)/6)

Generation of auxiliary variable from the uniform and normal distribution

X1 =runif(N,0,2) and X2 =rnorm(N,1,1)

Spatially varying regression model for generating the response variable The relation between Y and X’s is non-linear in the model

Yi = B0( Latitudei,Longitudei ) + exp[(B1( Latitudei,Longitudei )* X1i)+(B2( Latitudei,Longitudei )* X2i)] + ei ; i= 1,…, N

# Examples: Simulated population along with spatial coordinates and spatially varying model parameters

library(SpPOP)
sp_nonlinear5<-SpPOP_nonlinear5(25,5,c(1:5),c(1:5))
sp_nonlinear5
##               Y        X1         X2 latitude longitude       B0         B1
## 1  1.103903e+00 1.7726843  0.6931238        0         0 0.000000 0.00000000
## 2  5.850605e+00 0.4681129  0.7627186        1         0 1.000000 0.05555556
## 3  1.961385e+00 0.2284364 -0.7403483        2         0 1.732051 0.22222222
## 4  5.373880e+01 1.3447907  0.8200476        3         0 2.000000 0.50000000
## 5  1.071543e+03 0.1747166  1.9692052        4         0 1.732051 0.88888889
## 6  1.485138e+01 0.5841866  1.3025601        0         1 0.000000 0.05555556
## 7  4.136832e+01 1.8942626  0.9919833        1         1 1.000000 0.11111111
## 8  1.316942e+02 1.3193375  1.1229374        2         1 1.732051 0.27777778
## 9  1.724511e+04 0.4073500  2.7507396        3         1 2.000000 0.55555556
## 10 1.296532e+01 1.5332291  0.3989857        4         1 1.732051 0.94444444
## 11 8.313975e+01 0.3868766  1.2538381        0         2 0.000000 0.22222222
## 12 1.945610e+02 0.1617658  1.3048248        1         2 1.000000 0.27777778
## 13 2.129213e+02 0.3671498  1.4968874        2         2 1.732051 0.44444444
## 14 5.111629e+00 0.8055163  0.2132070        3         2 2.000000 0.72222222
## 15 7.289186e+00 1.4706585  0.5308819        4         2 1.732051 1.11111111
## 16 1.919799e+04 1.9088626  2.2270284        0         3 0.000000 0.50000000
## 17 1.366442e+03 0.8017310  1.9552640        1         3 1.000000 0.55555556
## 18 4.429240e+03 1.6647174  3.5967886        2         3 1.732051 0.72222222
## 19 9.712886e+00 1.8305691  1.6354156        3         3 2.000000 1.00000000
## 20 2.264272e+00 1.0556184  1.5446881        4         3 1.732051 1.38888889
## 21 7.866605e+01 1.2435629  0.9449393        0         4 0.000000 0.88888889
## 22 9.161498e+01 0.4883146  2.0214415        1         4 1.000000 0.94444444
## 23 4.248088e+00 0.5629063  0.7430984        2         4 1.732051 1.11111111
## 24 5.193690e-01 0.4193923  2.1132365        3         4 2.000000 1.38888889
## 25 5.137086e-01 0.4489261  2.9223826        4         4 1.732051 1.77777778
##               B2
## 1   0.000000e+00
## 2   2.000000e+00
## 3   3.464102e+00
## 4   4.000000e+00
## 5   3.464102e+00
## 6   2.000000e+00
## 7   3.464102e+00
## 8   4.000000e+00
## 9   3.464102e+00
## 10  2.000000e+00
## 11  3.464102e+00
## 12  4.000000e+00
## 13  3.464102e+00
## 14  2.000000e+00
## 15  4.898587e-16
## 16  4.000000e+00
## 17  3.464102e+00
## 18  2.000000e+00
## 19  4.898587e-16
## 20 -2.000000e+00
## 21  3.464102e+00
## 22  2.000000e+00
## 23  4.898587e-16
## 24 -2.000000e+00
## 25 -3.464102e+00