Resamples sites (with replacement) from an unmarkedFit object and re-fits the model, to generate new non-parametric bootstrap samples of estimates. These samples can then be used by vcov in order to get bootstrap-based estimates of standard errors.

# S4 method for class 'unmarkedFit'
nonparboot(object, B = 1, keepOldSamples = TRUE, ...)

Arguments

object

A unmarkedFit object

B

The number of bootstrap samples to get

keepOldSamples

Should previously generated bootstrap samples be retained?

...

Other arguments, currently ignored

Details

Calling nonparboot on an unmarkedFit returns the original unmarkedFit, with the bootstrap samples added on. Then subsequent calls to vcov with the argument method="nonparboot" will use these bootstrap samples. Additionally, standard errors of derived estimates from either linearComb or backTransform can be instructed to use bootstrap samples by providing the argument method = "nonparboot".

For all fitting functions, only sites are re-sampled. In previous versions of unmarked both sites and occasions of occu and occuRN fits were re-sampled, but now only sites are re-sampled for these fit types to match the other fit types.

Note: by default, if the model fit to a new resampled dataset results in an error or a convergence failure, nonparboot will continually re-sample and re-fit until this is no longer the case. This could result in the function hanging.

Examples

data(ovendata)
ovenFrame <- unmarkedFrameMPois(ovendata.list$data,
siteCovs=as.data.frame(scale(ovendata.list$covariates[,-1])), type = "removal")
(fm <- multinomPois(~ 1 ~ ufc + trba, ovenFrame))
#> 
#> Call:
#> multinomPois(formula = ~1 ~ ufc + trba, data = ovenFrame)
#> 
#> Abundance (log-scale):
#>             Estimate    SE      z P(>|z|)
#> (Intercept)    0.102 0.119  0.864   0.388
#> ufc            0.100 0.126  0.794   0.427
#> trba          -0.171 0.135 -1.262   0.207
#> 
#> Detection (logit-scale):
#>  Estimate    SE    z P(>|z|)
#>     0.288 0.233 1.24   0.217
#> 
#> AIC: 326.1387 
#> Number of sites: 70
#> 
fm <- nonparboot(fm, B = 20) # should use larger B in real life.
#> 
  |                                                  | 0 % ~calculating  
  |+++                                               | 5 % ~00s          
  |+++++                                             | 10% ~00s          
  |++++++++                                          | 15% ~00s          
  |++++++++++                                        | 20% ~00s          
  |+++++++++++++                                     | 25% ~00s          
  |+++++++++++++++                                   | 30% ~00s          
  |++++++++++++++++++                                | 35% ~00s          
  |++++++++++++++++++++                              | 40% ~00s          
  |+++++++++++++++++++++++                           | 45% ~00s          
  |+++++++++++++++++++++++++                         | 50% ~00s          
  |++++++++++++++++++++++++++++                      | 55% ~00s          
  |++++++++++++++++++++++++++++++                    | 60% ~00s          
  |+++++++++++++++++++++++++++++++++                 | 65% ~00s          
  |+++++++++++++++++++++++++++++++++++               | 70% ~00s          
  |++++++++++++++++++++++++++++++++++++++            | 75% ~00s          
  |++++++++++++++++++++++++++++++++++++++++          | 80% ~00s          
  |+++++++++++++++++++++++++++++++++++++++++++       | 85% ~00s          
  |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~00s          
  |++++++++++++++++++++++++++++++++++++++++++++++++  | 95% ~00s          
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s  
vcov(fm, method = "hessian")
#>               lambda(Int)   lambda(ufc)  lambda(trba)        p(Int)
#> lambda(Int)   0.014052472 -1.228179e-03  2.364962e-03 -4.323007e-03
#> lambda(ufc)  -0.001228179  1.594197e-02  8.057614e-03 -3.200697e-11
#> lambda(trba)  0.002364962  8.057614e-03  1.831812e-02 -3.459628e-11
#> p(Int)       -0.004323007 -3.200697e-11 -3.459628e-11  5.415986e-02
vcov(fm, method = "nonparboot")
#>               lambda(Int)  lambda(ufc) lambda(trba)        p(Int)
#> lambda(Int)   0.028845631 -0.001084086 0.0049178635 -0.0157796398
#> lambda(ufc)  -0.001084086  0.013770757 0.0110038361 -0.0046697094
#> lambda(trba)  0.004917864  0.011003836 0.0186061311  0.0009194527
#> p(Int)       -0.015779640 -0.004669709 0.0009194527  0.0948140633
avg.abundance <- backTransform(linearComb(fm, type = "state", coefficients = c(1, 0, 0)))

## Bootstrap sample information propagates through to derived quantities.
vcov(avg.abundance, method = "hessian")
#>            [,1]
#> [1,] 0.01724521
vcov(avg.abundance, method = "nonparboot")
#>            [,1]
#> [1,] 0.03539939
SE(avg.abundance, method = "nonparboot")
#> [1] 0.1881473