De la base de datos disponible en R, ToothGrowth. Este conjunto de datos considera la longitud de los odontoblastos (células responsables del crecimiento de los dientes) en 60 cobayos. Cada animal recibió uno de los tres niveles de dosis de vitamina C (0,5, 1 y 2 mg/día) mediante uno de los dos métodos de administración, jugo de naranja o ácido ascórbico (una forma de vitamina C y codificada como VC).
#Preración Datos
datos = ToothGrowth
period=rep("Vitamina C",length(datos$supp))
period[which(datos$supp=="OJ")]="Jugo Naranja"
datos$period = period
head(datos)
## len supp dose period
## 1 4.2 VC 0.5 Vitamina C
## 2 11.5 VC 0.5 Vitamina C
## 3 7.3 VC 0.5 Vitamina C
## 4 5.8 VC 0.5 Vitamina C
## 5 6.4 VC 0.5 Vitamina C
## 6 10.0 VC 0.5 Vitamina C
Medidas estadísticas
#Medidas
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
estadisticos = describeBy(datos$len, datos$period, mat = F)
print(estadisticos)
##
## Descriptive statistics by group
## group: Jugo Naranja
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 30 20.66 6.61 22.7 21.04 5.49 8.2 30.9 22.7 -0.52 -1.03 1.21
## ------------------------------------------------------------
## group: Vitamina C
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 30 16.96 8.27 16.5 16.58 9.27 4.2 33.9 29.7 0.28 -0.93 1.51
library(nortest)
t1 = lillie.test(datos$len)
t2 = shapiro.test(datos$len)
print(t1)
##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: datos$len
## D = 0.097092, p-value = 0.172
print(t2)
##
## Shapiro-Wilk normality test
##
## data: datos$len
## W = 0.96743, p-value = 0.1091
#Vitamina C
t1 = lillie.test(datos$len[which(datos$period=="Vitamina C")])
t2 = shapiro.test(datos$len[which(datos$period=="Vitamina C")])
print(t1)
##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: datos$len[which(datos$period == "Vitamina C")]
## D = 0.083756, p-value = 0.8537
print(t2)
##
## Shapiro-Wilk normality test
##
## data: datos$len[which(datos$period == "Vitamina C")]
## W = 0.96567, p-value = 0.4284
#Jugo de Naranja
t1 = lillie.test(datos$len[which(datos$period=="Jugo Naranja")])
t2 = shapiro.test(datos$len[which(datos$period=="Jugo Naranja")])
print(t1)
##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: datos$len[which(datos$period == "Jugo Naranja")]
## D = 0.13823, p-value = 0.1517
print(t2)
##
## Shapiro-Wilk normality test
##
## data: datos$len[which(datos$period == "Jugo Naranja")]
## W = 0.91784, p-value = 0.02359
QQplot
#QQplot
qqnorm(datos$len, pch = 19, col = "gray50")
qqline(datos$len)
#Prueba F
t1 = var.test(datos$len[which(datos$period=="Jugo Naranja")], datos$len[which(datos$period=="Vitamina C")], conf.level=0.95)
print(t1)
##
## F test to compare two variances
##
## data: datos$len[which(datos$period == "Jugo Naranja")] and datos$len[which(datos$period == "Vitamina C")]
## F = 0.6386, num df = 29, denom df = 29, p-value = 0.2331
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.3039488 1.3416857
## sample estimates:
## ratio of variances
## 0.6385951
Como los datos cumplen con los criterios de ser igual o más de 60 muestras, se ve una distribución normal, y sus varianzas son similares, se aplica una prueba de contraste para dos muestras paramétricas y se considera que las muestras son no pareadas.
res1 = t.test(len ~ period, data = datos, conf.level = 0.95, paired = F)
print(res1)
##
## Welch Two Sample t-test
##
## data: len by period
## t = 1.9153, df = 55.309, p-value = 0.06063
## alternative hypothesis: true difference in means between group Jugo Naranja and group Vitamina C is not equal to 0
## 95 percent confidence interval:
## -0.1710156 7.5710156
## sample estimates:
## mean in group Jugo Naranja mean in group Vitamina C
## 20.66333 16.96333
Con los datos obtenidos se puede observar que no hay diferencia entre el consumo jugo de naranja o ácido ascórbico en la longitud de los odontoblastos en los sujetos de muestra.
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.