bootstrap: Estimates Uncertainties with Bootstrapping

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Diversity measure provided in the vegetarian library call bootstrap to estimate standard error for the parameter outputs. Bootstrap generates simulated populations from a multinormal distribution centered around the community matrix provided and applies the function of interest to the simulated data. Requires stats package.

Usage

1
bootstrap(abundances, s.sizes = NULL, num.iter = 100, func, func.arg = "blank", sim.pop = FALSE, sim.par = FALSE)

Arguments

abundances

Community data as a matrix where columns are individual species and rows are sites. Matrix elements are abundance data (e.g. counts, percent cover estimates).

s.sizes

A vector of the total abundances at each site. If no vector is provided, then the scores in the abundance matrix will be treated as counts, and sample size of each site will be computed as the row sum.

num.iter

An integer giving the number of bootstrapping iterations.

func

The function on which bootstrapping will be performed. The function output must be a scalar.

func.arg

A list containing any additional arguments that must be fed to the function specified by func.

sim.pop

A logical specifying whether or not to output the simulated populations for each iteration.

sim.par

A logical specifying whether or not to output the individual parameters calculated on each simulated population.

Details

The procedure is outlined in Chao et al. (2008). For each site (row) of the original data set, the total sample size and the relative proportions of each species are used to construct a multinomial distribution. Scores are drawn from this multinomial distribution to generate a simulated population at that site. This is done for each row until an entire simulated community matrix is generated. The supplied function (func) is then applied to this simulated matrix to calculate the focal parameter for that iteration. This process of sampling from the multinormal distributions and applying the function is repeated for as many times as is specified by num.iter. The standard deviation of the bootstrap parameter values serves as the standard error for the parameter estimate based on the real data.

While this function is called internally by other functions in the vegetarian library, only the standard error is reported by those functions. The user may wish to call bootstrap directly to access the simulated populations and measure uncertainty in other ways.

Value

StdErr

Bootstrap Standard Error for parameter estimate

Simulated.Populations

(optional) Array containing simulated populations

Simulated.Parameters

(optional) Vector containing parameter for each simulated population

Author(s)

Noah Charney, Sydne Record

References

Chao, A, L. Jost, S. C. Chiang, Y.-H Jiang, R. L. Chazdon. 2008. A two-stage probabilistic approach to multiple-community similarity indices. Biometrics 64: 1178-1186.

See Also

d

Examples

1
2
3
4
5
6
7
data(simesants)
bootstrap(simesants[,-1], func=d)
boot_output<-bootstrap(simesants[,-1], func=d, num.iter=10, sim.pop=TRUE, sim.par=TRUE)
boot_output$Simulated.Parameters
boot_output$Simulated.Populations
simesants_freq<-normalize.rows(simesants[,-1])#not a necessary step, but just to show what you would do if your data were in the form of frequencies, not counts
bootstrap(simesants_freq, func=d, num.iter=1000, s.sizes=c(198,186,102,108,187))

Example output

$StdErr
[1] 0.1216232

 [1] 3.198917 3.405069 3.234103 2.977725 2.858734 3.172396 2.944505 3.031379
 [9] 3.010386 3.264188
, , 1

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  191    0    5    0    0    0    0    0     0     2     0     0     0
[2,]    3  133    0   14    0    0    0    0    0     6     8    15     0     3
[3,]    0   25    4    6    0    2   13    8   11     0     0     0     0    26
[4,]    0   77    0    1    0    0    0    0    0     0     7    21     0     1
[5,]    0   99    0   14    0    0    0    0    0     4    27     0     7     9
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     2     1     0     1
[3,]     0     2     1     0     0     0     4     0
[4,]     0     0     0     0     0     0     0     1
[5,]     7     0     0     7     0     0     4     9

, , 2

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  190    0    6    0    0    0    0    0     0     2     0     0     0
[2,]    1  130    0   20    0    0    0    0    0     4    11    12     0     1
[3,]    0   20   10    0    2    1   10    9   12     0     0     0     0    29
[4,]    0   68    0    1    0    0    0    0    0     0     9    24     0     1
[5,]    0   92    0   12    0    0    0    0    0     4    29     0     9    20
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     4     1     0     2
[3,]     0     3     2     0     2     0     2     0
[4,]     0     0     0     0     0     0     4     1
[5,]     8     0     0     8     0     0     1     4

, , 3

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  192    0    4    0    0    0    0    0     0     2     0     0     0
[2,]    4  119    0   17    0    0    0    0    0     5    18    14     0     2
[3,]    0   21   12    1    1    3    6   11   10     0     0     0     0    32
[4,]    0   78    0    0    0    0    0    0    0     0     9    17     0     1
[5,]    0  102    0   20    0    0    0    0    0     3    23     0     3     8
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     4     2     0     1
[3,]     0     0     1     0     1     0     3     0
[4,]     0     0     0     0     0     0     0     3
[5,]     7     0     0    14     0     0     4     3

