Description Usage Arguments Details Value Author(s) References Examples
Calculates a set of values for a particular statistic or sets of observations, typically for observed values and multiple sets of randomized observations.
| 1 | 
| rand | A list for which the elements are either sets of randomized variables or randomized index values.  | 
| marks | Should either be left empty, be a vector or a matrix. When  | 
| FUN | Any function used to calculate the statistic of interest (e.g.  | 
| ... | Optional arguments to  | 
fgstat is designed to calculate statistics for spatial explicit data for which randomized data sets are generated with fgperm. 
fgstat returns a vector of statistics. If rand is the output of fgperm and add.obs=TRUE, the first value is the statistic for the observed data and the rest for randomizations.
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 32 33 34 35 | #### Example for fgrand
## 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.