# saCI: Stochastic Approximation Confidence Interval for Correlation

An R package implementing the stochastic approximation method for constructing nonparametric confidence intervals for Pearson's correlation coefficient, based on Xiong & Xu (2016).

## Installation

```r
# Install from CRAN (once available)
install.packages("saCI")

# Or install development version from GitHub
# remotes::install_github("USERNAME/saCI")
```

## Usage

```r
library(saCI)

# Generate sample data
set.seed(42)
x <- rnorm(30)
y <- x + rnorm(30, sd = 0.5)

# Calculate confidence interval
result <- corrCI_sa(x, y)
print(result)
```

## Features

- **Stochastic Approximation CI**: Implements the SA method from Xiong & Xu (2016)
- **Bootstrap BCa Comparison**: Built-in Bootstrap BCa method for comparison
- **Interactive Shiny App**: Explore the method interactively
- **Simulation Studies**: Built-in Monte Carlo simulation for coverage studies

## Shiny App

Run the interactive Shiny app:

```r
saCI::runShinyApp()
# or
shiny::runApp(system.file("shinyapp", package = "saCI"))
```

## Method

This package implements the stochastic approximation algorithm for constructing confidence intervals without requiring large-scale resampling. The algorithm uses recursive Monte Carlo to find the quantiles of the sampling distribution.

## References

- Xiong, C. and Xu, J. (2016). Confidence intervals from stochastic approximation. *Communications in Statistics – Simulation and Computation*, 45, 1827-1837.

## License

GPL (>= 3)
