R packages
if (!require(tidyverse)) install.packages("tidyverse")
if (!require(googlesheets4)) install.packages("googlesheets4")
if (!require(googledrive)) install.packages("googledrive")
if (!require(plotly)) install.packages("plotly")
if (!require(lme4)) install.packages("lme4")
if (!require(fitdistrplus)) install.packages("fitdistrplus")
if (!require(goft)) install.packages("goft")
if (!require(data.table)) install.packages("data.table")
if (!require(scales)) install.packages("scales")
if (!require(ggbreak)) install.packages("ggbreak")
if (!require(arm)) install.packages("arm")
if (!require(splines)) install.packages("splines")
if (!require(DT)) install.packages("DT")
if (!require(binom)) install.packages("binom")
##
library(DT)
library(binom)
library(splines)
library(arm)
library(ggbreak)
library(scales)
library(tidyverse)
library(googlesheets4)
library(googledrive)
library(plotly)
library(lme4)
library(fitdistrplus)
library(goft)
library(data.table)
ss= "https://docs.google.com/spreadsheets/d/1fLePbF3flzafwVH_kOZh6o2_g5htf0nmrOB2TpSdZ_M/edit?usp=sharing"
hoja = "lico_1"
rango = "B2:I1188"
ss= "https://docs.google.com/spreadsheets/d/1fLePbF3flzafwVH_kOZh6o2_g5htf0nmrOB2TpSdZ_M/edit?usp=sharing"
hoja = 1
rango = "B2:I1188"
df <- read_sheet(ss,
sheet = hoja,
range = rango,
col_names = TRUE
)
✔ Reading from Copia de pesaje de pollos.
✔ Range ''lico_1'!B2:I1188'.
df <- data.frame(df)
df$g <- as.numeric(df$g)
df$grupo <- as.factor(df$grupo)
df$replica <- as.factor(df$replica)
df$pseudo.r.dia <- as.factor(df$pseudo.r.dia)
df$dia.grupo <- as.factor(df$dia.grupo)
df$dia.replica <- as.factor(df$dia.replica)
#########################
ss= "https://docs.google.com/spreadsheets/d/1fLePbF3flzafwVH_kOZh6o2_g5htf0nmrOB2TpSdZ_M/edit?usp=sharing"
hoja = 1
rango = "A1193:F1229"
df2 <- read_sheet(ss,
sheet = hoja,
range = rango,
col_names = TRUE
)
✔ Reading from Copia de pesaje de pollos.
✔ Range ''lico_1'!A1193:F1229'.
df2$grupo <- as.factor(df2$grupo)
p <- ggplot(data= df,
aes(x= dia, y= g)
)
p <- p +
# geom_boxplot( aes(col= pseudo.r), fill= NA,
# position = position_dodge(1),
# show.legend = FALSE) +
# geom_point(aes(col= grupo), size = 1,
# position = position_jitterdodge(jitter.height = 0.01,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
geom_smooth(aes(col=grupo),
method = "glm", linewidth = 0.4,
formula= y ~ bs(x, 3),
method.args = list(family="gaussian"),
show.legend = TRUE) +
stat_summary(aes(fill= grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.2,
col= "darkslategray", linewidth = 0.9,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 1),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = "peso (g)",
x= "dia",
title = "Peso (g) de pollos .....") +
scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
labels = levels(as.factor((df$dia))))
ggplotly(p)
df. <- df[df$dia>14,]
p <- ggplot(data= df.,
aes(x= dia, y= g)
)
p <- p +
geom_boxplot( aes(col= pseudo.r.dia), fill= NA,
position = position_dodge(6),
show.legend = TRUE) +
geom_point(aes(col= pseudo.r.dia), size = 1,
position = position_jitterdodge(jitter.height = 0.01,
jitter.width = 0.2,
dodge.width = 6),
show.legend = FALSE) +
# stat_summary(aes(fill= pseudo.r.dia), fun.data = 'mean_cl_normal' ,
# geom = , size= 0.05, linewidth = 0.6,
# position = position_jitterdodge(jitter.height = 0,
# jitter.width = 0,
# dodge.width = 6),
# show.legend = FALSE) +
# geom_smooth(aes(col=grupo),
# method = "glm", linewidth = 0.4,
# formula= y ~ bs(x, 3), se= FALSE,
# method.args = list(family="gaussian"),
# show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = "peso (g)",
x= "dia",
title = "Peso (g) de pollos .....") +
scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
labels = levels(as.factor((df$dia))))
#ggplotly(p)
p
mod1 <-lm(formula = g ~ grupo * dia ,
#family = gaussian,
data = df)
summary(mod1)
Call:
lm(formula = g ~ grupo * dia, data = df)
Residuals:
Min 1Q Median 3Q Max
-420.75 -149.74 -31.98 150.47 750.49
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -268.2086 13.0008 -20.630 <2e-16 ***
grupoE -17.6211 18.4379 -0.956 0.3394
dia 65.5620 0.6739 97.292 <2e-16 ***
grupoE:dia 2.1607 0.9652 2.239 0.0254 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 178.6 on 1182 degrees of freedom
Multiple R-squared: 0.9416, Adjusted R-squared: 0.9415
F-statistic: 6357 on 3 and 1182 DF, p-value: < 2.2e-16
mod2 <-lmer(formula = g ~ grupo * dia + (1|dia/replica),
#family = gaussian,
data = df)
boundary (singular) fit: see help('isSingular')
summary(mod2)
Linear mixed model fit by REML ['lmerMod']
Formula: g ~ grupo * dia + (1 | dia/replica)
Data: df
REML criterion at convergence: 14440.6
Scaled residuals:
Min 1Q Median 3Q Max
-5.3950 -0.2567 -0.0221 0.2312 5.5860
Random effects:
Groups Name Variance Std.Dev.
replica:dia (Intercept) 0 0.0
dia (Intercept) 28086 167.6
Residual 11203 105.8
Number of obs: 1186, groups: replica:dia, 21; dia, 7
Fixed effects:
Estimate Std. Error t value
(Intercept) -273.9727 114.8050 -2.386
grupoE -20.8032 10.9271 -1.904
dia 66.1618 5.7240 11.559
grupoE:dia 2.5071 0.5721 4.382
Correlation of Fixed Effects:
(Intr) grupoE dia
grupoE -0.047
dia -0.833 0.041
grupoE:dia 0.039 -0.827 -0.049
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
##################################
p <- ggplot(data= df,
aes(x= dia, y= g)
)
p <- p +
geom_boxplot( aes(col= dia.grupo), fill= NA,
position = position_dodge(1),
show.legend = TRUE) +
# geom_point(aes(col= dia.grupo), size = 0.7,
# position = position_jitterdodge(jitter.height = 0.01,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
geom_smooth(aes(group=grupo),
method = "lm", linewidth= 0.2,
formula= y ~ bs(x, 3), se= FALSE,
method.args = list(family="poisson"),
show.legend = FALSE) +
stat_summary(aes(fill= dia.grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.2,
col= "darkslategray", linewidth = 0.9,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 1),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = "peso (g)",
x= "dia",
title = "Peso (g) de pollos .....") +
scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
labels = levels(as.factor((df$dia))))
p
dia = 1
df. <- df[df$dia==dia,]
mod1 <-lmer(formula = g ~ grupo + (1|replica),
#family = gaussian,
data = df.)
boundary (singular) fit: see help('isSingular')
summary(mod1)
Linear mixed model fit by REML ['lmerMod']
Formula: g ~ grupo + (1 | replica)
Data: df.
REML criterion at convergence: 790.3
Scaled residuals:
Min 1Q Median 3Q Max
-2.2708 -0.8206 0.2154 0.8419 1.8028
Random effects:
Groups Name Variance Std.Dev.
replica (Intercept) 0.000 0.000
Residual 4.717 2.172
Number of obs: 180, groups: replica, 3
Fixed effects:
Estimate Std. Error t value
(Intercept) 35.13222 0.22895 153.451
grupoE -0.04778 0.32378 -0.148
Correlation of Fixed Effects:
(Intr)
grupoE -0.707
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
############# AOV ######################
p <- ggplot(data= df.,
aes(x= grupo, y= g)
)
p <- p +
geom_violin( aes(group=grupo), fill= NA,
position = position_dodge(1),
show.legend = FALSE) +
geom_point(aes(col= pseudo.r.dia), size = 1.5,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 2,
dodge.width =0.5),
show.legend = TRUE) +
# geom_smooth(aes(col=grupo),
# method = "lm",
# formula= y ~ bs(x, 3),
# method.args = list(family="poisson"),
# show.legend = TRUE) +
stat_summary(aes(shape= grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.4,
col= "darkslategray", linewidth = 1.4,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 0.8),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = paste("Peso (g) de pollos al dia", dia),
x = "Grupo",
title = paste("Peso (g) de pollos al dia", dia) )
#scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
# labels = levels(as.factor((df$dia))))
p
dia = 7
df. <- df[df$dia==dia,]
mod1 <-lmer(formula = g ~ grupo + (1|replica),
#family = gaussian,
data = df.)
boundary (singular) fit: see help('isSingular')
summary(mod1)
Linear mixed model fit by REML ['lmerMod']
Formula: g ~ grupo + (1 | replica)
Data: df.
REML criterion at convergence: 1555.3
Scaled residuals:
Min 1Q Median 3Q Max
-2.49623 -0.66986 0.06682 0.68165 2.25275
Random effects:
Groups Name Variance Std.Dev.
replica (Intercept) 0 0.00
Residual 347 18.63
Number of obs: 180, groups: replica, 3
Fixed effects:
Estimate Std. Error t value
(Intercept) 177.803 1.963 90.555
grupoE -8.845 2.777 -3.185
Correlation of Fixed Effects:
(Intr)
grupoE -0.707
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
############# AOV ######################
p <- ggplot(data= df.,
aes(x= grupo, y= g)
)
p <- p +
geom_violin( aes(group=grupo), fill= NA,
position = position_dodge(1),
show.legend = FALSE) +
geom_point(aes(col= pseudo.r.dia), size = 1.5,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 2,
dodge.width =0.5),
show.legend = TRUE) +
# geom_smooth(aes(col=grupo),
# method = "lm",
# formula= y ~ bs(x, 3),
# method.args = list(family="poisson"),
# show.legend = TRUE) +
stat_summary(aes(shape= grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.4,
col= "darkslategray", linewidth = 1.4,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 0.8),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = paste("Peso (g) de pollos al dia", dia),
x = "Grupo",
title = paste("Peso (g) de pollos al dia", dia))
#scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
# labels = levels(as.factor((df$dia))))
p
dia = 11
df. <- df[df$dia==dia,]
mod1 <-lmer(formula = g ~ grupo + (1|replica),
#family = gaussian,
data = df.)
boundary (singular) fit: see help('isSingular')
summary(mod1)
Linear mixed model fit by REML ['lmerMod']
Formula: g ~ grupo + (1 | replica)
Data: df.
REML criterion at convergence: 1672.2
Scaled residuals:
Min 1Q Median 3Q Max
-2.18134 -0.71277 0.01036 0.62419 2.90324
Random effects:
Groups Name Variance Std.Dev.
replica (Intercept) 0.0 0.00
Residual 669.3 25.87
Number of obs: 180, groups: replica, 3
Fixed effects:
Estimate Std. Error t value
(Intercept) 292.292 2.727 107.185
grupoE -6.837 3.857 -1.773
Correlation of Fixed Effects:
(Intr)
grupoE -0.707
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
############# AOV ######################
p <- ggplot(data= df.,
aes(x= grupo, y= g)
)
p <- p +
geom_violin( aes(group=grupo), fill= NA,
position = position_dodge(1),
show.legend = FALSE) +
geom_point(aes(col= pseudo.r.dia), size = 1.5,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 2,
dodge.width =0.5),
show.legend = TRUE) +
# geom_smooth(aes(col=grupo),
# method = "lm",
# formula= y ~ bs(x, 3),
# method.args = list(family="poisson"),
# show.legend = TRUE) +
stat_summary(aes(shape= grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.4,
col= "darkslategray", linewidth = 1.4,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 0.8),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = paste("Peso (g) de pollos al dia",dia),
x = "Grupo",
title = paste("Peso (g) de pollos al dia",dia) )
#scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
# labels = levels(as.factor((df$dia))))
p
dia = 14
df. <- df[df$dia==dia,]
mod1 <-lmer(formula = g ~ grupo + (1|replica),
#family = gaussian,
data = df.)
boundary (singular) fit: see help('isSingular')
summary(mod1)
Linear mixed model fit by REML ['lmerMod']
Formula: g ~ grupo + (1 | replica)
Data: df.
REML criterion at convergence: 1836.3
Scaled residuals:
Min 1Q Median 3Q Max
-2.0417 -0.6040 -0.0234 0.6610 3.1837
Random effects:
Groups Name Variance Std.Dev.
replica (Intercept) 0 0.00
Residual 1682 41.02
Number of obs: 180, groups: replica, 3
Fixed effects:
Estimate Std. Error t value
(Intercept) 496.502 4.323 114.840
grupoE 7.938 6.114 1.298
Correlation of Fixed Effects:
(Intr)
grupoE -0.707
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
############# AOV ######################
p <- ggplot(data= df.,
aes(x= grupo, y= g)
)
p <- p +
geom_violin( aes(group=grupo), fill= NA,
position = position_dodge(1),
show.legend = FALSE) +
geom_point(aes(col= pseudo.r.dia), size = 1.5,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 2,
dodge.width =0.5),
show.legend = TRUE) +
# geom_smooth(aes(col=grupo),
# method = "lm",
# formula= y ~ bs(x, 3),
# method.args = list(family="poisson"),
# show.legend = TRUE) +
stat_summary(aes(shape= grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.4,
col= "darkslategray", linewidth = 1.4,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 0.8),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = paste("Peso (g) de pollos al dia",dia),
x = "Grupo",
title = paste("Peso (g) de pollos al dia",dia) )
#scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
# labels = levels(as.factor((df$dia))))
p
dia = 21
df. <- df[df$dia==dia,]
mod1 <-lmer(formula = g ~ grupo + (1|replica),
#family = gaussian,
data = df.)
summary(mod1)
Linear mixed model fit by REML ['lmerMod']
Formula: g ~ grupo + (1 | replica)
Data: df.
REML criterion at convergence: 2123.1
Scaled residuals:
Min 1Q Median 3Q Max
-2.9771 -0.8093 0.0054 0.7608 2.4606
Random effects:
Groups Name Variance Std.Dev.
replica (Intercept) 99.72 9.986
Residual 8961.76 94.667
Number of obs: 179, groups: replica, 3
Fixed effects:
Estimate Std. Error t value
(Intercept) 1050.61 11.57 90.779
grupoE 26.11 14.15 1.845
Correlation of Fixed Effects:
(Intr)
grupoE -0.615
############# AOV ######################
p <- ggplot(data= df.,
aes(x= grupo, y= g)
)
p <- p +
geom_violin( aes(group=grupo), fill= NA,
position = position_dodge(1),
show.legend = FALSE) +
geom_point(aes(col= pseudo.r.dia), size = 1.5,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 2,
dodge.width =0.5),
show.legend = TRUE) +
# geom_smooth(aes(col=grupo),
# method = "lm",
# formula= y ~ bs(x, 3),
# method.args = list(family="poisson"),
# show.legend = TRUE) +
stat_summary(aes(shape= grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.4,
col= "darkslategray", linewidth = 1.4,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 0.8),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = paste("Peso (g) de pollos al dia",dia),
x = "Grupo",
title = paste("Peso (g) de pollos al dia",dia) )
#scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
# labels = levels(as.factor((df$dia))))
p
dia = 28
df. <- df[df$dia==dia,]
mod1 <-lmer(formula = g ~ grupo + (1|replica),
#family = gaussian,
data = df.)
summary(mod1)
Linear mixed model fit by REML ['lmerMod']
Formula: g ~ grupo + (1 | replica)
Data: df.
REML criterion at convergence: 1838.2
Scaled residuals:
Min 1Q Median 3Q Max
-2.3974 -0.7758 -0.1284 0.8951 1.9984
Random effects:
Groups Name Variance Std.Dev.
replica (Intercept) 184.2 13.57
Residual 22979.1 151.59
Number of obs: 144, groups: replica, 3
Fixed effects:
Estimate Std. Error t value
(Intercept) 1594.82 19.21 83.006
grupoE 60.04 25.52 2.352
Correlation of Fixed Effects:
(Intr)
grupoE -0.632
############# AOV ######################
p <- ggplot(data= df.,
aes(x= grupo, y= g)
)
p <- p +
geom_violin( aes(group=grupo), fill= NA,
position = position_dodge(1),
show.legend = FALSE) +
geom_point(aes(col= pseudo.r.dia), size = 1.5,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 2,
dodge.width =0.5),
show.legend = TRUE) +
# geom_smooth(aes(col=grupo),
# method = "lm",
# formula= y ~ bs(x, 3),
# method.args = list(family="poisson"),
# show.legend = TRUE) +
stat_summary(aes(shape= grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.4,
col= "darkslategray", linewidth = 1.4,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 0.8),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = paste("Peso (g) de pollos al dia",dia),
x = "Grupo",
title = paste("Peso (g) de pollos al dia",dia) )
#scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
# labels = levels(as.factor((df$dia))))
p
dia = 35
df. <- df[df$dia==dia,]
mod1 <-lmer(formula = g ~ grupo + (1|replica),
#family = gaussian,
data = df.)
boundary (singular) fit: see help('isSingular')
summary(mod1)
Linear mixed model fit by REML ['lmerMod']
Formula: g ~ grupo + (1 | replica)
Data: df.
REML criterion at convergence: 1948.4
Scaled residuals:
Min 1Q Median 3Q Max
-2.4249 -0.7270 -0.1096 0.8189 2.5071
Random effects:
Groups Name Variance Std.Dev.
replica (Intercept) 0 0.0
Residual 55268 235.1
Number of obs: 143, groups: replica, 3
Fixed effects:
Estimate Std. Error t value
(Intercept) 2175.79 27.15 80.152
grupoE 69.76 39.37 1.772
Correlation of Fixed Effects:
(Intr)
grupoE -0.690
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')
############# AOV ######################
p <- ggplot(data= df.,
aes(x= grupo, y= g)
)
p <- p +
geom_violin( aes(group=grupo), fill= NA,
position = position_dodge(1),
show.legend = FALSE) +
geom_point(aes(col= pseudo.r.dia), size = 1.5,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 2,
dodge.width =0.5),
show.legend = TRUE) +
# geom_smooth(aes(col=grupo),
# method = "lm",
# formula= y ~ bs(x, 3),
# method.args = list(family="poisson"),
# show.legend = TRUE) +
stat_summary(aes(shape= grupo), fun.data = 'mean_cl_normal' ,
geom = , size= 0.4,
col= "darkslategray", linewidth = 1.4,
position = position_jitterdodge(jitter.height = 0,
jitter.width = 0,
dodge.width = 0.8),
show.legend = FALSE) +
# stat_summary(aes(shape= grupo), col= "darkslategray",
# fun = median, geom = "point", size = 3,
# position = position_jitterdodge(jitter.height = 0.2,
# jitter.width = 0.2,
# dodge.width = 1),
# show.legend = FALSE) +
labs(y = paste("Peso (g) de pollos al dia",dia),
x = "Grupo",
title = paste("Peso (g) de pollos al dia",dia) )
#scale_x_continuous(breaks= c(1,7,11, 14,21,28,35),
# labels = levels(as.factor((df$dia))))
p
#dia = 35
#df. <- df[df$dia==dia,]
### Pooled tables
## pooled by DIA
by_grupo <- df2 %>% group_by(grupo)
mort_by_grupo<- as.data.frame(by_grupo %>% summarise( muertes = sum(muertes), n = sum(n)))
#
by_dia <- df2 %>% group_by(d)
mort_by_dia<- as.data.frame(by_dia %>% summarise( muertes = sum(muertes), n = sum(n)))
#
by_grupo.dia <- df2 %>% group_by(d, grupo)
mort_by_grupo.dia <- as.data.frame(by_grupo.dia %>% summarise(muertes = sum(muertes), n= sum(n)))
`summarise()` has grouped output by 'd'. You can override using the `.groups`
argument.
mort_by_grupo.dia$Pr.mortal <- mort_by_grupo.dia$muertes/
(mort_by_grupo.dia$muertes + mort_by_grupo.dia$n)
CIs <- binom.confint(x= mort_by_grupo.dia$muertes, n= mort_by_grupo.dia$n + mort_by_grupo.dia$muertes, methods="wilson")
mort_by_grupo.dia$lower <- CIs[,5]
mort_by_grupo.dia$upper<- CIs[,6]
datatable(mort_by_grupo.dia)
size= 3
width = 1
p <- ggplot(aes(x=d , y=Pr.mortal,
col=grupo, ymin = lower, ymax = upper),
data= mort_by_grupo.dia)
p <- p +
geom_hline(yintercept = mort_by_grupo.dia$lower[9],
linetype= "dashed", col="dark gray") +
geom_point(position= position_dodge(width=width),
size=size) +
geom_linerange(position = position_dodge(width=width)) +
scale_x_continuous(n.breaks= 6,
breaks= c(1,7,11,21,28,35),
labels= levels(as.factor(mort_by_grupo.dia$d)),
name= "Día") +
scale_y_continuous(n.breaks = 5,
breaks=c(0, 0.25, 0.50,0.75, 1), limits = c(0,1),
labels=c("0%","25%", "50%", "75%", "100%"),
name= "Mortalidad (%)") +
labs(title= "Mortalidad (%) de pollos (IC.95% de Wilson)") +
ylim(0,0.5) +
scale_colour_grey(start=0, end=0.6) +
theme_bw(base_size = 14)
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
p
### ######
Y <- cbind(mort_by_grupo.dia$muertes, mort_by_grupo.dia$n)
mod1 <-glm(formula = Y ~ d * grupo,
family = binomial,
data = mort_by_grupo.dia)
summary(mod1)
Call:
glm(formula = Y ~ d * grupo, family = binomial, data = mort_by_grupo.dia)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -5.515906 0.816304 -6.757 1.41e-11 ***
d 0.086616 0.028287 3.062 0.0022 **
grupoe 0.209388 1.082033 0.194 0.8466
d:grupoe 0.007278 0.037363 0.195 0.8456
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 133.483 on 11 degrees of freedom
Residual deviance: 99.518 on 8 degrees of freedom
AIC: 118.48
Number of Fisher Scoring iterations: 6