bootstrap | R Documentation |
Conducts a bootstrap procedure to calculate confidence intervals for various statistics.
bootstrap(x, statistic, alternative="two.sided", alpha = 0.05,
Q = c(0.25, 0.5, 0.75), qt = 7, R = 3000)
x |
A data frame or matrix containing the data. |
statistic |
Name of the function to compute the statistic of interest. |
alternative |
Type of hypothesis test. The default is "two.sided". |
alpha |
A numeric value specifying the significance level for confidence intervals. The default is 0.05. |
Q |
A numeric vector or a number specifying the probabilities used in quantile calculations. The default is c(0.25, 0.5, 0.75) for P25, P50, P75 (aka Q1, Q2 and Q3). |
qt |
A numeric value specifying the type of quantile calculation. The default is 7. |
R |
An integer specifying the number of bootstrap replicates. The default is 3000. |
This function performs a bootstrap procedure to calculate confidence intervals for various statistics. It is mainly used to evaluate the differences between various statistics for two groups based on a specified function. The function calculates confidence intervals using different methods, including normal, basic, percentile, and bias-corrected and accelerated (BCa) intervals. It allows users to pass custom statistics
(via statistic
) that include parameters like quantiles (via Q
) and types of quantiles (qt
), making it versatile
for non-standard use cases. In this way, the function extends the capabilities of boot::boot.ci
(R's suggested package) by supporting
more advanced statistical needs and customizable interval calculations. This function also incorporates the argument alternative
can be set to "greater"
or "less"
for one-tailed confidence intervals, whereas boot::boot.ci
primarily focuses on two-tailed intervals.Therefore, it is particularly useful for specialized applications. The data can be provided in long format, and the test uses a specified number of bootstrap replicates to calculate the empirical distribution of the test statistic under the null hypothesis.
A list containing the data frames for the following components for each statistic:
normal |
Lower and upper limits of the confidence interval computed with the normal method. |
basic |
Lower and upper limits of the confidence interval computed with the basic method. |
percent |
Lower and upper limits of the confidence interval computed with the percent method. |
bca |
Lower and upper limits of the confidence interval computed with the BCa method. |
Zeynel Cebeci, A. Firat Ozdemir, Engin Yildiztepe
permtest
# Load the quail dataset
data(quail)
# Bootstrap for the difference of various basic statistics
# Increase R for real-world applications
bootres <- bootstrap(quail, statistic = calcstatdif, R=200)
bootres
# Arrange the results as a data frame
ci2df(bootres)
# Bootstrap for the differences of quantiles
bootresq <- bootstrap(quail, statistic = calcquantdif, R=200)
bootresq
# Arrange the results as a data frame
ci2df(bootresq)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.