generated from UofUEpiBio/advanced-programming-midterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
113 lines (81 loc) · 3.21 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# symbootpkg
<!-- badges: start -->
[![R-CMD-check](https://github.com/blessingofori-atta/PHS7045-Midterm/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/blessingofori-atta/PHS7045-Midterm/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of symbootpkg is to provide flexible tools to compute bootstrap-t, equal-tailed, and symmetric confidence intervals for statistical analysis. It incorporates methods for plugin and nested bootstrap standard error estimations, with options for parallelization to improve efficiency.
## Features
- **Bootstrap-t Confidence Intervals**: Compute confidence intervals using the bootstrap-t method with options for plugin and nested standard error estimates.
- **Equal-Tailed and Symmetric Intervals**: Includes methods for both equal-tailed and symmetric bootstrap confidence intervals.
- **Flexible Standard Error Functions**: Supports user-specified `sdfun` functions or nested bootstrap for standard error estimation.
- **Parallel Processing**: Optional parallelization to leverage multiple cores for faster computation.
## Installation
You can install the development version of symbootpkg from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("blessingofori-atta/symbootpkg")
```
## Usage
### Basic Example
Here's a basic example of how to use the bootstrap and bootstrap_t functions:
```{r example}
library(symbootpkg)
set.seed(123)
# Define a statistic function
beta <- function(dat) {
mod <- lm(Sepal.Length ~ Sepal.Width, data = dat)
bb <- mod$coefficients[2]
return(bb)
}
# Perform bootstrap resampling
boot_obj <- bootstrap(
data = iris,
statistic = beta,
nboot = 1000,
return_samples = TRUE
)
# Compute symmetic bootstrap-t confidence intervals
ci_result <- bootstrap_t(
boot_obj = boot_obj,
Bsd = 25,
method = "bootsym-nested",
alpha = 0.05
)
# Print results
print(ci_result)
```
### Parallel Processing Example
You can enable parallel processing to speed up the computation:
```{r cars}
ci_result_parallel <- bootstrap_t(
boot_obj = boot_obj,
Bsd = 25,
method = "bootsym-nested",
parallel = TRUE,
cores = 2,
alpha = 0.05
)
# Print results
print(ci_result_parallel)
```
## Contribution
Contributions are welcome! Please open an issues or submit a pull request to improve the package.
## License
This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## References
1. Efron, B., & Tibshirani, R. J. (1993). An introduction to the bootstrap. New York:Chapman & Hall.
2. Hall, P. (1988). On Symmetric Bootstrap Confidence Intervals. Journal of the Royal Statistical Society. Series B (Methodological), 50(1), 35–45. http://www.jstor.org/stable/2345806.
3. Elias, C. J. (2015). Percentile and percentile- t bootstrap confidence intervals: A practical comparison. Journal of Econometric Methods, 4(1), 153–161. doi:10.1515/jem-2013-0015
4. http://users.stat.umn.edu/~helwig/notes/npboot-notes.html
---