, , 4

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  197    0    0    0    0    0    0    0     0     1     0     0     0
[2,]    1  137    0   14    0    0    0    0    0     8    10     6     0     2
[3,]    0   27   11    2    0    1    8    5   12     0     0     0     0    28
[4,]    0   80    0    0    0    0    0    0    0     0     5    21     0     0
[5,]    0   96    0   12    0    0    0    0    0     7    20     0     7    16
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     3     3     0     2
[3,]     0     0     1     0     0     0     7     0
[4,]     0     0     0     0     0     0     0     2
[5,]    11     0     0    12     0     0     2     4

, , 5

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  196    0    2    0    0    0    0    0     0     0     0     0     0
[2,]    1  141    0   17    0    0    0    0    0     5     9     5     0     3
[3,]    0   15   11    1    2    0   15    8   13     0     0     0     0    32
[4,]    0   86    0    1    0    0    0    0    0     0     5    14     0     0
[5,]    0  106    0   18    0    0    0    0    0     4    21     0     4     8
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     2     1     0     2
[3,]     0     2     0     0     1     0     2     0
[4,]     0     0     0     0     0     0     0     2
[5,]    11     0     0     6     0     0     5     4

, , 6

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  193    0    3    0    0    0    0    0     0     2     0     0     0
[2,]    2  132    0   19    0    0    0    0    0     4     7     9     0     3
[3,]    0   18    6    5    3    2   10    6   14     0     0     0     0    36
[4,]    0   65    0    3    0    0    0    0    0     0     5    30     0     0
[5,]    0  113    0   18    0    0    0    0    0     5    16     0     3     7
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     3     2     0     5
[3,]     0     1     0     0     0     0     1     0
[4,]     0     0     0     0     0     0     3     2
[5,]     7     0     0     8     0     0     5     5

, , 7

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  193    0    5    0    0    0    0    0     0     0     0     0     0
[2,]    4  135    0   17    0    0    0    0    0     7     5     7     0     6
[3,]    0   24    8    1    2    0    4    9   14     0     0     0     0    35
[4,]    0   70    0    0    0    0    0    0    0     0     6    29     0     0
[5,]    0  116    0   11    0    0    0    0    0     5    20     0     9     4
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     3     0     0     2
[3,]     0     1     1     0     1     0     2     0
[4,]     0     0     0     0     0     0     2     1
[5,]    13     0     0     4     0     0     2     3

, , 8

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  193    0    2    0    0    0    0    0     0     3     0     0     0
[2,]    4  136    0   13    0    0    0    0    0     7     7     9     0     2
[3,]    0   20    8    1    1    1   13    6    6     0     0     0     0    39
[4,]    0   79    0    1    0    0    0    0    0     0     3    23     0     0
[5,]    0   97    0   15    0    0    0    0    0    11    28     0     3    10
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     6     0     0     2
[3,]     0     1     2     0     1     0     3     0
[4,]     0     0     0     0     0     0     1     1
[5,]    10     0     0     5     0     0     3     5

, , 9

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  194    0    4    0    0    0    0    0     0     0     0     0     0
[2,]    2  131    0   17    0    0    0    0    0     8     6     8     0     2
[3,]    0   29    4    2    1    3    8    5   13     0     0     0     0    32
[4,]    0   76    0    0    0    0    0    0    0     0     8    20     0     3
[5,]    0  104    0   27    0    0    0    0    0     4    18     0    10    10
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     9     1     0     2
[3,]     0     0     0     0     0     0     5     0
[4,]     0     0     0     0     0     0     1     0
[5,]     6     0     0     4     0     0     2     2

, , 10

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,]    0  189    0    6    0    0    0    0    0     0     3     0     0     0
[2,]    3  132    0   10    0    0    0    0    0     9    10    15     0     3
[3,]    0   17   18    3    3    2   13    8   13     0     0     0     0    18
[4,]    0   75    0    1    0    0    0    0    0     0    13    19     0     0
[5,]    0  106    0   20    0    0    0    0    0     6    23     0     3     8
     [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
[1,]     0     0     0     0     0     0     0     0
[2,]     0     0     0     0     2     0     0     2
[3,]     0     1     2     0     1     0     3     0
[4,]     0     0     0     0     0     0     0     0
[5,]     8     0     0     8     0     0     2     3

$StdErr
[1] 0.1202579

vegetarian documentation built on May 1, 2019, 8:01 p.m.