Package 'LRTesteR'

Title: Likelihood Ratio Tests and Confidence Intervals
Description: A collection of hypothesis tests and confidence intervals based on the likelihood ratio <https://en.wikipedia.org/wiki/Likelihood-ratio_test>.
Authors: Greg McMahan [aut, cre]
Maintainer: Greg McMahan <[email protected]>
License: GPL-3
Version: 1.2.1
Built: 2024-11-07 05:43:29 UTC
Source: https://github.com/gmcmacran/lrtester

Help Index


Test the shape1 parameter of a beta distribution.

Description

Test the shape1 parameter of a beta distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

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

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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All shape1s are equal. (shape1_1 = shape1_2 ... shape1_k).

  • Alternative: At least one shape1 is not equal.

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(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(x, fctr, .95)

Test the shape2 parameter of a beta distribution.

Description

Test the shape2 parameter of a beta distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rbeta(100, shape1 = 1, shape2 = 3)
beta_shape2_one_sample(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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All shape2s are equal. (shape2_1 = shape2_2 ... shape2_k).

  • Alternative: At least one shape2 is not equal.

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(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(x, fctr, .95)

Test the p parameter of a binomial distribution.

Description

Test the p parameter of a binomial distribution.

Usage

binomial_p_one_sample(x, n, p, alternative = "two.sided", conf.level = 0.95)

Arguments

x

Number of successes.

n

Number of trials.

p

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_p_one_sample(52, 100, .50, "two.sided")

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

Test the equality of p parameters of binomial distributions.

Description

Test the equality of p parameters of binomial distributions.

Usage

binomial_p_one_way(x, n, fctr, conf.level = 0.95)

Arguments

x

a numeric vector indicating number of successes per group.

n

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.

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)
n <- rep(50, length(x))
fctr <- factor(1:length(x))
binomial_p_one_way(x, n, fctr, .95)

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

Test the location parameter of a cauchy distribution.

Description

Test the location parameter of a cauchy distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

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

Test the equality of location parameters of cauchy distributions.

Description

Test the equality of location parameters of cauchy distributions.

Usage

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

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • All locations are equal. (location_1 = location_2 ... location_k).

  • Alternative: At least one location is not equal.

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, 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(x, fctr, .95)

# Null is false
set.seed(1)
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(x, fctr, .95)

Test the scale parameter of a cauchy distribution.

Description

Test the scale parameter of a cauchy distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 2, "two.sided")

# Null is false
set.seed(1)
x <- rcauchy(n = 100, location = 3, scale = 2)
cauchy_scale_one_sample(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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All scales are equal. (scale_1 = scale_2 ... scale_k).

  • Alternative: At least one scale is not equal.

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(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(x, fctr, .95)

Test the mean parameter of an unknown distribution.

Description

Test the mean parameter of an unknown distribution.

Usage

empirical_mu_one_sample(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

  • Yudi Pawitan. In All Likelihood. Oxford University Press.

  • Owen. Empirical Likelihood. Chapman & Hall/CRC.

Examples

library(LRTesteR)

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

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

Test the equality of means of an unknown distribution.

Description

Test the equality of means of an unknown distribution.

Usage

empirical_mu_one_way(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

  • Null: All mus are equal. (mu1 = mu2 ... muk).

  • Alternative: At least one mu is not equal.

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

  • Yudi Pawitan. In All Likelihood. Oxford University Press.

  • Owen. Empirical Likelihood. Chapman & Hall/CRC.

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(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(x, fctr, .95)

Test a quantile of an unknown distribution.

Description

Test a quantile of an unknown distribution.

Usage

empirical_quantile_one_sample(
  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

  • Yudi Pawitan. In All Likelihood. Oxford University Press.

  • Owen. Empirical Likelihood. Chapman & Hall/CRC.

Examples

library(LRTesteR)

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

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

Test the equality of a quantile from an unknown distribution.

Description

Test the equality of a quantile from an unknown distribution.

Usage

empirical_quantile_one_way(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

  • Null: Quantiles are equal. (Q1 = Q2 ... Qk).

  • Alternative: At least one quantile is not equal.

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

  • Yudi Pawitan. In All Likelihood. Oxford University Press.

  • Owen. Empirical Likelihood. Chapman & Hall/CRC.

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(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(x, .50, fctr, .95)

Test the rate parameter of a exponential distribution.

Description

Test the rate parameter of a exponential distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

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

Test the equality of rate parameters of exponential distributions.

Description

Test the equality of rate parameters of exponential distributions.

Usage

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

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All lambdas are equal. (lambda_1 = lambda_2 ... lambda_k).

  • Alternative: At least one lambda is not equal.

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(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(x, fctr, .95)

Test the rate parameter of a gamma distribution.

Description

Test the rate parameter of a gamma distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rgamma(100, shape = 1, rate = 2)
gamma_rate_one_sample(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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All rates are equal. (rate_1 = rate_2 ... rate_k).

  • Alternative: At least one rate is not equal.

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(x, fctr, .95)

# Null is false
set.seed(1)
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(x, fctr, .95)

Test the scale parameter of a gamma distribution.

Description

Test the scale parameter of a gamma distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 2, "two.sided")

# Null is false
set.seed(1)
x <- rgamma(100, shape = 1, scale = 2)
gamma_scale_one_sample(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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: Null: All scales are equal. (scale_1 = scale_2 ... scale_k).

  • Alternative: At least one scale is not equal.

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(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(x, fctr, .95)

Test the shape parameter of a gamma distribution.

Description

Test the shape parameter of a gamma distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rgamma(100, shape = 3, scale = 2)
gamma_shape_one_sample(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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All shapes are equal. (shape_1 = shape_2 ... shape_k).

  • Alternative: At least one shape is not equal.

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(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(x, fctr, .95)

Test the mean of a gaussian distribution.

Description

Test the mean of a gaussian distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 0, "two.sided")

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

Test the equality of means of gaussian distributions.

Description

Test the equality of means of gaussian distributions.

Usage

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

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All mus are equal. (mu1 = mu2 ... muk).

  • Alternative: At least one mu is not equal.

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(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(x, fctr, .95)

Test the variance of a gaussian distribution.

Description

Test the variance of a gaussian distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rnorm(100, 0, 2)
gaussian_variance_one_sample(x, 1, "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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All variances are equal. (o^2_1 = o^2_2 ... o^2_k).

  • Alternative: At least one variance is not equal.

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(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(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_one_sample(
  x,
  dispersion,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 2, "two.sided")

# Null is false
set.seed(1)
x <- rinvgauss(n = 100, mean = 1, dispersion = 2)
inverse_gaussian_dispersion_one_sample(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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: Null: All dispersion parameters are equal. (dispersion_1 = dispersion_2 ... dispersion_k).

  • Alternative: At least one dispersion is not equal.

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(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(x, fctr, .95)

Test the mean of an inverse gaussian distribution.

Description

Test the mean of an inverse gaussian distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

# Null is false
set.seed(1)
x <- rinvgauss(n = 100, mean = 3, shape = 2)
inverse_gaussian_mu_one_sample(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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: All mus are equal. (mu1 = mu2 ... muk).

  • Alternative: At least one mu is not equal.

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(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(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_one_sample(
  x,
  shape,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 2, "two.sided")

# Null is false
set.seed(1)
x <- rinvgauss(n = 100, mean = 1, shape = 2)
inverse_gaussian_shape_one_sample(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(x, fctr, conf.level = 0.95)

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • Null: Null: All shapes are equal. (shape_1 = shape_2 ... shape_k).

  • Alternative: At least one shape is not equal.

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(x, fctr, .95)

# Null is false
set.seed(1)
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(x, fctr, .95)

Test the p parameter of a negative binomial distribution.

Description

Test the p parameter of a negative binomial distribution.

Usage

negative_binomial_p_one_sample(
  num_failures,
  num_successes,
  p,
  alternative = "two.sided",
  conf.level = 0.95
)

Arguments

num_failures

Number of failures.

num_successes

Number of successes.

p

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_p_one_sample(48, 52, .50, "two.sided")

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

Test the equality of p parameters of negative binomial distributions.

Description

Test the equality of p parameters of negative binomial distributions.

Usage

negative_binomial_p_one_way(
  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.

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_p_one_way(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_p_one_way(num_failures, num_successes, fctr, .95)

Test the lambda parameter of a poisson distribution.

Description

Test the lambda parameter of a poisson distribution.

Usage

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

Arguments

x

a numeric vector of at least 50 data values.

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_one_sample(x, 1, "two.sided")

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

Test the equality of lambda parameters of poisson distributions.

Description

Test the equality of lambda parameters of poisson distributions.

Usage

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

Arguments

x

a numeric vector of at least 50 data values per group.

fctr

a factor vector indicating groups.

conf.level

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

Details

  • All lambdas are equal. (lambda_1 = lambda_2 ... lambda_k).

  • Alternative: At least one lambda is not equal.

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(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(x, fctr, .95)

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.

Examples

library(LRTesteR)

set.seed(1)
x <- rnorm(100, 0, 1)
test <- gaussian_mu_one_sample(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(x, fctr, .95)
print(test)