Last data update: 2014.03.03

R: SPIn with Bootstrap
bootSPInR Documentation

SPIn with Bootstrap

Description

Compute the shortest probability interval (spin) using SPIn with bootstrap.

Usage

bootSPIn(x, n.boot = 50, conf = 0.95, bw = 0, lb = -Inf, ub = Inf, l = NA, u = NA)

Arguments

x

A vector of samples from the distribution.

n.boot

Number of bootstraps.

conf

Scalar, the confidence level desired.

bw

Scalar, the bandwidth of the weighting kernel in terms of sample points. If not specified, sqrt(n) will be used, where n is the sample size.

lb,ub

Scalars, the lower and upper bounds of the distribution. If specified, a pseudo-sample point equal to the corresponding bound will be added.

l,u

Scalars, weighting centers (if provided).

Details

spin.boot computes the shortest probability interval for a distribution using SPIn with bootstrap.

Value

spin.boot returns an object of class 'SPIn'. An object of class 'SPIn' is a list containing the following components:

spin

A vector of length 2 with the lower and upper endpoints of the interval.

conf

The confidence level.

x

A vector of samples from the distribution.

w.l,w.u

Vectors of the computed weights.

l.l,l.u,u.l,u.u

Endpoints of the weights.

Note

This function assumes that the distribution is unimodal, and computes only 1 interval, not the set of intervals that are appropriate for multimodal distributions.

Author(s)

Ying Liu yliu@stat.columbia.edu

References

Simulation efficient shortest probability intervals. (arXiv:1302.2142)

See Also

plot.SPIn,SPIn

Examples

x <- rgamma(100,3)
bootSPIn(x)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SPIn)
Loading required package: quadprog
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SPIn/bootSPIn.Rd_%03d_medium.png", width=480, height=480)
> ### Name: bootSPIn
> ### Title: SPIn with Bootstrap
> ### Aliases: bootSPIn
> ### Keywords: ~kwd1 ~kwd2
> 
> ### ** Examples
> 
> x <- rgamma(100,3)
> bootSPIn(x)
$spin
[1] 0.2433207 6.5576748

$conf
[1] 0.95

$x
  [1] 0.1433819 0.3142807 0.4482422 0.4640225 0.5961586 0.6084380 0.6713354
  [8] 0.6773032 0.6845424 0.7136049 0.7392136 0.7800528 0.8997425 0.9896822
 [15] 0.9898831 1.0045772 1.0207955 1.0231631 1.0938095 1.1038627 1.2787839
 [22] 1.2892222 1.4463101 1.4577106 1.5258429 1.5499204 1.7020122 1.8155723
 [29] 1.8201277 1.8398891 1.8947263 1.9018451 1.9512350 1.9721735 1.9987015
 [36] 2.0927159 2.2102145 2.3103053 2.3508682 2.3842066 2.3990982 2.4797129
 [43] 2.4849884 2.5426792 2.5734396 2.7412512 2.7493937 2.7555056 2.7654257
 [50] 2.7695003 2.8313748 2.8404939 2.8459163 3.0380713 3.1048049 3.1421630
 [57] 3.1705174 3.2870515 3.2942129 3.4212580 3.4214971 3.4337704 3.4395055
 [64] 3.4478941 3.4553017 3.5248962 3.5270138 3.5540941 3.5660882 3.5731119
 [71] 3.6233337 3.6724749 3.6815955 3.8488326 3.8943240 3.8987197 3.9305353
 [78] 4.0393772 4.1268260 4.1995582 4.2174398 4.3068905 4.5245923 4.6749177
 [85] 4.7875169 4.9636645 4.9717070 4.9944771 5.1114496 5.1212632 5.2642597
 [92] 5.3926510 5.4952581 5.8052434 6.0446469 6.1527174 6.5787286 8.9990892
 [99] 9.2635863 9.6166441

$w.l
  [1] 0.640571429 0.142793651 0.142793651 0.022793651 0.022793651 0.010793651
  [7] 0.010793651 0.002222222 0.002222222 0.002222222 0.000000000 0.000000000
 [13] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [19] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [25] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [31] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [37] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [43] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [49] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [55] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [61] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [67] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [73] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [79] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [85] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [91] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
 [97] 0.000000000 0.000000000 0.000000000 0.000000000

$w.u
  [1] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
  [7] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [13] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [19] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [25] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [31] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [37] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [43] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [49] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [55] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [61] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [67] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [73] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [79] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [85] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [91] 0.05773469 0.10363471 0.10773533 0.12915993 0.14191851 0.14410451
 [97] 0.11511797 0.08996056 0.06304932 0.04758446

$l.l
[1] 1

$l.u
[1] 10

$u.l
[1] 91

$u.u
[1] 100

attr(,"class")
[1] "SPIn"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>