An open API service indexing awesome lists of open source software.

https://github.com/okgreece/gginference

Visualise the Results of Inferential Statistics using 'ggplot2'
https://github.com/okgreece/gginference

ggplot2 inferential-statistics

Last synced: 9 months ago
JSON representation

Visualise the Results of Inferential Statistics using 'ggplot2'

Awesome Lists containing this project

README

          

README
================

[![R-CMD-check](https://github.com/okgreece/gginference/workflows/R-CMD-check/badge.svg)](https://github.com/okgreece/gginference/actions)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/gginference)](https://cran.r-project.org/package=gginference)
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![](http://cranlogs.r-pkg.org/badges/grand-total/gginference)](http://cran.rstudio.com/web/packages/gginference/index.html)
[![Licence](https://img.shields.io/badge/licence-GPL--2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1745505.svg)](https://doi.org/10.5281/zenodo.1745505)

# Overview

Visualise the results of F test to compare two variances, Student’s
t-test, test of equal or given proportions, Pearson’s chi-squared test
for count data and test for association/correlation between paired
samples.

# Installation

``` r
# CRAN installation:
install.packages("gginference")

# Or the development version from GitHub:
# install.packages("devtools")
devtools::install_github("okgreece/gginference")
```

# Usage

## One sample

### One sample t-test with normal population and σ2 unknown

The rejection regions for one sample t-test with normal population and
σ2 unknown are calculated using `ggttest` function. The
following table shows the rejection regions which is calculated with
**gginference** depending the specified parameters in `t.test`.

H0
H1
Rejection Region of gginference
Parameters of t.test

μ = μ0
μ < μ0
R = {z <  − za}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “less”

μ > μ0
R = {z > za}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “greater”

μ ≠ μ0
R = {|z| > za/2}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “two.sided”

where

![](readme_formula/1_One_sample_t-test_large.png)

### One sample t-test with normal population and n \< 30 and σ2 unknown

`ggttest` is also used to calculate rejection region for one sample
t-test with normal population and n \< 30 and σ2 unknown.

H0
H1
Rejection Region of gginference
Parameters of t.test

μ = μ0
μ < μ0
R = {t <  − tn − 1, a}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “less”

μ > μ0
R = {t > tn − 1, a}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “greater”

μ ≠ μ0
R = {|t| > tn − 1, a/2}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “two.sided”

where

![](readme_formula/2_One_sample_t-test_small.png)

## Two samples

### Two independent samples t-test with normal populations and σ12 = σ22 unknown

Next table shows the rejection regions of two independent samples t-test
with normal populations and σ12 =
σ22. `ggttest` is also used to visualize this
test.

H0
H1
Rejection Region of gginference
Parameters of t.test

μ1 − μ2 = d0
μ1 − μ2 < d0
R = {t <  − tn1 + n2 − 2, a}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = TRUE,


  • alternative = “less”

μ1 − μ2 > d0
R = {t > tn1 + n2 − 2, a}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = TRUE,


  • alternative = “greater”

μ1 − μ2 ≠ d0
R = {|t| > tn1 + n2 − 2, a/2}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = TRUE,


  • alternative = “two.sided”

where

![](readme_formula/3_Two_samples_t-test_equal_var.png)

### Two independent samples t-test with normal populations and σ12 ![](readme_formula/uneq.png) σ22

`ggttest` is used to visualize two independent samples t-test with
normal populations and σ12
![](readme_formula/uneq.png) σ22. The following
table shows the rejection regions of this test.

H0
H1
Rejection Region of gginference
Parameters of t.test

μ1 − μ2 = d0
μ1 − μ2 < d0
R = {t <  − tν, a}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “less”

μ1 − μ2 > d0
R = {t > tν, a}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “greater”

μ1 − μ2 ≠ d0
R = {|t| > tν, a/2}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “two.sided”

where

![](readme_formula/4_Two_samples_t-test_unequal_var.png)

and ν degrees of freedom with

![](readme_formula/4b_Two_samples_t-test_unequal_var_deg_freed.png)

## Paired samples with normal population

`ggttest` is used also to visualize the results of the paired sample
Student’s t-test. Next table shows th rejection region of this test.

H0
H1
Rejection Region of gginference
Parameters of t.test

μ1 − μ2 = d0
μ1 − μ2 < d0
R = {t <  − tn − 1, a}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “less”

μ1 − μ2 > d0
R = {t > tn − 1, a}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “greater”

μ1 − μ2 ≠ d0
R = {|t| > tn − 1, a/2}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “two.sided”

where

![](readme_formula/5a_Paired%20samples.png)

![](readme_formula/5b_Paired%20samples.png)

![](readme_formula/5c_Paired%20samples.png)

## Proportion test

### One-proportion z-test

`ggproptest()` is used to visualize one-proportion z-test. The rejection
regions are shown below.

H0
H1
Rejection Region of gginference
Parameters of prop.test()

p = p0
p < p0
R = {z <  − za}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “less”

p > p0
R = {z > za}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “greater”

p ≠ p0
R = {|z| > za/2}



  • x = vector of sample data,


  • mu = μ0,


  • alternative = “two.sided”

where

![](readme_formula/6a_one_proportion.png)

![](readme_formula/6b_one_proportion.png)

### Two-proportion z-test

The results of two-proportion z-test are visualized using `ggproptest()`
and next table shows the rejection regions.

H0
H1
Rejection Region of gginference
Parameters of prop.test()

p1 − p2 = d0
p1 − p2 < d0
R = {z <  − za}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “less”

p1 − p2 > d0
R = {z > za}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “greater”

p1 − p2 ≠ d0
R = {|z| > za/2}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • paired = FALSE,


  • var.equal = FALSE,


  • alternative = “two.sided”

where

![](readme_formula/7a_two_proportions.png)

![](readme_formula/7b_two_proportions.png)

![](readme_formula/7c_two_proportions.png)

![](readme_formula/7d_two_proportions.png)

## Two-sample F test for equality of variances

`ggvartest` is used to visualize the results of the paired sample
Student’s t-test. The rejection region that is used in this test is
shown below.

H0
H1
Rejection Region of gginference
Parameters of var.test

σ12 / σ22 = 1
σ12 / σ22 < 1
R = {F > Fn1 − 1, n2 − 1, 1 − a}



  • x = vector of sample 1 data,


  • y = vector of sample 2 data,


  • ratio = 1


  • alternative = “less”

σ12 / σ22 > 1
R = {F > Fn1 − 1, n2 − 1, a}



  • x = vector of sample data,


  • mu = μ0,


  • ratio = 1


  • alternative = “greater”

σ12 / σ22 1
R = {F > Fn1 − 1, n2 − 1, a/2}



  • x = vector of sample data,


  • mu = μ0,


  • ratio = 1


  • alternative = “two.sided”

where

![](readme_formula/8_test_cor.png)

## Test for Correlation Between Paired Samples

`ggcortest` is usesd to visualize the results of test for correlation
between paired samples. The following table shows the rejection region
of this test.

H0
H1
Rejection Region of gginference
Parameters of cor.test

𝜚 = 0
𝜚 ≠ 0
R = {|t| > tn − 2, a/2}



  • x = vector of sample 1 data


  • y = vector of sample 2 data,


  • alternative = “two.sided”

where

![](readme_formula/8_test_cor.png)

## Chi-squared Test of Independence

The results of Pearson’s chi-squared test for count data are visulized
using `ggchisqtest`. Next table shows the rejection region of this test.

H0
H1
Rejection Region of gginference
Parameters of chisq.test

Two variables are independent
Two variables are not independent
R = {X2 > χa/22}



  • x = 2-dimensional contingency table

where

![](readme_formula/9_chisq.png)

## ANOVA F-test

`ggaov` is used to visualize the results of ANOVA F-test. Table below
shows rejection region of Anova F-stest.

H0
H1
Rejection Region of gginference
Parameters of aov

H0 : μ1 = μ2= ... = μk
Not all three population means are equal
R = {F > Fk − 1, n − k, a}



  • formula = formula specifying the model


  • data = data frame with the variables specified in the formula

where

![](readme_formula/10_anova.png)

# Getting help

If you encounter a bug, please feel free to open an
[issue](https://github.com/okgreece/gginference/issues) with a minimal
reproducible example.