Bootstrap simulation of uncertainty for censored data
bootdistcens.Rd
Uses nonparametric bootstrap resampling in order to simulate uncertainty in the parameters of the distribution fitted to censored data.
Arguments
- f
An object of class
"fitdistcens"
, output of thefitdistcens
function.- niter
The number of samples drawn by bootstrap.
- silent
A logical to remove or show warnings and errors when bootstraping.
- parallel
The type of parallel operation to be used,
"snow"
or"multicore"
(the second one not being available on Windows), or"no"
if no parallel operation.- ncpus
Number of processes to be used in parallel operation : typically one would fix it to the number of available CPUs.
- x
An object of class
"bootdistcens"
.- object
An object of class
"bootdistcens"
.- ...
Further arguments to be passed to generic methods.
Details
Samples are drawn by
nonparametric bootstrap (resampling with replacement from the data set). On each bootstrap sample the function
mledist
is used to estimate bootstrapped values of parameters. When mledist
fails
to converge, NA
values are returned. Medians and 2.5 and 97.5 percentiles are computed by removing
NA
values. The medians and the 95 percent confidence intervals of parameters (2.5 and 97.5 percentiles)
are printed in the summary.
If inferior to the whole number of iterations, the number of iterations for which mledist
converges
is also printed in the summary.
The plot of an object of class "bootdistcens"
consists in a scatterplot or a matrix of scatterplots
of the bootstrapped values of parameters.
It uses the function stripchart
when the fitted distribution
is characterized by only one parameter, and the function plot
in other cases.
In these last cases, it provides
a representation of the joint uncertainty distribution of the fitted parameters.
It is possible to accelerate the bootstrap using parallelization. We recommend you to
use parallel = "multicore"
, or parallel = "snow"
if you work on Windows,
and to fix ncpus
to the number of available processors.
Value
bootdistcens
returns an object of class "bootdistcens"
, a list with 6 components,
- estim
a data frame containing the bootstrapped values of parameters.
- converg
a vector containing the codes for convergence of the iterative method used to estimate parameters on each bootstraped data set.
- method
A character string coding for the type of resampling : in this case
"nonparam"
as it is the only available method for censored data.- nbboot
The number of samples drawn by bootstrap.
- CI
bootstrap medians and 95 percent confidence percentile intervals of parameters.
- fitpart
The object of class
"fitdistcens"
on which the bootstrap procedure was applied.
Generic functions:
print
The print of a
"bootdistcens"
object shows the bootstrap parameter estimates. If inferior to the whole number of bootstrap iterations, the number of iterations for which the estimation converges is also printed.summary
The summary provides the median and 2.5 and 97.5 percentiles of each parameter. If inferior to the whole number of bootstrap iterations, the number of iterations for which the estimation converges is also printed in the summary.
plot
The plot shows the bootstrap estimates with the
stripchart
function for univariate parameters andplot
function for multivariate parameters.
See also
See fitdistrplus
for an overview of the package.
fitdistcens
, mledist
, quantile.bootdistcens
for another generic function to calculate
quantiles from the fitted distribution and its bootstrap results
and CIcdfplot
for adding confidence intervals on quantiles
to a CDF plot of the fitted distribution.
References
Cullen AC and Frey HC (1999), Probabilistic techniques in exposure assessment. Plenum Press, USA, pp. 181-241.
Delignette-Muller ML and Dutang C (2015), fitdistrplus: An R Package for Fitting Distributions. Journal of Statistical Software, 64(4), 1-34.
Examples
# We choose a low number of bootstrap replicates in order to satisfy CRAN running times
# constraint.
# For practical applications, we recommend to use at least niter=501 or niter=1001.
# (1) Fit of a normal distribution to fluazinam data in log10
# followed by nonparametric bootstrap and calculation of quantiles
# with 95 percent confidence intervals
#
data(fluazinam)
(d1 <-log10(fluazinam))
#> left right
#> 1 0.5797836 0.5797836
#> 2 1.5263393 1.5263393
#> 3 1.9395193 1.9395193
#> 4 3.2304489 NA
#> 5 2.8061800 2.8061800
#> 6 3.0625820 NA
#> 7 2.0530784 2.0530784
#> 8 2.1105897 2.1105897
#> 9 2.7678976 2.7678976
#> 10 3.2685780 NA
#> 11 0.2041200 0.2041200
#> 12 0.6812412 0.6812412
#> 13 1.9138139 1.9138139
#> 14 2.1903317 2.1903317
f1 <- fitdistcens(d1, "norm")
b1 <- bootdistcens(f1, niter = 51)
b1
#> Parameter values obtained with nonparametric bootstrap
#> mean sd
#> 1 2.441901 0.9705724
#> 2 1.866657 0.7906458
#> 3 1.897431 1.0534132
#> 4 2.063569 0.9523238
#> 5 2.272208 1.0193189
#> 6 2.134883 1.0706459
#> 7 2.293075 0.7633641
#> 8 1.687031 1.0445410
#> 9 2.901725 0.9773932
#> 10 2.568185 0.9615058
#> 11 2.556937 1.4094536
#> 12 2.442132 1.1473028
#> 13 2.060994 0.7346472
#> 14 1.807583 0.8492675
#> 15 1.820414 1.0638542
#> 16 3.380939 2.0937783
#> 17 2.165510 1.2343594
#> 18 1.972451 1.0049209
#> 19 2.173940 1.4045313
#> 20 1.985905 0.8631408
#> 21 1.827166 1.1840855
#> 22 2.054927 0.8202003
#> 23 2.387992 1.0413579
#> 24 2.351952 1.1787670
#> 25 1.772743 0.9730228
#> 26 1.868849 1.1578361
#> 27 2.695495 1.0277046
#> 28 2.190390 1.4672343
#> 29 1.870319 0.8614794
#> 30 1.899597 1.2814650
#> 31 2.401264 0.9076348
#> 32 2.250744 0.4908566
#> 33 2.040370 1.4495318
#> 34 2.469634 1.2541771
#> 35 1.622876 1.2933592
#> 36 1.996940 1.2438283
#> 37 1.868720 1.0912928
#> 38 2.290202 1.0497782
#> 39 1.971847 1.0369763
#> 40 2.233192 1.0927238
#> 41 1.941745 0.5782643
#> 42 2.198115 0.8572304
#> 43 2.314084 0.9944525
#> 44 2.437327 0.6067349
#> 45 2.084489 1.1195149
#> 46 1.938514 1.0258803
#> 47 1.607525 1.1698038
#> 48 2.411074 1.3173118
#> 49 2.355364 0.8947966
#> 50 2.047616 0.9936791
#> 51 1.725412 0.8320784
summary(b1)
#> Nonparametric bootstrap medians and 95% percentile CI
#> Median 2.5% 97.5%
#> mean 2.084489 1.638914 2.850168
#> sd 1.036976 0.585382 1.462809
plot(b1)
quantile(b1)
#> (original) estimated quantiles for each specified probability (censored data)
#> p=0.1 p=0.2 p=0.3 p=0.4 p=0.5 p=0.6 p=0.7
#> estimate 0.6655064 1.179033 1.549321 1.86572 2.161449 2.457179 2.773577
#> p=0.8 p=0.9
#> estimate 3.143865 3.657392
#> Median of bootstrap estimates
#> p=0.1 p=0.2 p=0.3 p=0.4 p=0.5 p=0.6 p=0.7 p=0.8
#> estimate 0.7662883 1.259467 1.56417 1.8223 2.084489 2.375101 2.649204 2.947968
#> p=0.9
#> estimate 3.352676
#>
#> two-sided 95 % CI of each quantile
#> p=0.1 p=0.2 p=0.3 p=0.4 p=0.5 p=0.6 p=0.7 p=0.8
#> 2.5 % 0.126951 0.6692259 1.030378 1.338969 1.638914 1.939799 2.224425 2.451905
#> 97.5 % 1.642281 1.9044221 2.251362 2.599362 2.850168 3.100974 3.384717 3.738452
#> p=0.9
#> 2.5 % 2.813773
#> 97.5 % 4.310994
CIcdfplot(b1, CI.output = "quantile")
# (2) Estimation of the mean of the normal distribution
# by maximum likelihood with the standard deviation fixed at 1
# using the argument fix.arg
# followed by nonparametric bootstrap
# and calculation of quantiles with 95 percent confidence intervals
#
f1b <- fitdistcens(d1, "norm", start = list(mean = 1),fix.arg = list(sd = 1))
b1b <- bootdistcens(f1b, niter = 51)
summary(b1b)
#> Nonparametric bootstrap medians and 95% percentile CI
#> Median 2.5% 97.5%
#> 2.200961 1.730186 2.669676
plot(b1b)
quantile(b1b)
#> (original) estimated quantiles for each specified probability (censored data)
#> p=0.1 p=0.2 p=0.3 p=0.4 p=0.5 p=0.6 p=0.7
#> estimate 0.8527324 1.292663 1.609883 1.880937 2.134284 2.387631 2.658684
#> p=0.8 p=0.9
#> estimate 2.975905 3.415836
#> Median of bootstrap estimates
#> p=0.1 p=0.2 p=0.3 p=0.4 p=0.5 p=0.6 p=0.7
#> estimate 0.9194095 1.35934 1.676561 1.947614 2.200961 2.454308 2.725362
#> p=0.8 p=0.9
#> estimate 3.042582 3.482513
#>
#> two-sided 95 % CI of each quantile
#> p=0.1 p=0.2 p=0.3 p=0.4 p=0.5 p=0.6 p=0.7 p=0.8
#> 2.5 % 0.448634 0.8885643 1.205785 1.476838 1.730186 1.983533 2.254586 2.571807
#> 97.5 % 1.388124 1.8280543 2.145275 2.416328 2.669676 2.923023 3.194076 3.511297
#> p=0.9
#> 2.5 % 3.011737
#> 97.5 % 3.951227
# (3) comparison of sequential and parallel versions of bootstrap
# to be tried with a greater number of iterations (1001 or more)
#
# \donttest{
niter <- 1001
data(fluazinam)
d1 <-log10(fluazinam)
f1 <- fitdistcens(d1, "norm")
# sequential version
ptm <- proc.time()
summary(bootdistcens(f1, niter = niter))
#> Nonparametric bootstrap medians and 95% percentile CI
#> Median 2.5% 97.5%
#> mean 2.161896 1.5618143 2.830404
#> sd 1.126103 0.6858136 1.707159
proc.time() - ptm
#> user system elapsed
#> 4.237 0.108 4.235
# parallel version using snow
require(parallel)
ptm <- proc.time()
summary(bootdistcens(f1, niter = niter, parallel = "snow", ncpus = 2))
#> Nonparametric bootstrap medians and 95% percentile CI
#> Median 2.5% 97.5%
#> mean 2.148432 1.5910391 2.876606
#> sd 1.112494 0.6706691 1.694509
proc.time() - ptm
#> user system elapsed
#> 0.010 0.000 3.179
# parallel version using multicore (not available on Windows)
ptm <- proc.time()
summary(bootdistcens(f1, niter = niter, parallel = "multicore", ncpus = 2))
#> Nonparametric bootstrap medians and 95% percentile CI
#> Median 2.5% 97.5%
#> mean 2.161133 1.5618112 2.930352
#> sd 1.119573 0.7089173 1.701791
proc.time() - ptm
#> user system elapsed
#> 0.011 0.013 2.213
# }