Package {LRTesteR}


Title: Likelihood Ratio Tests and Confidence Intervals
Version: 2.0.0
Maintainer: Greg McMahan <gmcmacran@gmail.com>
Description: A collection of hypothesis tests and confidence intervals based on the likelihood ratio https://en.wikipedia.org/wiki/Likelihood-ratio_test.
License: GPL-3
Encoding: UTF-8
Imports: stats, rlang, statmod, stringr, EnvStats
RoxygenNote: 7.3.3
Suggests: covr, testthat, lmtest, knitr, rmarkdown, emplik, emplik2, datasets
VignetteBuilder: knitr
URL: https://github.com/gmcmacran/LRTesteR
BugReports: https://github.com/gmcmacran/LRTesteR/issues
NeedsCompilation: no
Packaged: 2026-08-23 22:12:13 UTC; ixi_eulogy_ixi
Author: Greg McMahan [aut, cre]
Repository: CRAN
Date/Publication: 2026-08-24 08:10:08 UTC

Test the equality of shape 1 parameters of beta distributions.

Description

Test the equality of shape 1 parameters of beta distributions.

Usage

beta_shape1_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The shape2s are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rbeta(150, 1, 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
beta_shape1_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rbeta(50, 1, 2), rbeta(50, 2, 2), rbeta(50, 3, 2))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
beta_shape1_one_way_test(x, fctr, .95)

Test the shape1 parameter of a beta distribution.

Description

Test the shape1 parameter of a beta distribution.

Usage

