This work complets the Statistical Inference in Coursera Data Science class and it consists of two parts: Part 1: do a simulation to create some random data and do some analysis under the light of the Central Limit Theorem and Part 2: using one of the datasets in the R datasets library, do some analysis, some inferences and state a conclusion about the data.
#Load libraries to help
library(ggplot2)
#Use the ToothGrow dataset
data("ToothGrowth")
This dataset refers to the effect of Vitamin C on Tooth Growth in Guinea Pigs and the response is the length of odontoblasts (cells responsible for 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 coded as OJ or ascorbic acid, a form of vitamin C, and coded as VC.
Source of information: * https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/ToothGrowth.html *
#Lets have a overwiew of each variable in dataset
summary(ToothGrowth)
## len supp dose
## Min. : 4.20 OJ:30 Min. :0.500
## 1st Qu.:13.07 VC:30 1st Qu.:0.500
## Median :19.25 Median :1.000
## Mean :18.81 Mean :1.167
## 3rd Qu.:25.27 3rd Qu.:2.000
## Max. :33.90 Max. :2.000
#View first occorences
head(ToothGrowth)
## len supp dose
## 1 4.2 VC 0.5
## 2 11.5 VC 0.5
## 3 7.3 VC 0.5
## 4 5.8 VC 0.5
## 5 6.4 VC 0.5
## 6 10.0 VC 0.5
#Knew the unique values for each variable
unique(ToothGrowth$len)
## [1] 4.2 11.5 7.3 5.8 6.4 10.0 11.2 5.2 7.0 16.5 15.2 17.3 22.5 13.6
## [15] 14.5 18.8 15.5 23.6 18.5 33.9 25.5 26.4 32.5 26.7 21.5 23.3 29.5 17.6
## [29] 9.7 8.2 9.4 19.7 20.0 25.2 25.8 21.2 27.3 22.4 24.5 24.8 30.9 29.4
## [43] 23.0
unique(ToothGrowth$supp)
## [1] VC OJ
## Levels: OJ VC
unique(ToothGrowth$dose)
## [1] 0.5 1.0 2.0
t=ToothGrowth
levels(t$dose)<-c("0.5mg", "1mg", "2mg")
ggplot (t, aes(x=factor(supp), y=len))+facet_grid(.~dose)+geom_boxplot(aes(fill = factor(dose)), show_guide=TRUE)+labs(title="Tooth lenght of Guinea Pigs \naccording to doses and supply methods ", x="Supply Type", y="Tooth Length")
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
Assuming that the sample of 60 Guinea Pigs are representative of the population and that the doses and delivery methods were randomicaly aplied, we can conclude that the increasing of the dose are associated with the increasing of the tooth grow although, in minor doses, the eficience of the Orange Juice Method has reached greater values of tooth lengh than the Ascorbic Acid deliver method. When the doses reached the value 2, the mean of tooth grow are quite equivalent for both methods of delivery,
My best regards. Thanks for reading C.Werneck