We first compare tooth length of guinea pigs by the type of supplement given: Ascorbic Acid and Orange Juice. We assume that there is no difference in the mean length of teeth. Second we compare tooth length by dosage size: 0.5, 1.0, and 2.0 mg/day. We also assume that there is no difference in tooth length when comparing dosage size.
We do assume the data is normally distributed, the sample sizes are large enough.
| supp | mean | variance |
|---|---|---|
| Ascorbic Acid | 16.963 | 68.327 |
| Orange Juice | 20.663 | 43.633 |
| supp | dose | mean | variance |
|---|---|---|---|
| Ascorbic Acid | 0.5 | 7.98 | 7.544 |
| Ascorbic Acid | 1.0 | 16.77 | 6.327 |
| Ascorbic Acid | 2.0 | 26.14 | 23.018 |
| Orange Juice | 0.5 | 13.23 | 19.889 |
| Orange Juice | 1.0 | 22.70 | 15.296 |
| Orange Juice | 2.0 | 26.06 | 7.049 |
| supp | mean | variance |
|---|---|---|
| Ascorbic Acid | 7.98 | 7.544 |
| Orange Juice | 13.23 | 19.889 |
| supp | mean | variance |
|---|---|---|
| Ascorbic Acid | 16.77 | 6.327 |
| Orange Juice | 22.70 | 15.296 |
| supp | mean | variance |
|---|---|---|
| Ascorbic Acid | 26.14 | 23.018 |
| Orange Juice | 26.06 | 7.049 |
Each confidence interval below was tested at 95%.
Supplement interval: -7.571, 0.171
This result suggests that there is not a significant difference in tooth growth when comparing supplements using any size dosage
0.5 mg/day interval: 1.719, 8.781
Since both values are positive (the interval does not contain zero) then there is significant evidence to suggest that tooth growth increased when using 0.5 mg/day of Ascorbic Acid.
1.0 mg/day interval: -9.058, -2.802
Here both values are negative and suggests there is a significant difference in tooth growth rates when using Orange Juice to deliver the supplement at the 1.0 mg/day rate.
2.0 mg/day interval: -3.638, 3.798
When comparing Ascorbic Acid to Orange Juice supplements this interval contains the value of zero. Therefore there is not sufficient evidence to suggest there is a difference in tooth growth rates at the 2.0 mg/day rate.
In the analysis of the Tooth Growth data in guinea pigs we found that there was a not a significant difference in tooth growth rates when comparing the way the supplement was delivered. However, when we looked at the size of each dosage we determined that higher rates of growth occurred in the 0.5 mg/day when using Ascorbic Acid to deliver the supplement. When looking at 1.0 mg/day dosage rates the conclusion was that Orange Juice provided the higher rates of tooth growth rates. Finally, when comparing growth rates at the 2.0 mg/day dosage we determined there was no significant difference between Orange Juice and Ascorbic Acid.
library(dplyr)
library(datasets)
library(rmarkdown)
library(tinytex)
library(ggplot2)
ToothGrowth$supp <- gsub("OJ", "Orange Juice", ToothGrowth$supp)
ToothGrowth$supp <- gsub("VC", "Ascorbic Acid", ToothGrowth$supp)
supp_data <- ToothGrowth %>% group_by(supp) %>%
summarize(mean = round(mean(len),3),
variance = round(var(len),3),
.groups = "drop")
dose_data <- ToothGrowth %>% group_by(supp,dose) %>%
summarize(mean = round(mean(len),3),
variance = round(var(len),3),
.groups = "drop")
OJ_group <- ToothGrowth %>%
filter(supp == "Orange Juice")
OJ_summary <- summary(OJ_group$len)
VC_group <- ToothGrowth %>%
filter(supp == "Ascorbic Acid")
VC_summary <- summary(VC_group$len)
half_mg_dose <- ToothGrowth %>% filter(dose == 0.5)
half_summary <- half_mg_dose %>%
group_by(supp) %>%
summarise(mean = round(mean(len),3),
variance = round(var(len),3),
.groups = "drop")
full_mg_dose_group <- ToothGrowth %>% filter(dose == 1.0)
full_summary <- full_mg_dose_group %>%
group_by(supp) %>%
summarise(mean = round(mean(len),3),
variance = round(var(len),3),
.groups = "drop")
double_mg_dose_group <- ToothGrowth %>% filter(dose == 2.0)
double_summary <- double_mg_dose_group %>%
group_by(supp) %>%
summarise(mean = round(mean(len),3),
variance = round(var(len),3),
.groups = "drop")
knitr::kable(supp_data, caption = "Supplement Data")
knitr::kable(dose_data, caption = "Dosage Data")
knitr::kable(half_summary, caption = "0.5 mg/day summary")
knitr::kable(full_summary, caption = "1.0 mg/day summary")
knitr::kable(double_summary, caption = "2.0 mg/day summary")
ggplot(ToothGrowth, aes(supp,len, fill = supp)) +
geom_boxplot() +
labs(title = "Tooth Growth in Guinea Pigs by Supplement",
x = "Supplement",y = "Tooth Length")
ggplot(ToothGrowth, aes(factor(dose),len, fill = factor(dose))) +
geom_boxplot() +
labs(title = "Tooth Growth by Dosage Size",
x = "Dosage (in mg/day)", y = "Tooth Length") +
scale_fill_discrete(name = "Dose")
supp_CI <- round(t.test(VC_group$len,OJ_group$len)$conf,3)
VC_half_group <- half_mg_dose %>% filter(supp == "Ascorbic Acid")
OJ_half_group <- half_mg_dose %>% filter(supp == "Orange Juice")
half_CI <- round(t.test(OJ_half_group$len, VC_half_group$len)$conf,3)
VC_full_group <- full_mg_dose_group %>% filter(supp == "Ascorbic Acid")
OJ_full_group <- full_mg_dose_group %>% filter(supp == "Orange Juice")
full_CI <- round(t.test(VC_full_group$len,OJ_full_group$len)$conf,3)
VC_double_group <- double_mg_dose_group %>% filter(supp == "Ascorbic Acid")
OJ_double_group <- double_mg_dose_group %>% filter(supp == "Orange Juice")
double_CI <- round(t.test(VC_double_group$len,OJ_double_group$len)$conf,3)