beta_shape1_test(x, shape1, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

shape1

a number indicating the tested value of the shape1 parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rbeta(100, shape1 = 1, shape2 = 2)
beta_shape1_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rbeta(100, shape1 = 3, shape2 = 2)
beta_shape1_test(x, 1, "greater")

Test the equality of shape 2 parameters of beta distributions.

Description

Test the equality of shape 2 parameters of beta distributions.

Usage

beta_shape2_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The shape1s are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rbeta(150, 2, 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
beta_shape2_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rbeta(50, 2, 1), rbeta(50, 2, 2), rbeta(50, 2, 3))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
beta_shape2_one_way_test(x, fctr, .95)

Test the shape2 parameter of a beta distribution.

Description

Test the shape2 parameter of a beta distribution.

Usage

beta_shape2_test(x, shape2, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

shape2

a number indicating the tested value of the shape2 parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rbeta(100, shape1 = 1, shape2 = 1)
beta_shape2_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rbeta(100, shape1 = 1, shape2 = 3)
beta_shape2_test(x, 1, "greater")

Test the equality of prob parameters of binomial distributions.

Description

Test the equality of prob parameters of binomial distributions.

Usage

binomial_prob_one_way_test(x, size, fctr, conf.level = 0.95)

Arguments

x

a numeric vector indicating number of successes per group.

size

a numeric vector indicating number of attempts per group.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true.
set.seed(1)
x <- rbinom(3, 50, .5)
size <- rep(50, length(x))
fctr <- factor(1:length(x))
binomial_prob_one_way_test(x, size, fctr, .95)

# Null is false
set.seed(1)
x <- rbinom(3, 50, c(.25, .50, .75))
size <- rep(50, length(x))
fctr <- factor(1:length(x))
binomial_prob_one_way_test(x, size, fctr, .95)

Test the prob parameter of a binomial distribution.

Description

Test the prob parameter of a binomial distribution.

Usage

binomial_prob_test(x, size, prob, alternative = "two.sided", conf.level = 0.95)

Arguments

x

Number of successes.

size

Number of trials.

prob

Hypothesized probability of success.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true. 52 successes. 100 trials
binomial_prob_test(52, 100, .50, "two.sided")

# Null is false. 75 successes. 100 trials
binomial_prob_test(75, 100, .50, "two.sided")

Test the equality of location parameters of cauchy distributions.

Description

Test the equality of location parameters of cauchy distributions.

Usage

cauchy_location_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The scales are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(2)
x <- rcauchy(n = 150, location = 1, scale = 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
cauchy_location_one_way_test(x, fctr, .95)

# Null is false
set.seed(2)
x <- c(rcauchy(50, 1, 2), rcauchy(50, 2, 2), rcauchy(50, 3, 2))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
cauchy_location_one_way_test(x, fctr, .95)

Test the location parameter of a cauchy distribution.

Description

Test the location parameter of a cauchy distribution.

Usage

cauchy_location_test(x, location, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

location

a number indicating the tested value of the location parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rcauchy(n = 100, location = 1, scale = 2)
cauchy_location_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rcauchy(n = 100, location = 3, scale = 2)
cauchy_location_test(x, 1, "greater")

Test the equality of scale parameters of cauchy distributions.

Description

Test the equality of scale parameters of cauchy distributions.

Usage

cauchy_scale_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The locations are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rcauchy(n = 150, 1, 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
cauchy_scale_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rcauchy(50, 2, 1), rcauchy(50, 2, 2), rcauchy(50, 2, 3))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
cauchy_scale_one_way_test(x, fctr, .95)

Test the scale parameter of a cauchy distribution.

Description

Test the scale parameter of a cauchy distribution.

Usage

cauchy_scale_test(x, scale, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

scale

a number indicating the tested value of the scale parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rcauchy(n = 100, location = 1, scale = 2)
cauchy_scale_test(x, 2, "two.sided")

# Null is false
set.seed(1)
x <- rcauchy(n = 100, location = 3, scale = 2)
cauchy_scale_test(x, 1, "greater")

Nonparametric test for the equality of means of an unknown distribution.

Description

Nonparametric test for the equality of means of an unknown distribution.

Usage

empirical_mu_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(75, 1, 1)
fctr <- c(rep(1, 25), rep(2, 25), rep(3, 25))
fctr <- factor(fctr, levels = c("1", "2", "3"))
empirical_mu_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rnorm(25, 1, 1), rnorm(25, 2, 1), rnorm(25, 3, 1))
fctr <- c(rep(1, 25), rep(2, 25), rep(3, 25))
fctr <- factor(fctr, levels = c("1", "2", "3"))
empirical_mu_one_way_test(x, fctr, .95)

Nonparametric test for the mean parameter of an unknown distribution.

Description

Nonparametric test for the mean parameter of an unknown distribution.

Usage

empirical_mu_test(x, mu, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector.

mu

a number indicating the tested value of mu.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(25, 0, 1)
empirical_mu_test(x, 0, "two.sided")

# Null is false
set.seed(1)
x <- rnorm(25, 2, 1)
empirical_mu_test(x, 1, "greater")

Nonparametric test for the equality of a quantile from an unknown distribution.

Description

Nonparametric test for the equality of a quantile from an unknown distribution.

Usage

empirical_quantile_one_way_test(x, Q, fctr, conf.level = 0.95)

Arguments

x

a numeric vector.

Q

The quantile. A single numeric number. (.50 is median.)

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(75, 1, 1)
fctr <- c(rep(1, 25), rep(2, 25), rep(3, 25))
fctr <- factor(fctr, levels = c("1", "2", "3"))
empirical_quantile_one_way_test(x, .50, fctr, .95)

# Null is false
set.seed(1)
x <- c(rnorm(25, 1, 1), rnorm(25, 2, 1), rnorm(25, 3, 1))
fctr <- c(rep(1, 25), rep(2, 25), rep(3, 25))
fctr <- factor(fctr, levels = c("1", "2", "3"))
empirical_quantile_one_way_test(x, .50, fctr, .95)

Nonparametric test for a quantile of an unknown distribution.

Description

Nonparametric test for a quantile of an unknown distribution.

Usage

empirical_quantile_test(
  x,
  Q,
  value,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

x

a numeric vector.

Q

The quantile. A single numeric number. (.50 is median.)

value

A single numeric value that is the hypothesized Q quantile.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Details

For confidence intervals, an endpoint may be outside the observed range of x. In this case, NA is returned. Reducing confidence or collecting more data will make the CI computable.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(25, 0, 1)
empirical_quantile_test(x, .5, 0, "two.sided")

# Null is false
set.seed(1)
x <- rnorm(25, 2, 1)
empirical_quantile_test(x, .5, 1, "greater")

Nonparametric test for the equality of variances of unknown distributions.

Description

Nonparametric test for the equality of variances of unknown distributions.

Usage

empirical_variance_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

Because groups are independent, the -2 log likelihood ratios of the groups add. The common variance under the null is profiled out by minimizing the summed statistic.

The asymptotic approximation requires moderately large groups. In simulations with three normal groups, type I error was near the nominal .05 for groups of 100 or more and mildly inflated for smaller groups.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(30, 0, 1)
fctr <- c(rep(1, 15), rep(2, 15))
fctr <- factor(fctr, levels = c("1", "2"))
empirical_variance_one_way_test(x, fctr, .95) # Testing variance, not standard deviation

# Null is false
set.seed(1)
x <- c(rnorm(15, 0, 1), rnorm(15, 0, 3))
fctr <- c(rep(1, 15), rep(2, 15))
fctr <- factor(fctr, levels = c("1", "2"))
empirical_variance_one_way_test(x, fctr, .95)

Nonparametric test for the variance of an unknown distribution.

Description

Nonparametric test for the variance of an unknown distribution.

Usage

empirical_variance_test(
  x,
  sigma.squared,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

x

a numeric vector.

sigma.squared

a number indicating the tested value of sigma squared.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Details

The mean is a nuisance parameter and is profiled out of the likelihood.

For confidence intervals, an endpoint may not be computable. In this case, NA is returned. Reducing confidence or collecting more data will make the CI computable.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(25, 0, 1)
empirical_variance_test(x, 1, "two.sided") # Testing variance, not standard deviation

# Null is false
set.seed(1)
x <- rnorm(25, 0, 1)
empirical_variance_test(x, 2, "less")

Test the equality of rate parameters of exponential distributions.

Description

Test the equality of rate parameters of exponential distributions.

Usage

exponential_rate_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rexp(150, 1)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
exponential_rate_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rexp(50, 1), rexp(50, 2), rexp(50, 3))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
exponential_rate_one_way_test(x, fctr, .95)

Test the rate parameter of an exponential distribution.

Description

Test the rate parameter of an exponential distribution.

Usage

exponential_rate_test(x, rate, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

rate

a number indicating the tested value of rate.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rexp(100, 1)
exponential_rate_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rexp(100, 3)
exponential_rate_test(x, 1, "greater")

Test the equality of rate parameters of gamma distributions.

Description

Test the equality of rate parameters of gamma distributions.

Usage

gamma_rate_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The shapes are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rgamma(150, 1, 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gamma_rate_one_way_test(x, fctr, .95)

# Null is false
set.seed(5)
x <- c(rgamma(50, 2, 1), rgamma(50, 2, 2), rgamma(50, 2, 3))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gamma_rate_one_way_test(x, fctr, .95)

Test the rate parameter of a gamma distribution.

Description

Test the rate parameter of a gamma distribution.

Usage

gamma_rate_test(x, rate, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

rate

a number indicating the tested value of the rate parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rgamma(100, shape = 1, rate = 1)
gamma_rate_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rgamma(100, shape = 1, rate = 2)
gamma_rate_test(x, 1, "greater")

Test the equality of scale parameters of gamma distributions.

Description

Test the equality of scale parameters of gamma distributions.

Usage

gamma_scale_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The shapes are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rgamma(150, 1, scale = 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gamma_scale_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rgamma(50, 2, scale = 1), rgamma(50, 2, scale = 2), rgamma(50, 2, scale = 3))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gamma_scale_one_way_test(x, fctr, .95)

Test the scale parameter of a gamma distribution.

Description

Test the scale parameter of a gamma distribution.

Usage

gamma_scale_test(x, scale, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

scale

a number indicating the tested value of the scale parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rgamma(100, shape = 1, scale = 2)
gamma_scale_test(x, 2, "two.sided")

# Null is false
set.seed(1)
x <- rgamma(100, shape = 1, scale = 2)
gamma_scale_test(x, 1, "greater")

Test the equality of shape parameters of gamma distributions.

Description

Test the equality of shape parameters of gamma distributions.

Usage

gamma_shape_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The rates are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rgamma(150, 2, 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gamma_shape_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rgamma(50, 1, 2), rgamma(50, 2, 2), rgamma(50, 3, 2))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gamma_shape_one_way_test(x, fctr, .95)

Test the shape parameter of a gamma distribution.

Description

Test the shape parameter of a gamma distribution.

Usage

gamma_shape_test(x, shape, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

shape

a number indicating the tested value of the shape parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rgamma(100, shape = 1, scale = 2)
gamma_shape_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rgamma(100, shape = 3, scale = 2)
gamma_shape_test(x, 1, "greater")

Test the equality of means of gaussian distributions.

Description

Test the equality of means of gaussian distributions.

Usage

gaussian_mu_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The variance is assumed to be equal across all groups.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(150, 1, 1)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gaussian_mu_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rnorm(50, 1, 1), rnorm(50, 2, 1), rnorm(50, 3, 1))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gaussian_mu_one_way_test(x, fctr, .95)

Test the mean of a gaussian distribution.

Description

Test the mean of a gaussian distribution.

Usage

gaussian_mu_test(x, mu, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

mu

a number indicating the tested value of mu.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(100, 0, 1)
gaussian_mu_test(x, 0, "two.sided")

# Null is false
set.seed(1)
x <- rnorm(100, 3, 1)
gaussian_mu_test(x, 0, "greater")

Test the equality of variance parameters of gaussian distributions.

Description

Test the equality of variance parameters of gaussian distributions.

Usage

gaussian_variance_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The means are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(150, 1, 1)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gaussian_variance_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rnorm(50, 1, 1), rnorm(50, 1, 2), rnorm(50, 1, 3))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
gaussian_variance_one_way_test(x, fctr, .95)

Test the variance of a gaussian distribution.

Description

Test the variance of a gaussian distribution.

Usage

gaussian_variance_test(
  x,
  sigma.squared,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

x

a numeric vector of data.

sigma.squared

a number indicating the tested value of sigma squared.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rnorm(100, 0, 1)
gaussian_variance_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rnorm(100, 0, 2)
gaussian_variance_test(x, 1, "greater")

Test the equality of dispersion parameters of inverse gaussian distributions.

Description

Test the equality of dispersion parameters of inverse gaussian distributions.

Usage

inverse_gaussian_dispersion_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The means are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)
library(statmod)

# Null is true
set.seed(1)
x <- rinvgauss(n = 150, mean = 1, dispersion = 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
inverse_gaussian_dispersion_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(
  rinvgauss(n = 50, mean = 1, dispersion = 1),
  rinvgauss(n = 50, mean = 1, dispersion = 3),
  rinvgauss(n = 50, mean = 1, dispersion = 4)
)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
inverse_gaussian_dispersion_one_way_test(x, fctr, .95)

Test the dispersion parameter of an inverse gaussian distribution.

Description

Test the dispersion parameter of an inverse gaussian distribution.

Usage

inverse_gaussian_dispersion_test(
  x,
  dispersion,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

x

a numeric vector of data.

dispersion

a number indicating the tested value of the dispersion parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)
library(statmod)

# Null is true
set.seed(1)
x <- rinvgauss(n = 100, mean = 1, dispersion = 2)
inverse_gaussian_dispersion_test(x, 2, "two.sided")

# Null is false
set.seed(1)
x <- rinvgauss(n = 100, mean = 1, dispersion = 2)
inverse_gaussian_dispersion_test(x, 1, "greater")

Test the equality of means of inverse gaussian distributions.

Description

Test the equality of means of inverse gaussian distributions.

Usage

inverse_gaussian_mu_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The shape parameter is assumed to be equal across all groups.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)
library(statmod)

# Null is true
set.seed(1)
x <- rinvgauss(n = 150, mean = 1, shape = 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
inverse_gaussian_mu_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(
  rinvgauss(n = 50, mean = 1, shape = 2),
  rinvgauss(n = 50, mean = 2, shape = 2),
  rinvgauss(n = 50, mean = 3, shape = 2)
)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
inverse_gaussian_mu_one_way_test(x, fctr, .95)

Test the mean of an inverse gaussian distribution.

Description

Test the mean of an inverse gaussian distribution.

Usage

inverse_gaussian_mu_test(x, mu, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

mu

a number indicating the tested value of mu.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)
library(statmod)

# Null is true
set.seed(1)
x <- rinvgauss(n = 100, mean = 1, shape = 2)
inverse_gaussian_mu_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rinvgauss(n = 100, mean = 3, shape = 2)
inverse_gaussian_mu_test(x, 1, "greater")

Test the equality of shape parameters of inverse gaussian distributions.

Description

Test the equality of shape parameters of inverse gaussian distributions.

Usage

inverse_gaussian_shape_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The means are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)
library(statmod)

# Null is true
set.seed(1)
x <- rinvgauss(n = 150, mean = 1, shape = 2)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
inverse_gaussian_shape_one_way_test(x, fctr, .95)

# Null is false
set.seed(2)
x <- c(
  rinvgauss(n = 50, mean = 1, shape = 1),
  rinvgauss(n = 50, mean = 1, shape = 3),
  rinvgauss(n = 50, mean = 1, shape = 4)
)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
inverse_gaussian_shape_one_way_test(x, fctr, .95)

Test the shape parameter of an inverse gaussian distribution.

Description

Test the shape parameter of an inverse gaussian distribution.

Usage

inverse_gaussian_shape_test(
  x,
  shape,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

x

a numeric vector of data.

shape

a number indicating the tested value of the shape parameter.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)
library(statmod)

# Null is true
set.seed(1)
x <- rinvgauss(n = 100, mean = 1, shape = 2)
inverse_gaussian_shape_test(x, 2, "two.sided")

# Null is false
set.seed(1)
x <- rinvgauss(n = 100, mean = 1, shape = 2)
inverse_gaussian_shape_test(x, 1, "greater")

Test the equality of means of log normal distributions.

Description

Test the equality of means of log normal distributions.

Usage

log_normal_mu_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The variance of the logged data is assumed to be equal across all groups.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rlnorm(150, 1, 1)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
log_normal_mu_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rlnorm(50, 1, 1), rlnorm(50, 2, 1), rlnorm(50, 3, 1))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
log_normal_mu_one_way_test(x, fctr, .95)

Test the mean of a log normal distribution.

Description

Test the mean of a log normal distribution.

Usage

log_normal_mu_test(x, mu, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

mu

a number indicating the tested value of mu.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rlnorm(100, 0, 1)
log_normal_mu_test(x, 0, "two.sided")

# Null is false
set.seed(1)
x <- rlnorm(100, 3, 1)
log_normal_mu_test(x, 0, "greater")

Test the equality of variance parameters of log normal distributions.

Description

Test the equality of variance parameters of log normal distributions.

Usage

log_normal_variance_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

The means of the logged data are treated as nuisance parameters and are estimated separately for each group.

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rlnorm(150, 1, 1)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
log_normal_variance_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rlnorm(50, 1, 1), rlnorm(50, 1, 2), rlnorm(50, 1, 3))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
log_normal_variance_one_way_test(x, fctr, .95)

Test the variance of a log normal distribution.

Description

Test the variance of a log normal distribution.

Usage

log_normal_variance_test(
  x,
  sigma.squared,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

x

a numeric vector of data.

sigma.squared

a number indicating the tested value of sigma squared.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rlnorm(100, 0, 1)
log_normal_variance_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rlnorm(100, 0, 2)
log_normal_variance_test(x, 1, "greater")

Test the equality of prob parameters of negative binomial distributions.

Description

Test the equality of prob parameters of negative binomial distributions.

Usage

negative_binomial_prob_one_way_test(
  num_failures,
  num_successes,
  fctr,
  conf.level = 0.95
)

Arguments

num_failures

a numeric vector indicating number of failures per group.

num_successes

a numeric vector indicating number of successes per group.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true.
set.seed(1)
num_failures <- rnbinom(3, 50, .5)
num_successes <- rep(50, length(num_failures))
fctr <- factor(1:length(num_failures))
negative_binomial_prob_one_way_test(num_failures, num_successes, fctr, .95)


# Null is false
set.seed(1)
num_failures <- rnbinom(3, 50, c(.25, .50, .75))
num_successes <- rep(50, length(num_failures))
fctr <- factor(1:length(num_failures))
negative_binomial_prob_one_way_test(num_failures, num_successes, fctr, .95)

Test the prob parameter of a negative binomial distribution.

Description

Test the prob parameter of a negative binomial distribution.

Usage

negative_binomial_prob_test(
  num_failures,
  num_successes,
  prob,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

num_failures

Number of failures.

num_successes

Number of successes.

prob

Hypothesized probability of success.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true. 48 failures before 52 successes.
negative_binomial_prob_test(48, 52, .50, "two.sided")

# Null is false. 25 failures before 75 successes.
negative_binomial_prob_test(25, 75, .50, "two.sided")

Test the equality of lambda parameters of poisson distributions.

Description

Test the equality of lambda parameters of poisson distributions.

Usage

poisson_lambda_one_way_test(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of data.

fctr

a factor vector indicating groups.

conf.level

overall confidence level of the likelihood intervals. Uses Bonferroni correction.

Details

Value

An S3 class containing the test statistic, p value, list of likelihood based confidence intervals, overall confidence level, individual confidence level of each interval and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rpois(150, 1)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
poisson_lambda_one_way_test(x, fctr, .95)

# Null is false
set.seed(1)
x <- c(rpois(50, 1), rpois(50, 2), rpois(50, 3))
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
poisson_lambda_one_way_test(x, fctr, .95)

Test the lambda parameter of a poisson distribution.

Description

Test the lambda parameter of a poisson distribution.

Usage

poisson_lambda_test(x, lambda, alternative = "two.sided", conf.level = 0.95)

Arguments

x

a numeric vector of data.

lambda

a number indicating the tested value of lambda

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the likelihood interval.

Value

An S3 class containing the test statistic, p value, likelihood based confidence interval, and alternative hypothesis.

Source

Examples

library(LRTesteR)

# Null is true
set.seed(1)
x <- rpois(100, 1)
poisson_lambda_test(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rpois(100, 2)
poisson_lambda_test(x, 1, "greater")

Print results of tests.

Description

Print results of tests.

Usage

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

Arguments

x

a test from LRTesteR.

...

arguments passed to other methods.

Value

x, invisibly. Called for the side effect of printing the test.

Examples

library(LRTesteR)

set.seed(1)
x <- rnorm(100, 0, 1)
test <- gaussian_mu_test(x, 0, "two.sided")
print(test)

set.seed(1)
x <- rnorm(150, 1, 1)
fctr <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
test <- gaussian_mu_one_way_test(x, fctr, .95)
print(test)