# nonpar_bs_ci: Non-Parametric bootstrapped confidence intervals to control... In rcc: Parametric Bootstrapping to Control Rank Conditional Coverage

## Description

This function implements Algorithm 3 in the paper (see Section 2.4). The user supplies individual level data and an analysis function that generates test statistics and point estimates. The function resamples individuals from the original data and recalculates test statistics and estimates in order to calculate confidence intervals.

## Usage

 ```1 2``` ```nonpar_bs_ci(data, analysis.func, rank.func = NULL, level = 0.9, res.orig = NULL, n.rep = 1000, use.abs = TRUE, parallel = FALSE, ...) ```

## Arguments

 `data` An n by K matrix of data `analysis.func` A function that performs the analysis. This function should take exactly one argument (data) and return a list or data frame including an item called 'estimate' and an item called 'statistic'. These should both be vectors of length p, the number of parameters. `rank.func` A function that takes, as first argument, the statistics returned by analysis.func. The second argument should be use.abs which can take a logical value. This argument indicates if ranking should be based on signed or absolute value of the statistics. rank.func should return a list including items named order and rank. See rcc:::basic_rank for an example. If NULL, the basic_rank function will be used which ranks based on the size of the test statistics. `level` Confidence level `res.orig` Results of applying analysis.funct to the original data if they are already available. If NULL, these will be calculated. `n.rep` Number of bootstrap replications `use.abs` Logical. Rank based on absolute value of the statistics `parallel` Logical. If true, use the parallel package to make use of multiple cores. `...` Additional parameters to pass to rank.func

## Value

A data frame giving original estimates and statistics, confidence intervals, debiased point estimates, and rank for each parameter.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23``` ```#Generate some data -- 10 parameters, 30 samples #Most problems will have many more parameters! set.seed(4e8) dat <- matrix(rnorm(n=10*30), nrow=10) #Write a function to do a t-test comparing #the first 15 samples and the last 15 samples my.analysis.func <- function(data){ x <- rep(c(1, 0), each=15) B <- t(apply(data, MARGIN=1, FUN=function(y){ f <- t.test(y~x) est <- f\$estimate[2]-f\$estimate[1] stat <- f\$statistic return(c(est, stat)) })) B <- data.frame(B) names(B) <- c("estimate", "statistic") return(B) } #Calculate confidence intervals cis <- nonpar_bs_ci(data=dat, analysis.func=my.analysis.func, n.rep=500) head(cis) ```

### Example output

```          est   statistic rank   ci.lower  ci.upper debiased.est
1 -0.33433416  0.70673267    6 -0.5276049 0.6026144 -0.059476794
2 -0.42490918  1.08534074    3 -0.4720446 0.7053101 -0.048338306
3  0.11450914 -0.24275888    9 -0.5276049 0.6026144 -0.097944981
4  0.02623807 -0.06779177   10 -0.5768847 0.5143433 -0.160500982
5  0.60261437 -1.58519472    1 -0.5276049 0.6026144  0.006117771
6 -0.37841153  0.98299169    4 -0.5124299 0.6177894 -0.041882394
```

rcc documentation built on May 1, 2019, 6:35 p.m.