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   2.0847506 0.19711994        0         0 0.00000000 0.0000000
## 2  -0.1908818 0.68615500        1         0 0.05555556 0.1111111
## 3   0.5034180 0.12463850        2         0 0.11111111 0.2222222
## 4   0.4471763 0.07723530        3         0 0.16666667 0.3333333
## 5   1.4709401 0.29456697        4         0 0.22222222 0.4444444
## 6  -1.6599233 0.62600777        0         1 0.05555556 0.0000000
## 7  -0.6727445 0.10115499        1         1 0.11111111 0.1111111
## 8  -0.1032940 0.17095342        2         1 0.16666667 0.2222222
## 9   0.4789275 0.17750216        3         1 0.22222222 0.3333333
## 10  0.5135855 0.63731041        4         1 0.27777778 0.4444444
## 11  0.7906542 0.16211915        0         2 0.11111111 0.0000000
## 12 -0.1620686 0.40213061        1         2 0.16666667 0.1111111
## 13  1.2198084 0.19937617        2         2 0.22222222 0.2222222
## 14 -0.3123606 0.61601468        3         2 0.27777778 0.3333333
## 15  1.1743658 0.89414592        4         2 0.33333333 0.4444444
## 16 -0.4841511 0.39642593        0         3 0.16666667 0.0000000
## 17 -0.8542582 0.51348243        1         3 0.22222222 0.1111111
## 18 -1.1914184 0.10402783        2         3 0.27777778 0.2222222
## 19  0.9441363 0.90436516        3         3 0.33333333 0.3333333
## 20  1.7180409 0.33014396        4         3 0.38888889 0.4444444
## 21 -0.2536968 0.39001973        0         4 0.22222222 0.0000000
## 22 -0.2355690 0.03378337        1         4 0.27777778 0.1111111
## 23 -0.2645980 0.51426576        2         4 0.33333333 0.2222222
## 24 -0.2497399 0.72683714        3         4 0.38888889 0.3333333
## 25  1.8610994 0.97802313        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  -1.5444152 0.44125694 0.51452997 0.31563573        0         0 0.0000000
## 2   0.2185088 0.79003255 0.29076808 0.64197249        1         0 0.1666667
## 3   2.0446986 0.55378834 0.09921822 0.56774552        2         0 0.3333333
## 4   0.5409371 0.09441451 0.96626200 0.08739008        3         0 0.5000000
## 5   2.4965886 0.68479850 0.83769148 0.29197600        4         0 0.6666667
## 6   2.4367386 0.63003801 0.22077066 0.62458387        0         1 0.1666667
## 7   1.7934075 0.30653893 0.51883874 0.72180879        1         1 0.3333333
## 8   1.5959914 0.06721706 0.83381614 0.52897036        2         1 0.5000000
## 9   3.9629132 0.45821187 0.61437862 0.87861374        3         1 0.6666667
## 10  2.9200483 0.40233911 0.33932967 0.26954164        4         1 0.8333333
## 11  2.4129286 0.91074559 0.67658803 0.54341282        0         2 0.3333333
## 12  2.7081650 0.22233981 0.48790603 0.88376794        1         2 0.5000000
## 13  4.1385209 0.63504617 0.91678902 0.52002587        2         2 0.6666667
## 14  2.0301092 0.05278236 0.29319035 0.40364087        3         2 0.8333333
## 15  1.6080878 0.19616180 0.10276173 0.02185539        4         2 1.0000000
## 16  2.3585984 0.04836455 0.93944343 0.19361559        0         3 0.5000000
## 17  0.8464880 0.77901166 0.12883174 0.08712989        1         3 0.6666667
## 18  6.2407054 0.97043877 0.28788277 0.66060304        2         3 0.8333333
## 19  9.4005756 0.56613773 0.52094945 0.83952114        3         3 1.0000000
## 20  9.2066143 0.98271688 0.47190351 0.95289980        4         3 1.1666667
## 21  4.5092823 0.07678839 0.18262770 0.28890384        0         4 0.6666667
## 22  6.9578266 0.64080445 0.81462305 0.39349809        1         4 0.8333333
## 23  6.1698871 0.27105724 0.49925480 0.70269560        2         4 1.0000000
## 24  3.4339752 0.86967546 0.14900656 0.02323132        3         4 1.1666667
## 25  7.6196137 0.94677355 0.48123368 0.61730450        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   0.08581367 0.47404392        0         0 0.0000000 0.0000000
## 2   1.46831875 0.49456328        1         0 0.3333333 0.3333333
## 3  -1.42505824 0.46939454        2         0 0.6666667 0.6666667
## 4   0.64418190 1.03457949        3         0 1.0000000 1.0000000
## 5   3.29386476 1.14522124        4         0 1.3333333 1.3333333
## 6  -1.48017774 0.56336294        0         1 0.1666667 0.0000000
## 7   1.57109320 1.89638831        1         1 0.5000000 0.3333333
## 8   0.98728753 0.06167618        2         1 0.8333333 0.6666667
## 9   1.47036117 0.58404282        3         1 1.1666667 1.0000000
## 10  3.83840508 0.73038603        4         1 1.5000000 1.3333333
## 11 -1.80043998 1.58727096        0         2 0.3333333 0.0000000
## 12  1.46461669 0.86453123        1         2 0.6666667 0.3333333
## 13  0.91794011 1.47496441        2         2 1.0000000 0.6666667
## 14  1.86393043 0.33228756        3         2 1.3333333 1.0000000
## 15  5.14886503 0.94960662        4         2 1.6666667 1.3333333
## 16 -0.46512294 0.07084865        0         3 0.5000000 0.0000000
## 17  2.63321045 0.82763237        1         3 0.8333333 0.3333333
## 18  1.98327426 1.68300979        2         3 1.1666667 0.6666667
## 19  2.22875054 0.95286130        3         3 1.5000000 1.0000000
## 20  2.88637823 0.88954676        4         3 1.8333333 1.3333333
## 21  0.49217883 1.89176902        0         4 0.6666667 0.0000000
## 22 -0.49149617 0.20212161        1         4 1.0000000 0.3333333
## 23  2.38886057 0.18931724        2         4 1.3333333 0.6666667
## 24  4.18267156 1.86470368        3         4 1.6666667 1.0000000
## 25  2.08174417 1.59896996        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.3852961 1.7330069        0         0 0.0000000 0.0000000
## 2   1.8663652 1.3958807        1         0 0.3333333 0.3333333
## 3   3.8664116 1.0937948        2         0 0.6666667 0.6666667
## 4   7.5949054 1.8622154        3         0 1.0000000 1.0000000
## 5  11.5397071 1.7247055        4         0 1.3333333 1.3333333
## 6  -0.2300467 0.8584055        0         1 0.1666667 0.0000000
## 7   1.3816402 0.3686430        1         1 0.5000000 0.3333333
## 8   3.5652910 1.1784975        2         1 0.8333333 0.6666667
## 9   1.7007753 0.4151196        3         1 1.1666667 1.0000000
## 10 10.1130369 1.4959418        4         1 1.5000000 1.3333333
## 11  2.0027158 0.1543511        0         2 0.3333333 0.0000000
## 12  0.7411587 0.2781347        1         2 0.6666667 0.3333333
## 13  1.2562111 0.6727218        2         2 1.0000000 0.6666667
## 14  2.0548240 0.5885006        3         2 1.3333333 1.0000000
## 15  4.9364388 0.7557369        4         2 1.6666667 1.3333333
## 16  1.0479191 0.4599556        0         3 0.5000000 0.0000000
## 17  2.3955301 1.8129975        1         3 0.8333333 0.3333333
## 18  3.2461516 0.4161563        2         3 1.1666667 0.6666667
## 19  2.4501485 0.6002525        3         3 1.5000000 1.0000000
## 20  0.9879998 0.2265500        4         3 1.8333333 1.3333333
## 21  1.1299570 0.9792097        0         4 0.6666667 0.0000000
## 22  2.8082032 1.9620152        1         4 1.0000000 0.3333333
## 23  2.8264553 0.3397899        2         4 1.3333333 0.6666667
## 24  2.9797022 0.1329242        3         4 1.6666667 1.0000000
## 25  8.5033448 1.3102759        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.8257339 1.57746298 -1.18921467        0         0 0.0000000 0.0000000
## 2   0.4589575 1.52082015  0.81810017        1         0 0.1666667 0.3333333
## 3   3.7156769 1.86765844  0.71168843        2         0 0.3333333 0.6666667
## 4   3.4630577 1.12393358  1.29639984        3         0 0.5000000 1.0000000
## 5   5.1428043 0.97615315  1.76774772        4         0 0.6666667 1.3333333
## 6   1.4149045 0.64305155  1.69303231        0         1 0.1666667 0.0000000
## 7   2.3727357 0.64273638  0.92989419        1         1 0.3333333 0.3333333
## 8   4.2553522 1.32726184  1.70428144        2         1 0.5000000 0.6666667
## 9   2.6584654 1.06944386  0.13063820        3         1 0.6666667 1.0000000
## 10  1.2176451 0.05110163  1.50387960        4         1 0.8333333 1.3333333
## 11  4.3097633 1.74238934  1.56060404        0         2 0.3333333 0.0000000
## 12  3.9662184 1.48443354  0.98716470        1         2 0.5000000 0.3333333
## 13  4.2793004 0.62639946  1.62500590        2         2 0.6666667 0.6666667
## 14 21.8352739 1.41101700  2.36024745        3         2 0.8333333 1.0000000
## 15  1.4813699 0.30850403 -0.36753753        4         2 1.0000000 1.3333333
## 16  1.9290666 1.38371217  0.42672926        0         3 0.5000000 0.0000000
## 17  3.0633164 1.26481758 -0.09374393        1         3 0.6666667 0.3333333
## 18  9.6175262 1.96782945  0.67832374        2         3 0.8333333 0.6666667
## 19 59.4526115 1.45142127  2.59018531        3         3 1.0000000 1.0000000
## 20  2.9819596 0.53087775 -0.19497531        4         3 1.1666667 1.3333333
## 21  6.7609761 0.26382390  1.20979838        0         4 0.6666667 0.0000000
## 22  5.3876514 0.63417904  0.51604860        1         4 0.8333333 0.3333333
## 23  9.3068350 1.89620190  0.68377870        2         4 1.0000000 0.6666667
## 24  2.3521704 0.09608644  0.20215305        3         4 1.1666667 1.0000000
## 25 74.2987686 1.43066903  1.77576877        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  -1.0294450 0.894662433        0         0 0.000000 0.00000000
## 2  -0.8988090 0.117473698        1         0 1.000000 0.05555556
## 3   2.4626530 0.460764319        2         0 1.732051 0.22222222
## 4   3.1439662 0.911972784        3         0 2.000000 0.50000000
## 5   1.3973109 0.799889067        4         0 1.732051 0.88888889
## 6   2.0115482 0.573283562        0         1 0.000000 0.05555556
## 7   1.5460814 0.036044521        1         1 1.000000 0.11111111
## 8   2.0163742 0.965641699        2         1 1.732051 0.27777778
## 9   2.6239566 0.705517118        3         1 2.000000 0.55555556
## 10  3.5520188 0.746990587        4         1 1.732051 0.94444444
## 11  0.4382878 0.239722305        0         2 0.000000 0.22222222
## 12  0.7043238 0.935653037        1         2 1.000000 0.27777778
## 13  2.1648288 0.004695854        2         2 1.732051 0.44444444
## 14  2.7822068 0.173253422        3         2 2.000000 0.72222222
## 15  1.4305623 0.112039780        4         2 1.732051 1.11111111
## 16  0.6755227 0.960220895        0         3 0.000000 0.50000000
## 17  0.9675504 0.116092087        1         3 1.000000 0.55555556
## 18  2.5049918 0.677376441        2         3 1.732051 0.72222222
## 19  2.7528614 0.437995782        3         3 2.000000 1.00000000
## 20  1.9386830 0.529982317        4         3 1.732051 1.38888889
## 21  1.9262956 0.912933954        0         4 0.000000 0.88888889
## 22  2.1263298 0.274156325        1         4 1.000000 0.94444444
## 23  1.1790132 0.653149741        2         4 1.732051 1.11111111
## 24  1.2092295 0.215103691        3         4 2.000000 1.38888889
## 25  3.4611725 0.821281794        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.8342872 0.2359394        0         0  0.000000e+00    0.500000
## 2    0.9654366 0.9341484        1         0  1.000000e+00    1.359141
## 3    5.3507727 0.9176639        2         0  1.732051e+00    3.694528
## 4    7.2301330 0.5113917        3         0  2.000000e+00   10.042768
## 5   26.9211773 0.9719575        4         0  1.732051e+00   27.299075
## 6    1.5290924 0.2995863        0         1  1.000000e+00    1.359141
## 7    5.0126524 0.8165433        1         1  1.732051e+00    3.694528
## 8   10.6424827 0.9279315        2         1  2.000000e+00   10.042768
## 9    6.4681997 0.1761923        3         1  1.732051e+00   27.299075
## 10  58.8903139 0.7782671        4         1  1.000000e+00   74.206580
## 11   2.5339452 0.6006290        0         2  1.732051e+00    3.694528
## 12   9.6733230 0.7760704        1         2  2.000000e+00   10.042768
## 13  13.0290468 0.3896764        2         2  1.732051e+00   27.299075
## 14  13.5909109 0.1719458        3         2  1.000000e+00   74.206580
## 15  95.6483553 0.4724471        4         2  2.449294e-16  201.714397
## 16   3.3798979 0.1852113        0         3  2.000000e+00   10.042768
## 17  21.2495955 0.6740584        1         3  1.732051e+00   27.299075
## 18  16.8344967 0.1971718        2         3  1.000000e+00   74.206580
## 19 143.0764086 0.7053660        3         3  2.449294e-16  201.714397
## 20 133.8805379 0.2448009        4         3 -1.000000e+00  548.316579
## 21  27.5719222 0.8913244        0         4  1.732051e+00   27.299075
## 22  46.7534333 0.6009959        1         4  1.000000e+00   74.206580
## 23  95.3403828 0.4750103        2         4  2.449294e-16  201.714397
## 24 507.9315844 0.9252415        3         4 -1.000000e+00  548.316579
## 25 600.1365143 0.4045764        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     1.030293 0.04515895 0.94887802 0.52200197        0         0 0.000000
## 2     1.975723 0.35687188 0.03629351 0.64830816        1         0 1.000000
## 3     6.504675 0.14093758 0.47435702 0.73250594        2         0 1.732051
## 4     8.571680 0.17518909 0.62507657 0.23218807        3         0 2.000000
## 5     3.507532 0.73774939 0.40801453 0.02575692        4         0 1.732051
## 6     2.286849 0.26781777 0.57000932 0.84458122        0         1 0.000000
## 7     5.613916 0.07340088 0.82084424 0.17974116        1         1 1.000000
## 8     6.302133 0.15770700 0.28651669 0.50517212        2         1 1.732051
## 9    17.742632 0.02708156 0.45042543 0.52293177        3         1 2.000000
## 10   24.894857 0.70942544 0.41152460 0.29280238        4         1 1.732051
## 11    3.073531 0.56121005 0.46922094 0.60470455        0         2 0.000000
## 12    7.622642 0.18133517 0.76430015 0.27781306        1         2 1.000000
## 13   18.368897 0.55360213 0.39507888 0.58113095        2         2 1.732051
## 14   29.661743 0.59422202 0.45469291 0.33953070        3         2 2.000000
## 15   99.796784 0.50716273 0.15765440 0.48219443        4         2 1.732051
## 16   11.756042 0.33256751 0.53876553 0.92557034        0         3 0.000000
## 17    7.411376 0.50316586 0.75627297 0.10716534        1         3 1.000000
## 18   15.096469 0.61807763 0.67881087 0.15016511        2         3 1.732051
## 19   22.889603 0.64807565 0.33555548 0.09871337        3         3 2.000000
## 20   99.495157 0.94929290 0.96505030 0.17907591        4         3 1.732051
## 21   13.189848 0.07924795 0.67850229 0.41184878        0         4 0.000000
## 22   26.482562 0.54004692 0.14547569 0.32684053        1         4 1.000000
## 23   36.788073 0.58696284 0.13791818 0.17414036        2         4 1.732051
## 24  222.752106 0.70319451 0.18502199 0.40566756        3         4 2.000000
## 25 1069.616837 0.88637502 0.99089727 0.71790115        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.5895118 1.31228432        0         0 0.000000 0.00000000
## 2   0.7602584 0.38064342        1         0 1.000000 0.05555556
## 3   5.5392565 1.95194268        2         0 1.732051 0.22222222
## 4   4.2877055 1.66550771        3         0 2.000000 0.50000000
## 5   3.3816593 0.22327644        4         0 1.732051 0.88888889
## 6   0.7941527 0.90109375        0         1 0.000000 0.05555556
## 7   3.1322111 1.13077431        1         1 1.000000 0.11111111
## 8   2.8853447 0.20454794        2         1 1.732051 0.27777778
## 9   4.4169307 0.35216270        3         1 2.000000 0.55555556
## 10  5.4789664 1.13588009        4         1 1.732051 0.94444444
## 11  1.3933327 0.53416245        0         2 0.000000 0.22222222
## 12  2.9139301 0.04770908        1         2 1.000000 0.27777778
## 13  4.3585323 0.97512264        2         2 1.732051 0.44444444
## 14  5.1658267 1.93743105        3         2 2.000000 0.72222222
## 15  5.5891124 0.40481342        4         2 1.732051 1.11111111
## 16  1.8157742 1.39603217        0         3 0.000000 0.50000000
## 17  2.5588144 0.37220277        1         3 1.000000 0.55555556
## 18  1.9998452 0.85536890        2         3 1.732051 0.72222222
## 19  4.0230042 0.78100286        3         3 2.000000 1.00000000
## 20  5.9502152 1.04439898        4         3 1.732051 1.38888889
## 21  2.0786984 0.85291517        0         4 0.000000 0.88888889
## 22  5.9393330 1.69132887        1         4 1.000000 0.94444444
## 23  0.3399925 0.08126901        2         4 1.732051 1.11111111
## 24  4.8765690 0.36516175        3         4 2.000000 1.38888889
## 25 13.3568424 1.43555873        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.333040e+00 0.11867569  0.60670710        0         0 0.000000 0.00000000
## 2  1.107574e+00 0.49725603 -0.22282936        1         0 1.000000 0.05555556
## 3  2.326946e+02 1.53074886  1.47096435        2         0 1.732051 0.22222222
## 4  2.794926e+00 0.46207003 -1.03018363        3         0 2.000000 0.50000000
## 5  3.132868e+00 0.15952205 -0.33684856        4         0 1.732051 0.88888889
## 6  7.831944e-01 0.80613347  0.20832988        0         1 0.000000 0.05555556
## 7  5.172890e+00 0.37168742  0.42039794        1         1 1.000000 0.11111111
## 8  3.401850e+00 1.32723490 -0.22189271        2         1 1.732051 0.27777778
## 9  2.268025e+01 0.50936408  0.82018450        3         1 2.000000 0.55555556
## 10 2.245556e+02 0.37584703  2.52849687        4         1 1.732051 0.94444444
## 11 2.513593e+01 1.31972695  0.85317519        0         2 0.000000 0.22222222
## 12 3.820789e+03 0.05555008  2.05815964        1         2 1.000000 0.27777778
## 13 1.945683e+01 0.35610533  0.77253835        2         2 1.732051 0.44444444
## 14 3.015438e+01 0.89701954  1.31702053        3         2 2.000000 0.72222222
## 15 4.180323e+00 0.87161649  1.25907999        4         2 1.732051 1.11111111
## 16 5.641948e-01 0.88517802 -0.06559450        0         3 0.000000 0.50000000
## 17 1.005314e+04 1.33059037  2.44689779        1         3 1.000000 0.55555556
## 18 2.114435e+00 0.75547340 -1.28878590        2         3 1.732051 0.72222222
## 19 1.944477e+00 0.36956913  2.65192995        3         3 2.000000 1.00000000
## 20 4.856523e+00 0.65469969 -0.08054587        4         3 1.732051 1.38888889
## 21 1.059230e+01 0.15837523  0.64588817        0         4 0.000000 0.88888889
## 22 4.169661e+01 0.73409094  1.51678346        1         4 1.000000 0.94444444
## 23 1.339652e+00 0.56379414  2.24566424        2         4 1.732051 1.11111111
## 24 2.208118e+00 0.72348517  2.05370173        3         4 2.000000 1.38888889
## 25 3.089552e+00 1.88763604  1.26068660        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