As an introduction, lets start with one way ANOVA. Here 3 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)
<- c(rnorm(50, 1, 1), rnorm(50, 3, 1), rnorm(50, 5, 1))
x <- c(rep(1, 50), rep(2, 50), rep(3, 50))
fctr <- factor(fctr, levels = c("1", "2", "3"))
fctr gaussian_mu_one_way(x, fctr, conf.level = 0.95)
#> [1] "Likelihood Statistic: 205.77"
#> [1] "p value: 0"
#> [1] "Confidence Level Of Set: 95%"
#> [1] "Individual Confidence Level: 98.3%"
#> [1] "Confidence Interval For Group 1: (0.814, 1.387)"
#> [1] "Confidence Interval For Group 2: (2.783, 3.452)"
#> [1] "Confidence Interval For Group 3: (4.537, 5.158)"
Here 2 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)
<- c(rcauchy(50, 2, 1), rcauchy(50, 2, 3))
x <- c(rep(1, 50), rep(2, 50))
fctr <- factor(fctr, levels = c("1", "2"))
fctr cauchy_scale_one_way(x, fctr, conf.level = 0.95)
#> [1] "Likelihood Statistic: 18.2"
#> [1] "p value: 0"
#> [1] "Confidence Level Of Set: 95%"
#> [1] "Individual Confidence Level: 97.5%"
#> [1] "Confidence Interval For Group 1: (0.715, 1.71)"
#> [1] "Confidence Interval For Group 2: (2.388, 5.612)"
Here 4 poisson random variables with different lambdas are created. The null hypothesis is
\[ H_{0}: \lambda_1 = \lambda_2 = \lambda_3 = \lambda_4 \]
set.seed(1)
<- c(rpois(50, 1), rpois(50, 2), rpois(50, 3), rpois(50, 4))
x <- c(rep(1, 50), rep(2, 50), rep(3, 50), rep(4, 50))
fctr <- factor(fctr, levels = c("1", "2", "3", "4"))
fctr poisson_lambda_one_way(x, fctr, conf.level = 0.95)
#> [1] "Likelihood Statistic: 107.3"
#> [1] "p value: 0"
#> [1] "Confidence Level Of Set: 95%"
#> [1] "Individual Confidence Level: 98.8%"
#> [1] "Confidence Interval For Group 1: (0.753, 1.49)"
#> [1] "Confidence Interval For Group 2: (1.524, 2.519)"
#> [1] "Confidence Interval For Group 3: (2.519, 3.764)"
#> [1] "Confidence Interval For Group 4: (3.444, 4.879)"
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 common across groups. Some 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.