Package {saCI}


Title: Stochastic Approximation Confidence Interval for Correlation
Version: 0.1.0
Description: Implements stochastic approximation method for constructing nonparametric confidence intervals for correlation coefficient, based on Xiong & Xu (2016).
License: GPL (≥ 3)
Encoding: UTF-8
Imports: boot, MASS, mvtnorm
Suggests: testthat (≥ 3.0.0), shiny
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-05-26 06:54:10 UTC; 14482
Author: Pengyu Chen Group1 [aut, cre]
Maintainer: Pengyu Chen Group1 <1448207797@qq.com>
Repository: CRAN
Date/Publication: 2026-05-29 10:40:02 UTC

Bootstrap BCa Confidence Interval for Correlation

Description

Computes confidence interval for the correlation of two populations using bootstrap BCa (bias-corrected and accelerated) method.

Usage

boot_corrCI(x, y, conf.level = 0.95, R = 999)

Arguments

x

Numeric vector of first variable (must have same length as y)

y

Numeric vector of second variable (must have same length as x)

conf.level

Confidence level for the interval (default 0.95)

R

Number of bootstrap replicates (default 999)

Details

This function implements the BCa (bias-corrected and accelerated) bootstrap method for constructing confidence intervals for Pearson's correlation coefficient. The BCa method adjusts for both bias and skewness in the bootstrap distribution.

The data is standardized in the same way as corrCI_sa for consistency in comparison studies.

Value

An S3 object of class "corrCI_boot" containing:

lower

Lower bound of the confidence interval

upper

Upper bound of the confidence interval

estimate

Point estimate of correlation coefficient

conf.level

The confidence level

method

Description of the method

References

Efron, B. (1987). Better Bootstrap Confidence Intervals. Journal of the American Statistical Association, 82(398), 171-185.

Examples

set.seed(42)
x <- rnorm(30)
y <- x + rnorm(30, sd = 0.5)
result <- boot_corrCI(x, y)
print(result)


Stochastic Approximation Confidence Interval for Correlation

Description

Computes confidence interval for the correlation of two populations using stochastic approximation via resampling method (Garthwaite, 1996).

Usage

corrCI_sa(x, y, conf.level = 0.95)

Arguments

x

Numeric vector of first variable (must have same length as y)

y

Numeric vector of second variable (must have same length as x)

conf.level

Confidence level for the interval (default 0.95)

Details

This function implements the stochastic approximation algorithm for constructing nonparametric confidence intervals for Pearson's correlation coefficient, based on Garthwaite (1996). The algorithm uses recursive resampling to find the quantiles of the sampling distribution.

Value

An S3 object of class "corrCI_sa" containing:

lower

Lower bound of the confidence interval

upper

Upper bound of the confidence interval

estimate

Point estimate of correlation coefficient

conf.level

The confidence level

method

Description of the method

iterations

List with components L (iterations for lower bound) and U (iterations for upper bound)

References

Garthwaite, P. H. (1996). Confidence interval formation via stochastic approximation. Statistics and Computing, 6(3), 235-241.

Examples

set.seed(42)
x <- rnorm(30)
y <- x + rnorm(30, sd = 0.5)
result <- corrCI_sa(x, y)
print(result)


Print Method for corrCI_boot Objects

Description

Prints the results of a bootstrap correlation confidence interval analysis.

Usage

## S3 method for class 'corrCI_boot'
print(x, ...)

Arguments

x

An object of class "corrCI_boot"

...

Additional arguments passed to print

Value

Prints the confidence interval, estimate, and method information.


Print Method for corrCI_sa Objects

Description

Prints the results of a correlation confidence interval analysis.

Usage

## S3 method for class 'corrCI_sa'
print(x, ...)

Arguments

x

An object of class "corrCI_sa"

...

Additional arguments passed to print

Value

Prints the confidence interval, estimate, and method information.


Run the saCI Shiny Application

Description

Run the saCI Shiny Application

Usage

runShinyApp()

Value

Starts the Shiny app