Skip to contents

A spatial moving block bootstrap resampling scheme is constructed, that can then be used in resampling-based inference (e.g. using anova.manyglm). Blocks are constructed as discs or tiles of observations of a user-specified size and shape.

Usage

BlockBootID(
  x,
  y,
  block_L,
  nBoot = 499,
  Grid_space,
  lookuptables.folderpath = NA,
  shape = "disc",
  ...
)

Arguments

x

the easting of spatial coordinate for the site.

y

the northing of the spatial coordinate for the site.

block_L

the size of the spatial blocks to be resampled.

nBoot

the number of resamples required (defaults to 499).

Grid_space

the resolution of the lattice used to sample centres of spatial blocks. Defaults to a third of the resolution of block_Ls.

lookuptables.folderpath

(optional) path to a directory where lookup tables can be found that assign observations to spatial blocks. Such tables would considerably speed up the process.

shape

shape of the spatial blocks to resample. Default is disc, but square tiles can also be specified.

...

additional arguments passed to resample_blocks_by_area.

Value

A matrix of IDs for each moving block bootstrap resample, with different resamples in rows and observations in columns.

Details

A spatial moving block bootstrap resampling scheme is constructed, that can then be used in resampling-based inference. A matrix of IDs is returned, with different resamples in different rows of the matrix, which can be used as input to functions designed for resampling-based inference (such as anova.manyglm).

Blocks are constructed as discs or tiles of observations, whose size is controlled by blockl_L, these blocks are kept together in resampling. The centre of each block is chosen at random along a lattice specified via Grid_space.

The most computationally intensive part of this process is working out which observations belong in which blocks. If repeated analyses are to be undertaken in the same spatial domain using the same sites, it is best to run this process only once and save the result as a set of lookup tables. Then the path to the directory containing these tables is specified via lookuptables.folderpath and the whole thing runs heaps faster.

See also

Author

Eve Slavich <eve.slavich@unsw.edu.au>

Examples

# \donttest{
data(Myrtaceae)
# fit a lm:
library(mvabund)
Myrtaceae$logrich=log(Myrtaceae$richness+1)
mft_richAdd = manylm(logrich~soil+poly(TMP_MAX,degree=2)+
                     poly(TMP_MIN,degree=2)+poly(RAIN_ANN,degree=2),
                                        data=Myrtaceae)
                                        
# construct a boot ID matrix: 
BootID = BlockBootID(x = Myrtaceae$X, y = Myrtaceae$Y, block_L = 20,
            nBoot = 199, Grid_space = 5)
anova(mft_richAdd,resamp="case",bootID=BootID)
#> Using <int> bootID matrix from input. 
#> Analysis of Variance Table
#> 
#> Model: manylm(formula = logrich ~ soil + poly(TMP_MAX, degree = 2) + 
#> Model:     poly(TMP_MIN, degree = 2) + poly(RAIN_ANN, degree = 2), data = Myrtaceae)
#> 
#> Overall test for all response variables
#> Test statistics:
#>                            Res.Df Df.diff val(F) Pr(>F)   
#> (Intercept)                   999                         
#> soil                          991       8 11.971  0.640   
#> poly(TMP_MAX, degree = 2)     989       2 18.244  0.005 **
#> poly(TMP_MIN, degree = 2)     987       2 17.533  0.550   
#> poly(RAIN_ANN, degree = 2)    985       2  8.208  0.480   
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> Arguments: P-value calculated using 199 iterations via case resampling.
#> 
# }