Probabilistic multi-resolution scanning for cross-sample variation
================================

This package fits the MRS algorithm for comparison across probability distributions.
The model is based on a nonparametric process taking the form of a Markov model that transitions
between a "null" and an "alternative" state on a multi-resolution partition tree of the sample space.
MRS effectively detects and characterizes a variety of underlying differences.
These differences can be visualized using several plotting functions.

### Install

The development version can be installed from GitHub on Linux, macOS, or Windows:

```S
install.packages("remotes")
remotes::install_github("MaStatLab/MRS")
```

### Use
The main functions and their descriptions are provided in the help files:

```S
ans = mrs(X, G)
ans = andova(X, G, H)
summary(ans)
plot1D(ans)
plot2D(ans)
plotTree(ans)
plot1DSigWindows(ans)
```

### Visual demos

The package includes three reproducible demonstrations of the main workflows:

```S
demo(package = "MRS")

demo("mrs_1d", package = "MRS", ask = FALSE)
demo("mrs_2d", package = "MRS", ask = FALSE)
demo("andova_replicates", package = "MRS", ask = FALSE)
```

The former standalone scripts in `examples/` have been consolidated into these
demos. Each workflow now has one purpose:

- `mrs_1d` shows a localized difference, its signed effect, and Bayesian-FDR
  selection.
- `mrs_2d` compares the observed grouping with a label-shuffled control before
  showing multiscale probability, effect, and tree views.
- `andova_replicates` compares pooled MRS with both ANDOVA integration methods,
  uses an explicit baseline, and contrasts nested studies with 4, 10, and 20
  replicates to show why pooled analysis can be overconfident.

All simulations use fixed random seeds. The obsolete `mrs_nested()` examples
are represented by the supported `andova()` workflow, while developer-oriented
numerical diagnostics are covered by the automated tests.

### Reference
Soriano J. and Ma L. (2017). Probabilistic multi-resolution scanning for two-sample differences. Journal of the Royal Statistical Society: Series B, 79(2), 547-572. <https://doi.org/10.1111/rssb.12180>

Ma L. and Soriano J. (2018). Analysis of distributional variation through multi-scale Beta-Binomial modeling. Journal of Computational and Graphical Statistics, 27(3), 529-541. <https://doi.org/10.1080/10618600.2017.1402774>
