Description Usage Arguments Details Value Author(s) References Examples
The fgperm
function produces sets of permuted observations or indices using the Floating Grid Permutation Technique, which is a method for spatially restricted permutations. fgploc
offers additional functionality to manipulate observations within grid cells, for instance observations could be scaled with grid cells.
1 2 3 4 |
xy |
Two-column matrix with the geographical locations of observations. |
z |
Vector with the observations. If left empty |
scale |
Value indicating the spatial scale of the permutations. |
group |
Optional group membership of observations. |
iter |
Number of iterations for every grid cell size. Default is 999. Note that in order to produce a probability an observation is assigned to any of the geographical locations is a negative function of the distance between its original and assigned location many iterations are needed. |
ratio |
The ratio between the sides of the grid cells. Default is 1. |
FUN |
Function to perform randomizations. Note that the function must be able to randomize one value, which is for instance a issue if using |
FUN.mani |
Function to perform manipulations of the observations within grid cells. This functionality should be used together with |
... |
Optional arguments to |
marks |
Should either be left empty, be a vector or a matrix. When |
add.obs |
If |
as.matrix |
If |
pass.rand |
If |
Before using those functions please read the reference or vignette. Alternatively use the more user-friendly function fgeasy
. If there are missing values for the observations, leave z
empty and enter the observations as marks
in the fgstat
function.
fgperm
returns a list
or a matrix
, depending on the setting of argument as.matrix
.
Reinder Radersma
Reinder Radersma & Ben C. Sheldon, 2015. A new permutation technique to explore and control for spatial autocorrelation. Submitted
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ## 200 random geographical locations
xy <- array(runif(400,0,2), dim=c(200,2))
## run fgperm to produce 99 randomizations for scale 1
test <- fgperm(xy, scale=1, iter=99, add.obs=TRUE)
## run fgperm to produce 99 bootstraps for scale 1
test <- fgperm(xy, scale=1, iter=99, FUN=function(x){
x[sample.int(length(x),replace=TRUE)]}, add.obs=TRUE)
## 200 times 200 random distances (e.g. genetic relatedness between mated pairs)
trait <- array(rnorm(200*200,0.6,0.1), dim=c(200,200))
## make the observed pairs more alike
diag(trait) <- diag(trait)+0.02
## make two rows and two colums empty
trait[,3] <- NA
trait[,50] <- NA
trait[6,] <- NA
trait[12,] <- NA
## calculate means; will give NAs because there are missing values
calc <- fgstat(test,trait,mean)
## calculate means
calc <- fgstat(test,trait,mean, na.rm=TRUE)
## plot means
hist(calc)
abline(v=calc[1], col="red", lwd=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.