Dos tipos de moluscos A y B fueron sometidos a tres concentraciones distintas de agua de mar (100%, 75% y 50%) y se observó el consumo de oxigeno midiendo la proporción de O2 por unidad de peso seco del molusco.
##A analisis de datos univariados y bivariados
se carga la base de datos “BD_moluscos” para analizar los datos
library(readxl)
Punto1_parcial3 <- read_excel("D:/Escritorio/parcial 3 bioestadisca/Punto1_parcial3.xlsx",
col_types = c("numeric", "text", "numeric"))
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C2 / R2C3: '7.16'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C3 / R3C3: '8.26'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C4 / R4C3: '6.78'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C6 / R6C3: '13.6'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C7 / R7C3: '11.1'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C8 / R8C3: '8.93'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C9 / R9C3: '9.66'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C10 / R10C3: '6.14'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C11 / R11C3: '6.14'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C12 / R12C3: '3.68'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C14 / R14C3: '10.4'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C15 / R15C3: '11.6'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C16 / R16C3: '5.49'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C17 / R17C3: '5.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C18 / R18C3: '5.2'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C19 / R19C3: '13.2'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C20 / R20C3: '5.2'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C21 / R21C3: '8.39'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C22 / R22C3: '7.18'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C23 / R23C3: '10.4'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C24 / R24C3: '6.37'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C25 / R25C3: '7.18'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C26 / R26C3: '4.47'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C27 / R27C3: '4.95'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C28 / R28C3: '9.96'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C29 / R29C3: '6.49'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C30 / R30C3: '5.75'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C31 / R31C3: '5.44'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C32 / R32C3: '1.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C33 / R33C3: '9.9'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C34 / R34C3: '11.11'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C35 / R35C3: '10.5'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C36 / R36C3: '9.74'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C37 / R37C3: '14.6'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C38 / R38C3: '18.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C39 / R39C3: '11.11'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C40 / R40C3: '9.74'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C41 / R41C3: '11.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C42 / R42C3: '9.63'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C43 / R43C3: '14.5'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C44 / R44C3: '6.38'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C45 / R45C3: '10.2'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C46 / R46C3: '13.4'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C47 / R47C3: '17.7'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C48 / R48C3: '14.5'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C49 / R49C3: '12.3'
Punto1_parcial3
## # A tibble: 48 x 3
## Concentracionag Tipo po2
## <dbl> <chr> <dbl>
## 1 100 A 7.16
## 2 100 A 8.26
## 3 100 A 6.78
## 4 100 A 14
## 5 100 A 13.6
## 6 100 A 11.1
## 7 100 A 8.93
## 8 100 A 9.66
## 9 100 B 6.14
## 10 100 B 6.14
## # ... with 38 more rows
se observa que la tabla se basa en 3 variables: que son tipo de molusco, concentracion de agua y proporcion de oxigeno, con el objetivo de analizar el consumo de oxigeno midiendo la proporcion de O2 por unidad de peso seco del molusco.
require(ggplot2)
require(plotly)
require(agricolae)
summary(Punto1_parcial3$po2)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.800 6.312 9.700 9.305 11.232 18.800
sd(Punto1_parcial3$po2)
## [1] 3.682652
se evidencia la desviacion estandar referente a la proporcion de O2 por unidad de peso seco del molusco, division de cuartiles, y datos como maximo, minimos y media.
ggplot(Punto1_parcial3,aes(x=po2))+geom_histogram()+facet_grid(~Concentracionag)+ylab("Count")+ggtitle("Consumo de O2 con relacion a la porporcion de O2")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(Punto1_parcial3,aes(x=po2))+geom_histogram()+facet_grid(~Tipo)+ylab("Count")+ggtitle("Consumo de O2 de los tipos de molusco")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
En estos dos graficos se representa el consumo de 02 en relacion a la proporcion de O2 y el tipo de molusco(A y B) respectivamente. En el primer grafico evidenciamos que el consumo de O2 con relacion a la proporcion de por unidad de peso seco del molusco tienen valores mas reiterativos en un rango de 5 a 8, cumpliendo esto en todas las concentraciones de agua con una excepcion en la concentracion al 50%. En el segundo grafico observamos la relacion del consumo dependiendo del tipo de molusco.
ggplot(Punto1_parcial3,aes(y=po2,x=Concentracionag,fill=Tipo))+geom_boxplot()+xlab("Concentracion de agua")+ylab("Consumo de O2")
ggplot(Punto1_parcial3,aes(y=po2,x=Tipo))+geom_boxplot()+facet_grid(~Concentracionag)+xlab("Tipo de molusco")+ylab("Consumo de O2")
Representacion de diagrama de cajas relacionando las tres variables observadas. En el primer diagrama de cajas se observa que el molusco tipo B tienen una desviacion estadndar mucho mayor, por ende posee valores mas altos y mas bajos en comparacion al molusco tipo B. El molusco tipo B presenta valores variopintos , siendo estos muy dispersos en la escala de consumo. En cambio, el moluscop tipo A, presenta valores mas iguales y sin tantas variaciones entre ellos, con la excepcion de un dato atipico. Por otro lado, el segundo diagrama esta representado y diferenciado por las diferentes concentraciones, donde es claro la mayor efectividad de consumo en proporcion al O2 del molusco tipo B en la concentracion menor(50%), esto en contraste con las dos otras concentraciones(75% y 100%), en las cuales sucede lo contrario, el molusco tipo A presenta una mayor efectividad. En vista general, los dos moluscos tienen mayor consumo de O2 en un ambiente con concentracion de agua de mar de 50%.
##B Diseño de modelo
mod1=lm(po2 ~ Concentracionag * Tipo, data = Punto1_parcial3)
anova(mod1)
## Analysis of Variance Table
##
## Response: po2
## Df Sum Sq Mean Sq F value Pr(>F)
## Concentracionag 1 102.50 102.495 9.0684 0.004298 **
## Tipo 1 23.23 23.227 2.0550 0.158773
## Concentracionag:Tipo 1 14.38 14.378 1.2721 0.265481
## Residuals 44 497.31 11.302
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(mod1)
##
## Call:
## lm(formula = po2 ~ Concentracionag * Tipo, data = Punto1_parcial3)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.8092 -2.2067 -0.1795 2.2469 7.6802
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.35854 2.61316 5.112 6.65e-06 ***
## Concentracionag -0.04477 0.03362 -1.332 0.190
## TipoB 2.63063 3.69556 0.712 0.480
## Concentracionag:TipoB -0.05363 0.04754 -1.128 0.265
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.362 on 44 degrees of freedom
## Multiple R-squared: 0.2198, Adjusted R-squared: 0.1666
## F-statistic: 4.132 on 3 and 44 DF, p-value: 0.01151
se observa que el valor p es de 0.01, validando la veracidad de la prueba al estar dentro del rango del nivel de confianza.
post1=LSD.test(mod1,"Concentracionag")
post1
## $statistics
## MSerror Df Mean CV t.value LSD
## 11.3025 44 9.304792 36.13105 2.015368 2.395502
##
## $parameters
## test p.ajusted name.t ntr alpha
## Fisher-LSD none Concentracionag 3 0.05
##
## $means
## po2 std r LCL UCL Min Max Q25 Q50 Q75
## 50 12.25062 3.199643 16 10.556750 13.944500 6.38 18.8 10.085 11.455 14.5000
## 75 6.99250 2.804093 16 5.298625 8.686375 1.80 13.2 5.200 6.430 8.7675
## 100 8.67125 3.000940 16 6.977375 10.365125 3.68 14.0 6.140 8.595 10.5750
##
## $comparison
## NULL
##
## $groups
## po2 groups
## 50 12.25062 a
## 100 8.67125 b
## 75 6.99250 b
##
## attr(,"class")
## [1] "group"
bar.group(post1$groups,ylim=c(0,15))
Durante esta prueba postanova se evaluo el efecto de la concentracion de agua de mar y los tipos de molusco sobre el consumo de O2, arrojando como resultado que el molusco tipo A muestra el consumo de oxigeno mas efectivo a una concentracion de agua de mar al 50%. ademas, en el grafico se observan los datos referentes a la prueba postanova.
Cargamos la base de datos para analizar los datos.
A continuacion, encontrara usted los datos de riqueza (numero de especies) de moluscos asociados a cantos intermareales de diferente tamaño en diferentes epocas del año. Teniendo en cuenta esto, usted quiere evaluar si la riqueza varia entre los diferentes tamaños de cantos, las diferentes epocas del año y si existe interaccion entre el tamaño del canto y la epoca del año. Recuerde plantear las hipotesis de trabajo antes de empezar con los an?lisis. Adicionalmente, recuerde que el investigador debe estar seguro de que sus datos cumplen ciertas asunciones para poder utilizar el ANOVA. Utilice pruebas de comparacion multiple (postanova), de ser necesarias, para determinar cual es el tamaño del canto donde se encuentra mayor numero de especies para cada epoca del año. Utilice un alpha = 5%.
en este punto se observara si existe relacion entre el tamaño del canto y la epoca del año sobre la cantidad de especies marinas. Para iniciar se plantean las hipotesis: h0= almenos una de las variables epoca(Tiempo) y tamaño del canto (T_canto) influyen en la riqueza de especies y ha= ninguna de las variables como epoca(Tiempo) y tamaño del canto(T_Canto) influyen en la riqueza de especies, por ultimo se deben comprobar los supuestos de los datos obtenidos por los investigadoes.
Cargamos la base de datos para analizar los datos.
library(readxl)
Punto2_Parcial3 <- read_excel("D:/Escritorio/parcial 3 bioestadisca/Punto2_Parcial3.xlsx",
col_types = c("numeric", "numeric", "numeric"))
Punto2_Parcial3
## # A tibble: 64 x 3
## T_Canto Tiempo Riqueza
## <dbl> <dbl> <dbl>
## 1 1 1 7
## 2 1 1 5
## 3 1 1 7
## 4 1 1 7
## 5 1 2 6
## 6 1 2 4
## 7 1 2 9
## 8 1 2 8
## 9 1 3 7
## 10 1 3 11
## # ... with 54 more rows
attach(Punto2_Parcial3)
En el grafico de puntos no se observa una tendencia definida en la influencia de las variables frente a la riqueza de especies, pero cuando nos referimos al tamaño de canto se nota una pequeña tendencia, por el momento los datos no presentan normalidad
######normalidad
Se realizo la prueba de Shapiro Wilk para comprobar la normalidad de los datos.
shapiro.test(Punto2_Parcial3$Riqueza)
##
## Shapiro-Wilk normality test
##
## data: Punto2_Parcial3$Riqueza
## W = 0.95524, p-value = 0.02089
se observa que el valor es menor a 0.05, lo cual nos dice que los datos no presentan una distribucion normal
######Correlacion
cor= cor.test(Punto2_Parcial3$Tiempo, Punto2_Parcial3$T_Canto,
alternative = "two.sided",
method = "pearson")
cor
##
## Pearson's product-moment correlation
##
## data: Punto2_Parcial3$Tiempo and Punto2_Parcial3$T_Canto
## t = 0, df = 62, p-value = 1
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.2458093 0.2458093
## sample estimates:
## cor
## 0
segun esta prueba de correlacion nos indica que existe una relacion entre ambas variables y la riqueza de especies, esto puede indicar de que la influencia puede ser dada solo por una variable
#####Anova
mod=lm(Riqueza~Tiempo*T_Canto)
summary(mod)
##
## Call:
## lm(formula = Riqueza ~ Tiempo * T_Canto)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5900 -1.3650 -0.2925 1.3987 5.3950
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.5625 1.6726 5.119 3.41e-06 ***
## Tiempo 0.2125 0.6108 0.348 0.7291
## T_Canto -1.4750 0.6108 -2.415 0.0188 *
## Tiempo:T_Canto -0.1100 0.2230 -0.493 0.6236
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.23 on 60 degrees of freedom
## Multiple R-squared: 0.4524, Adjusted R-squared: 0.425
## F-statistic: 16.52 on 3 and 60 DF, p-value: 6.118e-08
anova(mod)
## Analysis of Variance Table
##
## Response: Riqueza
## Df Sum Sq Mean Sq F value Pr(>F)
## Tiempo 1 0.312 0.312 0.0628 0.8029
## T_Canto 1 245.000 245.000 49.2603 2.326e-09 ***
## Tiempo:T_Canto 1 1.210 1.210 0.2433 0.6236
## Residuals 60 298.415 4.974
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
se realizo un analisis de varianza donde se observa que la variable tamaño del canto afecta la riqueza de especies; ya que el valor p para el tamaño del canto es significativo, pero a variable tiempo no afecta la riqueza de especies.
#####Supuestos
par(mfrow=c(2,2))
plot(mod)
segun las graficas de los residuales no se presenta un comportamiento definido siendo los datos aleatorios.
por otro lado para los datos de normal Q-Q si se presenta un comportamiento lineal por la forma de la pendiente.
#####Postanova
post1=LSD.test(mod,"Tiempo")
post1
## $statistics
## MSerror Df Mean CV t.value LSD
## 4.973583 60 4.71875 47.26152 2.000298 1.577191
##
## $parameters
## test p.ajusted name.t ntr alpha
## Fisher-LSD none Tiempo 4 0.05
##
## $means
## Riqueza std r LCL UCL Min Max Q25 Q50 Q75
## 1 4.5625 2.897556 16 3.447257 5.677743 1 11 2.00 3.0 7.00
## 2 5.0000 2.476557 16 3.884757 6.115243 1 9 3.00 4.5 6.50
## 3 4.9375 3.802959 16 3.822257 6.052743 0 11 1.00 6.0 7.25
## 4 4.3750 2.655184 16 3.259757 5.490243 1 11 2.75 4.0 5.25
##
## $comparison
## NULL
##
## $groups
## Riqueza groups
## 2 5.0000 a
## 3 4.9375 a
## 1 4.5625 a
## 4 4.3750 a
##
## attr(,"class")
## [1] "group"
post2=LSD.test(mod,"T_Canto")
post2
## $statistics
## MSerror Df Mean CV t.value LSD
## 4.973583 60 4.71875 47.26152 2.000298 1.577191
##
## $parameters
## test p.ajusted name.t ntr alpha
## Fisher-LSD none T_Canto 4 0.05
##
## $means
## Riqueza std r LCL UCL Min Max Q25 Q50 Q75
## 1 7.3125 1.922455 16 6.197257 8.427743 4 11 6.75 7 8.00
## 2 5.8750 2.963669 16 4.759757 6.990243 0 11 3.75 6 8.00
## 3 3.3750 2.276694 16 2.259757 4.490243 0 9 2.00 3 4.25
## 4 2.3125 1.400893 16 1.197257 3.427743 0 5 1.00 2 3.25
##
## $comparison
## NULL
##
## $groups
## Riqueza groups
## 1 7.3125 a
## 2 5.8750 a
## 3 3.3750 b
## 4 2.3125 b
##
## attr(,"class")
## [1] "group"
Segun los resultados de la prueba de comparacion multiple para saber si el tamaño del canto oceanico influye en la riqueza de especies, estos evidenciaron que el tamaño de canto s1 y s2 tiene mas efecto sobre la variable de respuesta, ademas se observo que la variable epoca o tiempo no genera ningun efecto en la variable de respuesta.
se pudó confirmar que los grupos de especies S1 y S2 contienen la mayor riqueza de especies y el grupo de especies S3 y S4 contienen menor riqueza de especies.
Suponga que se desea realizar una investigacion diseñada para conocer el efecto de cuatro tipos de dieta sobre el engorde de cerdos, donde se tienen 20 cerdos asignados aleatoriamente a cuatro grupos experimentales (cuatro dietas disponibles) y someter a cada grupo a un único tipo de dieta. Teniendo en cuenta lo anterior, usted quiere evaluar si existen diferencias entre los pesos corporales de los cerdos (en Kg) después de haber sido criados con esas dietas por un mes.
Cargamos la base de datos para analizar los datos.
library(readxl)
Punto3_Parcial3 <- read_excel("D:/Escritorio/parcial 3 bioestadisca/Punto3_Parcial3.xlsx",
col_types = c("text", "numeric"))
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B2 / R2C2: '60.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B3 / R3C2: '67.0'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B4 / R4C2: '65.0'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B5 / R5C2: '68.6'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B6 / R6C2: '61.7'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B7 / R7C2: '68.7'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B8 / R8C2: '67.7'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B9 / R9C2: '75.0'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B10 / R10C2: '73.3'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B11 / R11C2: '71.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B12 / R12C2: '69.6'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B13 / R13C2: '77.1'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B14 / R14C2: '75.2'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B15 / R15C2: '71.5'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B16 / R16C2: '74.3'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B17 / R17C2: '61.9'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B18 / R18C2: '64.2'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B19 / R19C2: '63.1'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B20 / R20C2: '66.7'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in B21 / R21C2: '60.3'
Punto3_Parcial3
## # A tibble: 20 x 2
## t_dieta peso
## <chr> <dbl>
## 1 A 60.8
## 2 A 67
## 3 A 65
## 4 A 68.6
## 5 A 61.7
## 6 B 68.7
## 7 B 67.7
## 8 B 75
## 9 B 73.3
## 10 B 71.8
## 11 C 69.6
## 12 C 77.1
## 13 C 75.2
## 14 C 71.5
## 15 C 74.3
## 16 D 61.9
## 17 D 64.2
## 18 D 63.1
## 19 D 66.7
## 20 D 60.3
Aqui las dos variables son: el tipo de dieta y el peso de 20 porcinos asignados aleatoriamente a cuatro grupos experimentales y cada uno con un tipo de dieta unica.
summary(Punto3_Parcial3$peso)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 60.30 63.92 68.15 68.17 72.17 77.10
sd(Punto3_Parcial3$peso)
## [1] 5.227345
Aqui se observan Valores de desviacion estandar y datos como maximo, minimos, media y division de la muestra en cuartiles.
ggplot(Punto3_Parcial3,aes(y=peso,x=t_dieta))+geom_point()+ylab("Peso")+xlab("Tipo de dieta")
ggplot(Punto3_Parcial3,aes(y=peso,x=t_dieta,fill=t_dieta))+geom_boxplot()+ylab("Peso")+xlab("Tipo de dieta")
se observa la representacion de la relacion del tipo de dieta con el peso de los cerdos.En el primer grafico (puntos) muestra los diferentes 5 pesos de cada ejemplar con su respectivas dieta. El tipo de dieta C posee valores mayores, es decir que es mas efectivo al cumplir el objetivo de aumentar el peso de los ejemplares. En el diagrama de cajas se observa o anteriormente nombrado, donde las dietas A y D son las menos efectivas, y las dietas B y C son las mas efectivas, siendo C la mas efectiva del experimento.
mod3=lm(peso~t_dieta, data=Punto3_Parcial3)
anova(mod3)
## Analysis of Variance Table
##
## Response: peso
## Df Sum Sq Mean Sq F value Pr(>F)
## t_dieta 3 377.71 125.902 14.239 8.833e-05 ***
## Residuals 16 141.47 8.842
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(mod3)
##
## Call:
## lm(formula = peso ~ t_dieta, data = Punto3_Parcial3)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.940 -2.680 0.440 2.095 3.980
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 64.620 1.330 48.593 < 2e-16 ***
## t_dietaB 6.680 1.881 3.552 0.002655 **
## t_dietaC 8.920 1.881 4.743 0.000221 ***
## t_dietaD -1.380 1.881 -0.734 0.473691
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.974 on 16 degrees of freedom
## Multiple R-squared: 0.7275, Adjusted R-squared: 0.6764
## F-statistic: 14.24 on 3 and 16 DF, p-value: 8.833e-05
post3=LSD.test(mod3,"t_dieta")
post3
## $statistics
## MSerror Df Mean CV t.value LSD
## 8.842 16 68.175 4.361643 2.119905 3.986775
##
## $parameters
## test p.ajusted name.t ntr alpha
## Fisher-LSD none t_dieta 4 0.05
##
## $means
## peso std r LCL UCL Min Max Q25 Q50 Q75
## A 64.62 3.345445 5 61.80092 67.43908 60.8 68.6 61.7 65.0 67.0
## B 71.30 3.068387 5 68.48092 74.11908 67.7 75.0 68.7 71.8 73.3
## C 73.54 2.987139 5 70.72092 76.35908 69.6 77.1 71.5 74.3 75.2
## D 63.24 2.416195 5 60.42092 66.05908 60.3 66.7 61.9 63.1 64.2
##
## $comparison
## NULL
##
## $groups
## peso groups
## C 73.54 a
## B 71.30 a
## A 64.62 b
## D 63.24 b
##
## attr(,"class")
## [1] "group"
bar.group(post3$groups,ylim=c(0,100))
En la prueba postanova se observa que la dieta C tuvo mayor rendimiento con un peso de 73.54 Kg observado en el grafico. la segunda dieta mas efectiva fue la B con un peso de 71.30Kg. Para terminar se puede concluir que las dietas C y B son las mas efectivas por lo tanto estas son las que se tienen que aplicar en los ejemplares.
Se desea determinar el efecto que tienen dos factores (Temperatura y Sexo) sobre la tasa de consumo de oxigeno (mgO2) de una especie de cangrejo. La siguiente tabla muestra los datos colectados para 24 animales usados en el experimento.
library(readxl)
Punto4_parcial3 <- read_excel("D:/Escritorio/parcial 3 bioestadisca/Punto4_parcial3.xlsx",
col_types = c("text", "text", "numeric"))
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C2 / R2C3: '1.9'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C3 / R3C3: '1.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C4 / R4C3: '1.6'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C5 / R5C3: '1.4'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C6 / R6C3: '1.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C7 / R7C3: '1.7'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C8 / R8C3: '1.4'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C9 / R9C3: '1.5'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C10 / R10C3: '2.3'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C11 / R11C3: '2.1'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C13 / R13C3: '2.6'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C14 / R14C3: '2.4'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C15 / R15C3: '2.7'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C16 / R16C3: '2.4'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C17 / R17C3: '2.6'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C18 / R18C3: '2.9'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C19 / R19C3: '2.8'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C20 / R20C3: '3.4'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C21 / R21C3: '3.2'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C23 / R23C3: '3.1'
## Warning in read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, :
## Coercing text to numeric in C25 / R25C3: '2.7'
Punto4_parcial3
## # A tibble: 24 x 3
## Temp. Sexo TC_O
## <chr> <chr> <dbl>
## 1 Baja Macho 1.9
## 2 Baja Macho 1.8
## 3 Baja Macho 1.6
## 4 Baja Macho 1.4
## 5 Baja Hembra 1.8
## 6 Baja Hembra 1.7
## 7 Baja Hembra 1.4
## 8 Baja Hembra 1.5
## 9 Media Macho 2.3
## 10 Media Macho 2.1
## # ... with 14 more rows
En la tabla se pueden apreciar las variables: temperatura y sexo (cuantitativas) y consumo de oxigeno (cualitativa), donde la tempratura esta dividida en baja, media y alta; trabajadas por orden alfabetico.
Utilizamos la función summary para calcular todos los datos necesarios para el estudio de la relación entre el consumo de oxigeno con dos factores, sexo y temperatura de una especie de cangrejo.
summary(Punto4_parcial3$TC_O)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.400 1.800 2.400 2.346 2.825 3.400
sd(Punto4_parcial3$TC_O)
## [1] 0.6121801
se observa el resumen de valores como minimo, maximo, mediana, media y desviacion estandar.
ggplot(Punto4_parcial3,aes(x=TC_O))+geom_density()+facet_grid(~Sexo)+ylab("Density")+ggtitle("Consumo de O2 con relación al sexo")
ggplot(Punto4_parcial3,aes(x=TC_O))+geom_bar()+facet_grid(~Temp.)+ylab("Count")+ggtitle("Consumo de O2 con relación a la temperatura")
En estos graficos se aprecia la representacion de la relación del consumo de O2 con el sexo y el consumo de O2 en relacion a la temperatura respectivamente. En el primer grafico de densidad, se observa la diferencia que existe entre hembras y machos, donde las hembras muestran un mayor consumo de O2 que los machos. En el diagrama de barras se observan comportamientos entre el consumo de oxigeno y las diferentes temperaturas, ya que los patrones de consumo varian en que en temperatura alta el consumo es mayor, en temperatura baja los valores de consumo son las menores y en temperatura media los valores son medios. Se observa un comportamiento lineal, ya que existe una relacion directa entre la temperatura y el consumo.
ggplot(Punto4_parcial3,aes(x=Temp.,y=TC_O,fill=Sexo))+geom_boxplot()+facet_grid(~Sexo)
En este diagrama de cajas se evidencia la relacion de las tres variables en funcion de la temperatura. Se observa que el consumo de oxigeno es mayor en temperatura alta, consumo medio en la temperatura media y baja en la temperatura baja, mostrando un comportamiento directamente porporcional. En temperatura alta presentan los machos un mayor consumo en comparacion a las hembras que presentan un dato atipico. De la misma manera en temperaturas bajas, los machos muestran un mayor consumo de oxigeno, con diferencia a la temperatura media donde las hembras presentan un mayor consumo de oxigeno en comparacion con los machos.
mod4=lm(TC_O~Temp.*Sexo, data=Punto4_parcial3)
anova(mod4)
## Analysis of Variance Table
##
## Response: TC_O
## Df Sum Sq Mean Sq F value Pr(>F)
## Temp. 2 7.5833 3.7917 81.0089 9.991e-10 ***
## Sexo 1 0.0037 0.0037 0.0801 0.7804
## Temp.:Sexo 2 0.1900 0.0950 2.0297 0.1604
## Residuals 18 0.8425 0.0468
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(mod4)
##
## Call:
## lm(formula = TC_O ~ Temp. * Sexo, data = Punto4_parcial3)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.2750 -0.1562 0.0500 0.1313 0.3500
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.9500 0.1082 27.271 4.31e-16 ***
## Temp.Baja -1.3500 0.1530 -8.825 5.90e-08 ***
## Temp.Media -0.4250 0.1530 -2.778 0.0124 *
## SexoMacho 0.1250 0.1530 0.817 0.4246
## Temp.Baja:SexoMacho -0.0500 0.2163 -0.231 0.8198
## Temp.Media:SexoMacho -0.4000 0.2163 -1.849 0.0810 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2163 on 18 degrees of freedom
## Multiple R-squared: 0.9023, Adjusted R-squared: 0.8751
## F-statistic: 33.23 on 5 and 18 DF, p-value: 1.749e-08
post4=LSD.test(mod4,"Temp.")
post4
## $statistics
## MSerror Df Mean CV t.value LSD
## 0.04680556 18 2.345833 9.222561 2.100922 0.227263
##
## $parameters
## test p.ajusted name.t ntr alpha
## Fisher-LSD none Temp. 3 0.05
##
## $means
## TC_O std r LCL UCL Min Max Q25 Q50 Q75
## Alta 3.0125 0.2232071 8 2.851801 3.173199 2.7 3.4 2.875 3.00 3.125
## Baja 1.6375 0.1922610 8 1.476801 1.798199 1.4 1.9 1.475 1.65 1.800
## Media 2.3875 0.2474874 8 2.226801 2.548199 2.0 2.7 2.250 2.40 2.600
##
## $comparison
## NULL
##
## $groups
## TC_O groups
## Alta 3.0125 a
## Media 2.3875 b
## Baja 1.6375 c
##
## attr(,"class")
## [1] "group"
bar.group(post4$groups,ylim=c(0,5))
En la prueba postanova se observa que el mayor consumo de oxigeno se presenta a altas temperaturas. Esto es verificado en los diagramas y su correspondiente grafico.
Cierto Agricultor interesado en el cultivo de la caña de azúcar desea saber en que zonas del mundo puede establecer su cultivo y obtener rendimientos (kg/ha) potenciales. El agricultor sabe que uno de los factores limitantes (mas no el único) es el clima y por ello investiga cuales son los rangos óptimos sobre los cuales se obtienen rendimientos potenciales, identificando lo siguiente: temperatura media entre (22.5 y 28 grados centígrados) y precitación anual entre 1500 y 3500 milímetros) o precipitación mensual entre 125 y 290 mm. Adicionalmente el agricultor tiene información que le indica que la región del Valle del Cauca en Colombia posee unos rendimientos altos y que otra aproximación para identificar las zonas a nivel global seria buscar otros sitios con estas condiciones (similares).