You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: "Analysis of ToothGrowth data in the R datasets package"
3
+
author: "Carlos Hernández"
4
+
date: "25/9/2020"
5
+
output:
6
+
pdf_document:
7
+
latex_engine: xelatex
8
+
highlight: espresso
9
+
toc: true
10
+
toc_depth: 4
11
+
---
12
+
13
+
```{r setup, include=FALSE}
14
+
knitr::opts_chunk$set(echo = TRUE)
15
+
```
16
+
17
+
## ToothGrowth Dataset
18
+
19
+
ToothGrowth data set contains the result from an experiment studying the effect of vitamin C on tooth growth in 60 Guinea pigs. Each animal received one of three dose levels of vitamin C (0.5, 1, and 2 mg/day) by one of two delivery methods, orange juice or ascorbic acid (a form of vitamin C and coded as VC).
20
+
21
+
```{r ToothGrowth }
22
+
library(kableExtra)
23
+
head(ToothGrowth,5) %>%
24
+
kbl() %>%
25
+
kable_material(c("striped", "hover"))
26
+
27
+
```
28
+
29
+
1. len: Tooth length
30
+
2. supp: Supplement type (VC or OJ).
31
+
3. dose: numeric Dose in milligrams/day
32
+
33
+
## Basic exploratory data analysis
34
+
35
+
```{r}
36
+
library(ggplot2)
37
+
ggplot(ToothGrowth, aes(x = dose, y = len, fill = supp)) +
38
+
geom_col() +
39
+
facet_grid(~supp, scales = "free")
40
+
```
41
+
42
+
At first glance, it seems that the dose given through orange juice is more effective, since greater growth is observed in the teeth when the dose is administered via orange juice and less when it is administered with ascorbic acid. We could also notice that when doses of 2mg are administered, it seems that the growth is the same regardless of which medium is administered.
43
+
44
+
But these are only initial guesses that we can verify or reject by performing a hypothesis test.
45
+
46
+
47
+
## Hypothesis Testing
48
+
49
+
### Assumptions
50
+
51
+
- The variables must be independent and identically distributed (i.i.d.).
52
+
- Variances of tooth growth are different when using different supplement and dosage.
53
+
- Tooth growth follows a normal distribution.
54
+
55
+
### Hypothesis 1: Variation of tooth length when using OJ or VC
56
+
57
+
Our null hypothesis is that the length of the tooth does not vary when we use either of the two methods (VC or OJ).
58
+
59
+
Therefore, our alternative hypothesis would be that tooth length varies depending on the method through which the dose is delivered.
t.test(oj_len,vc_len, paired = FALSE, var.equal = FALSE, alternative = "greater")
66
+
```
67
+
68
+
As we can see our p-value is greater than 0.05, therefore our null hypothesis is rejected and we accept that the length of the tooth varies according to the method used.
69
+
70
+
Furthermore, we can see that on average if we use OJ the tooth length is greater than using VC.
71
+
72
+
### Hypothesis 2: Variation of tooth length when using different doses
73
+
74
+
Our null hypothesis is that tooth length does not vary between methods when we use different doses.
75
+
76
+
Therefore, our alternative hypothesis would be that the length of the teeth varies according to the method and dose delivered.
As we can see, for doses of 0.5 mg and 1 mg we obtained results similar to that of our hypothesis 1. In both cases the p-value is less than 0.5, therefore we can reject the null hypothesis and accept that the logintud of the teeth It varies according to the dose and greater lengths are obtained with doses of 1 mg being administered with OJ.
108
+
109
+
However, for doses of 2 mg, we obtain a p-value greater than 0.5, which we can interpret in that we must accept the null hypothesis. This means that regardless of the method used (VC or OJ) the length of the teeth obtained is the same for a dose of 2 mg.
110
+
111
+
## Conclusion
112
+
113
+
As a conclusion we can say that after conducting this brief but interesting analysis, we have shown that for doses of 0.5 mg and 1 mg, orange juice results in greater tooth length. However for doses of 2mg, the length of teeth obtained will be the same regardless of whether OJ or VC is used.
labs(title= "Exponential distribution with lambda = 0.2 and 40 observations", subtitle = "Replicated 1000 times", caption="Produced by Carlos Hernández") +
83
+
labs(title= "Exponential distribution with lambda = 0.2 and 40 observations",
0 commit comments