- Notifications
You must be signed in to change notification settings - Fork1
RJauslin/WaveSampling
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Spatial data are generally auto-correlated, meaning that if two unitsselected are close to each other, then it is likely that they share thesame properties. For this reason, when sampling in the population it isoften needed that the sample is well spread over space. A new method todraw a sample from a population with spatial coordinates is proposed.This method is calledwave (weakly associated vectors) sampling. Ituses the less correlated vector to a spatial weights matrix to updatethe inclusion probabilities vector into a sample. For more details seeRaphaël Jauslin and Yves Tillé (2020)https://doi.org/10.1007/s13253-020-00407-1.
install.packages("WaveSampling")You can install the latest version of the packageWaveSampling withthe following command:
# install.packages("devtools")devtools::install_github("Rjauslin/WaveSampling")
This basic example shows you how to solve a common problem. Spatialcoordinates from the functionrunif() are firstly generated.
library(WaveSampling)#> Le chargement a nécessité le package : MatrixN<-144n<-48X<- cbind(runif(N),runif(N))head(X,10)#> [,1] [,2]#> [1,] 0.35000373 0.2557976#> [2,] 0.87553309 0.6370745#> [3,] 0.09019367 0.9000345#> [4,] 0.97906235 0.3576902#> [5,] 0.32768335 0.1444912#> [6,] 0.41488141 0.5468550#> [7,] 0.67789730 0.4799551#> [8,] 0.21604234 0.8712608#> [9,] 0.38741250 0.6283276#> [10,] 0.78754375 0.6948966
Inclusion probabilitiespik is set up all equal with the functionrep().
pik<- rep(n/N,times=N)
It only remains to use the functionwave(),
s<- wave(X,pik)
We can also generate a plot to observe the result.
library(ggplot2)ggplot()+ geom_point(data=data.frame(x=X[,1],y=X[,2]), aes(x=x,y=y),shape=1,alpha=0.2)+ geom_point(data=data.frame(x=X[s==1,1],y=X[s==1,2]), aes(x,y),shape=16,colour="black")+ theme_void()
About
Weakly Associated Vectors sampling
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
