| Title: | Visualise the Results of Inferential Statistics using 'ggplot2' |
|---|---|
| Description: | 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. |
| Authors: | Charalampos Bratsas [aut], Anastasia Foudouli [aut], Kleanthis Koupidis [aut, cre] |
| Maintainer: | Kleanthis Koupidis <[email protected]> |
| License: | GPL-2 | file LICENSE |
| Version: | 0.1.3 |
| Built: | 2026-05-19 07:44:11 UTC |
| Source: | https://github.com/okgreece/gginference |
A data frame showing the use of seat belt and the driver status after a car accident in Greece.
accidentsDataaccidentsData
A data frame with 383 observations of 2 columns:
recordfactor representing the driver status
seatBeltfactor indicating whether the driver wore a seatbelt
The original data are available at Hellenic Statistical Authority
A data frame containing the number of births and deaths along with their rates from 1932 to 2016.
BirthDeathBirthDeath
A data frame with 71 observations of 5 columns:
Yearyears 1932-2016
Deathsnumber of deaths
DeathsRatenumber of deaths per 1000 citizen
Birthsnumber of births
BirthRatenumber of births per 1000 citizen
The original data are available at Hellenic Statistical Authority
A data frame containing samples with the number of births and deaths before and after 2000.
BirthDeath2000BirthDeath2000
A data frame with 30 observations of 3 columns:
deathsnumber of deaths
birthsnumber of births
typefactor indicating if the number of births and deaths correspond before 2000 or after 2000
The original data are available at Hellenic Statistical Authority
A data frame giving the number of births per 1000 people in Greece from 1976 to 1989.
birthsbirths
A data frame with 14 observations of 2 columns:
yearyears from 1976 to 1989
ratenumber of births per 1000 people
The original data are available at Hellenic Statistical Authority
A data frame including a sample of bio diesel and RON 95 consumption in Greece.
DieselbioRon95DieselbioRon95
A data frame with 24 observations of 5 columns:
regionfactor of Greek regions
DieselBio_consumption2006metric tons of bio-diesel consumption in 2006
DieselBio_consumption2016metric tons of bio-diesel consumption in 2016
RON95_consumption2006metric tons of ron 95 consumption in 2006
RON95_consumption2016metric tons of ron 95 consumption in 2016
The original data are available at Hellenic Statistical Authority
A data frame containing the fuel consumption in Greece.
FuelConsumptionFuelConsumption
A data frame with 50 observations of 8 columns:
Geographic.areafactor with geographic area of Greece
Regionsfactor with regions of Greece
Runitsfactor with regional units of Greece
RON95metric tons of ron 95 consumption
RON98_100metric tons of ron 98 consumption
DieselBiometric tons of bio diesel consumption
LPGmetric tons of liquefied petroleum gas consumption
DieselCmetric tons of heating oil consumption
The original data are available at Hellenic Statistical Authority
Visualise anova F-test to determine whether group means are equal
ggaov(t, alpha=0.05, colaccept="lightsteelblue1", colreject="grey84", colstat="navyblue")ggaov(t, alpha=0.05, colaccept="lightsteelblue1", colreject="grey84", colstat="navyblue")
t |
an object of class aov |
alpha |
alpha level for finding critical F value |
colaccept |
color for the acceptance region of the test |
colreject |
color for the area of rejection of the test |
colstat |
color of the statistic of the test line |
# 21-th day chick21 <- ChickWeight[ChickWeight$Time == 21, ] chickaov <- aov(weight ~ Diet, data = chick21) summary(chickaov) ggaov(chickaov, colaccept = "grey89", colreject = "black")# 21-th day chick21 <- ChickWeight[ChickWeight$Time == 21, ] chickaov <- aov(weight ~ Diet, data = chick21) summary(chickaov) ggaov(chickaov, colaccept = "grey89", colreject = "black")
Visualise chi-squared contingency table tests and goodness-of-fit tests.
ggchisqtest(t, colaccept="lightsteelblue1", colreject="gray84", colstat="navyblue", alpha=0.05)ggchisqtest(t, colaccept="lightsteelblue1", colreject="gray84", colstat="navyblue", alpha=0.05)
t |
a list result of |
colaccept |
color the acceptance area of the test |
colreject |
color for the rejection area of the test |
colstat |
color for the test statistic vline |
alpha |
default set to 0.05, choose confidence level for the plot as it is not stated in chisqtest |
## Chi-squared test for given probabilities x <- c(A = 20, B = 15, C = 25) chisq_test <- chisq.test(x) chisq_test ggchisqtest(chisq_test) x <- c(10, 86, 45, 38, 10) p <- c(0.10, 0.40, 0.20, 0.20, 0.10) chisq_test2 <- chisq.test(x, p = p) chisq_test2 ggchisqtest(chisq_test2) ## Pearson's Chi-squared test library(MASS) sex_smoke <- table(survey$Sex, survey$Smoke) chisq_test3 <- chisq.test(sex_smoke) chisq_test3 ggchisqtest(chisq_test3)## Chi-squared test for given probabilities x <- c(A = 20, B = 15, C = 25) chisq_test <- chisq.test(x) chisq_test ggchisqtest(chisq_test) x <- c(10, 86, 45, 38, 10) p <- c(0.10, 0.40, 0.20, 0.20, 0.10) chisq_test2 <- chisq.test(x, p = p) chisq_test2 ggchisqtest(chisq_test2) ## Pearson's Chi-squared test library(MASS) sex_smoke <- table(survey$Sex, survey$Smoke) chisq_test3 <- chisq.test(sex_smoke) chisq_test3 ggchisqtest(chisq_test3)
Visualise test for association between paired samples, using Pearson's product moment correlation coefficient.
ggcortest(t, colaccept="lightskyblue1", colreject="grey94", colstat="navy")ggcortest(t, colaccept="lightskyblue1", colreject="grey94", colstat="navy")
t |
a list result of |
colaccept |
color the acceptance area of the test |
colreject |
color for the rejection area of the test |
colstat |
color for the test statistic vline |
corr_test <- cor.test(iris$Sepal.Length, iris$Sepal.Width) corr_test ggcortest(corr_test)corr_test <- cor.test(iris$Sepal.Length, iris$Sepal.Width) corr_test ggcortest(corr_test)
Visualise prop.test for testing the null that the proportions
(probabilities of success) in several groups are the same, or that they
equal certain given values.
ggproptest(t, alpha=0.05,colaccept="lightsteelblue1", colreject="gray84", colstat="navyblue")ggproptest(t, alpha=0.05,colaccept="lightsteelblue1", colreject="gray84", colstat="navyblue")
t |
a list result of |
alpha |
alpha level for ploting distribution, when prop.test is used on more than 2 samples |
colaccept |
color the acceptance area of the test |
colreject |
color for the rejection area of the test |
colstat |
color for the test statistic vline |
x <- c(5, 8, 12) y <- c(8, 9, 13) pr_test <- prop.test(x, y) pr_test ggproptest(pr_test)x <- c(5, 8, 12) y <- c(8, 9, 13) pr_test <- prop.test(x, y) pr_test ggproptest(pr_test)
Visualise one and/or two sample t-tests on vectors of data.
ggttest(t, colaccept="lightsteelblue1", colreject="grey84", colstat="navyblue")ggttest(t, colaccept="lightsteelblue1", colreject="grey84", colstat="navyblue")
t |
a list result of |
colaccept |
color the acceptance area of the test |
colreject |
color for the rejection area of the test |
colstat |
color for the test statistic vline |
t_test <- t.test(sleep$extra ~ sleep$group) t_test ggttest(t_test) t_test2 <- t.test(x = 1:10, y = c(7:20)) t_test2 ggttest(t_test2)t_test <- t.test(sleep$extra ~ sleep$group) t_test ggttest(t_test) t_test2 <- t.test(x = 1:10, y = c(7:20)) t_test2 ggttest(t_test2)
Visualise F test to compare two variances
ggvartest(t, colaccept = "lightsteelblue1", colreject = "gray84", colstat = "navyblue")ggvartest(t, colaccept = "lightsteelblue1", colreject = "gray84", colstat = "navyblue")
t |
a list result of |
colaccept |
color the acceptance area of the test, see
|
colreject |
color for the rejection area of the test |
colstat |
color for the test statistic vline |
x <- rnorm(50, mean = 0, sd = 2) y <- rnorm(30, mean = 1, sd = 1) var_test <- var.test(x, y) var_test ggvartest(var_test)x <- rnorm(50, mean = 0, sd = 2) y <- rnorm(30, mean = 1, sd = 1) var_test <- var.test(x, y) var_test ggvartest(var_test)
A data frame that contains sample ratings of 18 laptops, by three experts.
LaptopRatesLaptopRates
A data frame with 54 observations of 3 columns:
laptoplaptop id, 1-18
experta character of expert1,expert2,expert3 values
ratingratings-5 likert scale, 5 indicates a very good rate
A data frame containing a sample with the results of neuropsychological assessment before and after serious game intervention in the living lab, Thess-AHALL (Thessaloniki Active and Healthy Aging Living Lab) of Medical Physics Laboratory of Aristotle University of Thessaloniki.
LivLabLivLab
A data frame with 10 observations of 2 columns:
beforescore in a neuropsychological test before serious game intervention
afterscore in a neuropsychological test after serious game intervention
<http://aha-livinglabs.com/>
A data frame with the volume of new stores by category for urban, suburban and rural areas.
m_anovam_anova
A data frame with 54 observations of 4 columns:
Categoriesinteger representing three categories
UrbanAreascoding for urban, suburban and rural areas
Monthinteger representing three months
Volumevolume in cubic meters
The original data are available at Hellenic Statistical Authority
A data frame containing a sample of the number of cow, sheep and goat milk bottles sold.
MilkConsumptionMilkConsumption
A data frame with 13 observations of 3 columns:
Cow.Milknumber of cow milk bottles
Sheep.Milknumber of sheep milk bottles
Goat.Milknumber of goat milk bottles
The original data are available at Hellenic Statistical Authority
A data frame with the profits of some companies for 5 months, constructed for teaching purposes.
profits_dfprofits_df
A data frame with 26 companies (rows) of 5 months (columns).
A data frame containing a sample with the answers of students.
questionnairequestionnaire
A data frame with 50 observations of 8 columns:
genderA factor with the student gender
writing.handA factor with the writing hand of the students (left, right)
fold.armA factor with the top hand when the students fold their arms
pulseInteger with the pulse rate of students (beats per minute)
exerciseA factor with the frequency the students exercises (none, some,frequently)
smokeA factor with the frequency the students smokes (heavy, regularly, occasionally, never)
heightInteger with the height of the students (in centimeters)
ageInteger with the age of the students
A data frame with 128 sample results of a repeated experiment. Success is noted with 1 and failure with 0.
randexperimentrandexperiment
A data frame with 128 observations of 1 column.
A sample data frame with female and male salaries of a company.
Salary_GenderSalary_Gender
A data frame with 100 observations of 2 columns:
Male_salmale salaries
Female_salfemale salaries