Analysis of Deviance

Classic One-Way ANOVA

As an introduction, lets start with one way ANOVA. Here three random variables following a normal distribution with a common standard deviation are created. For this test, the null hypothesis is

\[ H_{0}: \mu_0 = \mu_1 = \mu_2 \]

library(LRTesteR)

set.seed(1)
x <- c(
  rnorm(n = 50, mean = 1, sd = 1),
  rnorm(n = 50, mean = 3, sd = 1),
  rnorm(n = 50, mean = 5, sd = 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 = x, fctr = fctr, conf.level = 0.95)
#> Log Likelihood Statistic: 205.77
#> p value: 0
#> Confidence Level Of Set: 95%
#> Individual Confidence Level: 98.3%
#> Confidence Interval For Group 1: (0.814, 1.387)
#> Confidence Interval For Group 2: (2.783, 3.452)
#> Confidence Interval For Group 3: (4.537, 5.158)

Cauchy Random Variables

Here two random variables following a Cauchy distribution with a common location and different scales are created. For this test, the null hypothesis is

\[ H_{0}: \gamma_0 = \gamma_1 \]

set.seed(1)
x <- c(rcauchy(n = 50, location = 2, scale = 1), rcauchy(n = 50, location = 2, scale = 3))
fctr <- c(rep(1, 50), rep(2, 50))
fctr <- factor(fctr, levels = c("1", "2"))
cauchy_scale_one_way(x = x, fctr = fctr, conf.level = 0.95)
#> Log Likelihood Statistic: 18.2
#> p value: 0
#> Confidence Level Of Set: 95%
#> Individual Confidence Level: 97.5%
#> Confidence Interval For Group 1: (0.715, 1.71)
#> Confidence Interval For Group 2: (2.388, 5.612)

Poisson Random Variables

Here three poisson random variables with different lambdas are created. The null hypothesis is

\[ H_{0}: \lambda_0 = \lambda_1 = \lambda_2 \]

set.seed(1)
x <- c(rpois(n = 50, lambda = 1), rpois(n = 50, lambda = 2), rpois(n = 50, lambda = 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 = x, fctr = fctr, conf.level = 0.95)
#> Log Likelihood Statistic: 51.11
#> p value: 0
#> Confidence Level Of Set: 95%
#> Individual Confidence Level: 98.3%
#> Confidence Interval For Group 1: (0.765, 1.471)
#> Confidence Interval For Group 2: (1.541, 2.495)
#> Confidence Interval For Group 3: (2.541, 3.735)

Mathematical Details

All one way tests have a null hypothesis the groups share a common value of the parameter. The alternative is at least one group’s parameter is unequal to the others. If the test involves a nuisance parameter, it is assumed equal across groups for parametric tests. Some parametric tests are more robust against violations of this assumption than others.

All functions apply the Bonferroni correction to the set of confidence intervals. To have accurate coverage rates, each group requires 50 data points or more.