Title: | Statistical Tests of Familial Hypotheses |
---|---|
Description: | Provides functionality for testing familial hypotheses. Supports testing centers belonging to the Huber family. Testing is carried out using the Bayesian bootstrap. One- and two-sample tests are supported, as are directional tests. Methods for visualizing output are provided. |
Authors: | Ryan Thompson [aut, cre] |
Maintainer: | Ryan Thompson <[email protected]> |
License: | GPL-3 |
Version: | 1.0.5 |
Built: | 2024-11-20 03:20:38 UTC |
Source: | https://github.com/ryan-thompson/familial |
Performs a Bayesian bootstrap for a statistic defined via a suitable function.
bayes.boot(x, fun, nboot = 1000, cluster = NULL, ...)
bayes.boot(x, fun, nboot = 1000, cluster = NULL, ...)
x |
a numeric vector to be passed as the first argument to |
fun |
the function to bootstrap; must accept data |
nboot |
the number of bootstraps to perform |
cluster |
an optional cluster for running bootstraps in parallel; must be set up using
|
... |
any other arguments for |
An object of class bayes.boot
; a data frame with the following columns:
boot.id |
the bootstrap iteration index |
... |
any columns returned by |
Ryan Thompson <[email protected]>
set.seed(123) boot <- bayes.boot(MASS::galaxies, fun = fit.family, nboot = 100) head(boot)
set.seed(123) boot <- bayes.boot(MASS::galaxies, fun = fit.family, nboot = 100) head(boot)
Performs a one- or two-sample test for a family of centers.
center.test( x, y = NULL, family = "huber", alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, nboot = 1000, loss = NULL, cluster = NULL, ... )
center.test( x, y = NULL, family = "huber", alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, nboot = 1000, loss = NULL, cluster = NULL, ... )
x |
a numeric vector of data |
y |
an optional numeric vector of data |
family |
the family of centers; currently only allows 'huber' for Huber family |
alternative |
the form of the alternative hypothesis; must be one of 'two.sided' (default), 'greater', or 'less' |
mu |
the null value of the center for a one-sample test, or the null value of the center of differences for a paired two-sample test, or the null value of the difference of centers for an independent two-sample test; can be an interval |
paired |
a logical indicating whether to treat |
nboot |
the number of bootstraps to perform |
loss |
an optional c×2 matrix of losses incurred from an incorrect decision, where c is the number of candidate choices (typically c=3: H0, H1, or indeterminate) |
cluster |
an optional cluster for running bootstraps in parallel; must be set up using
|
... |
any other arguments |
Uses the Bayesian bootstrap to compute posterior probabilities for the hypotheses
for some
vs.
for all
,
where
is a family of centers.
The default loss matrix results in a decision whenever the posterior probability
for one of the hypotheses is greater than 0.95 and otherwise is indeterminate.
An object of class center.test
; a list with the following components:
expected.loss |
the expected loss, calculated by post-multiplying |
decision |
the optimal decision given the expected loss |
loss |
the loss matrix |
prob |
the estimated posterior probabilities of the null and alternative |
boot |
the bootstrap output from |
x |
the |
y |
the |
mu |
the |
family |
the |
Ryan Thompson <[email protected]>
Thompson, R., Forbes, C. S., MacEachern, S. N., and Peruggia, M. (2023). 'Familial inference: Tests for hypotheses on a family of centres'. arXiv: 2202.12540.
set.seed(123) test <- center.test(MASS::galaxies, mu = 21000, nboot = 100) print(test) plot(test) cl <- parallel::makeCluster(2) test <- center.test(MASS::galaxies, mu = 21000, nboot = 100, cluster = cl) parallel::stopCluster(cl) print(test)
set.seed(123) test <- center.test(MASS::galaxies, mu = 21000, nboot = 100) print(test) plot(test) cl <- parallel::makeCluster(2) test <- center.test(MASS::galaxies, mu = 21000, nboot = 100, cluster = cl) parallel::stopCluster(cl) print(test)
Fits a family of centers.
fit.family( x, w = rep(1, length(x)), family = "huber", spread.fun = weighted.mad, eps = .Machine$double.eps )
fit.family( x, w = rep(1, length(x)), family = "huber", spread.fun = weighted.mad, eps = .Machine$double.eps )
x |
a numeric vector of data |
w |
a numeric vector of weights |
family |
the location family; currently only allows 'huber' for Huber family |
spread.fun |
a function used for the spread of |
eps |
a numerical tolerance parameter |
An object of class fit.family
; a data frame with the following columns:
mu |
the fitted values |
lambda |
the thresholding parameter |
Ryan Thompson <[email protected]>
fit <- fit.family(MASS::galaxies) plot(fit)
fit <- fit.family(MASS::galaxies) plot(fit)
center.test
objectPlot the posterior distribution for the family of centers using a functional box plot.
## S3 method for class 'center.test' plot(x, band = c(0.5, 0.75, 0.95), ninterp = 25, ...)
## S3 method for class 'center.test' plot(x, band = c(0.5, 0.75, 0.95), ninterp = 25, ...)
x |
an object of class |
band |
a vector of band limits for the functional box plot |
ninterp |
the number of interpolation points for the functional box plot; more points lead to finer resolution of the plot at the expense of additional computation |
... |
any other arguments |
A plot of the posterior distribution.
Ryan Thompson <[email protected]>
fit.family
objectPlot a fitted family.
## S3 method for class 'fit.family' plot(x, y = NULL, ...)
## S3 method for class 'fit.family' plot(x, y = NULL, ...)
x |
an object of class |
y |
an object of class |
... |
any other arguments |
A plot of the fitted family.
Ryan Thompson <[email protected]>
center.test
objectPrint objects of class center.test
.
## S3 method for class 'center.test' print(x, ...)
## S3 method for class 'center.test' print(x, ...)
x |
an object of class |
... |
any other arguments |
The argument x
.
Ryan Thompson <[email protected]>
Random number generation for the uniform Dirichlet distribution (having all concentration parameters set to one).
rudirichlet(n, d)
rudirichlet(n, d)
n |
the number of observations |
d |
the number of dimensions |
A matrix; each row is a random draw and each column is a dimension.
Ryan Thompson <[email protected]>
Assorted weighted statistics unavailable in base R.
weighted.median(x, w) weighted.mad(x, w)
weighted.median(x, w) weighted.mad(x, w)
x |
a numeric vector of data |
w |
a numeric vector of weights |
A length-one numeric vector.
Ryan Thompson <[email protected]>