\[\text{Valeria Riveros Parra y Juan Felipe Paz Paiba}\] \[\text{Analisis de varianza para medidas repetidas de dos vĂ­as}\]

library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.2.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.2.3
library(ggplot2)
library(rstatix)
## Warning: package 'rstatix' was built under R version 4.2.3
## 
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
## 
##     filter
library(readxl)
## Warning: package 'readxl' was built under R version 4.2.3
library(multcomp)
## Loading required package: mvtnorm
## Warning: package 'mvtnorm' was built under R version 4.2.3
## Loading required package: survival
## Loading required package: TH.data
## Warning: package 'TH.data' was built under R version 4.2.3
## Loading required package: MASS
## Warning: package 'MASS' was built under R version 4.2.3
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:rstatix':
## 
##     select
## 
## Attaching package: 'TH.data'
## The following object is masked from 'package:MASS':
## 
##     geyser
library(lme4)
## Warning: package 'lme4' was built under R version 4.2.3
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.2.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.3
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:MASS':
## 
##     select
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.2.3
## 
## Attaching package: 'tidyr'
## The following objects are masked from 'package:Matrix':
## 
##     expand, pack, unpack
# Datos en formato ancho
data_2= read_xlsx ("C:/Users/juanf/Downloads/m_repetidas.xlsx", sheet= "biomasa_2")
data_2
## # A tibble: 30 Ă— 14
##    dosis_fert `0_dĂ­as` `05_dĂ­as` `10_dĂ­as` `15_dĂ­as` `20_dĂ­as` `25_dĂ­as`
##    <chr>         <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
##  1 A            0.0001      2.95      3.31      3.12      3.27      3.86
##  2 A            0.0001      2.53      3.02      3.35      3.41      3.73
##  3 A            0.0001      2.68      3.07      3.39      2.72      3.52
##  4 A            0.0001      2.77      2.91      3.11      3.42      2.99
##  5 A            0.0001      2.83      3.15      3.46      3.15      3.08
##  6 A            0.0001      2.88      3.18      3.27      3.75      3.24
##  7 A            0.0001      2.92      3.21      2.67      3.37      3.81
##  8 A            0.0001      2.86      2.96      3.24      2.9       3.45
##  9 A            0.0001      2.99      3.27      3.04      3.51      3.03
## 10 A            0.0001      3.02      3.14      3.19      3.44      3.57
## # ℹ 20 more rows
## # ℹ 7 more variables: `30_dĂ­as` <dbl>, `35_dĂ­as` <dbl>, `40_dĂ­as` <dbl>,
## #   `45_dĂ­as` <dbl>, `50_dĂ­as` <dbl>, `55_dĂ­as` <dbl>, `60_dĂ­as` <dbl>
# Gather the columns t1, t2 and t3 into long format.
# Convert id and time into factor variables
data_2_larga <- data_2 %>%
  gather(key = "time", value = "biomasa",`0_dĂ­as`, `05_dĂ­as`, `10_dĂ­as`, `15_dĂ­as`, `20_dĂ­as`, `25_dĂ­as`, `30_dĂ­as`, `35_dĂ­as`, `40_dĂ­as`, `45_dĂ­as`, `50_dĂ­as`, `55_dĂ­as`, `60_dĂ­as`) %>%
  convert_as_factor(time)
head(data_2_larga)
## # A tibble: 6 Ă— 3
##   dosis_fert time   biomasa
##   <chr>      <fct>    <dbl>
## 1 A          0_dĂ­as  0.0001
## 2 A          0_dĂ­as  0.0001
## 3 A          0_dĂ­as  0.0001
## 4 A          0_dĂ­as  0.0001
## 5 A          0_dĂ­as  0.0001
## 6 A          0_dĂ­as  0.0001
# Inspect some random rows of the data by groups
set.seed(123)
data_2_larga %>% sample_n_by(dosis_fert, time, size = 1)
## # A tibble: 39 Ă— 3
##    dosis_fert time    biomasa
##    <chr>      <fct>     <dbl>
##  1 A          0_dĂ­as   0.0001
##  2 A          05_dĂ­as  2.68  
##  3 A          10_dĂ­as  3.14  
##  4 A          15_dĂ­as  3.35  
##  5 A          20_dĂ­as  3.75  
##  6 A          25_dĂ­as  3.08  
##  7 A          30_dĂ­as  3.60  
##  8 A          35_dĂ­as  3.64  
##  9 A          40_dĂ­as  4.59  
## 10 A          45_dĂ­as  4.13  
## # ℹ 29 more rows
data_2_larga %>%
  group_by(dosis_fert, time) %>%
  get_summary_stats(biomasa, type = "mean_sd")
## # A tibble: 39 Ă— 6
##    dosis_fert time    variable     n  mean    sd
##    <chr>      <fct>   <fct>    <dbl> <dbl> <dbl>
##  1 A          0_dĂ­as  biomasa     10  0    0    
##  2 A          05_dĂ­as biomasa     10  2.84 0.15 
##  3 A          10_dĂ­as biomasa     10  3.12 0.133
##  4 A          15_dĂ­as biomasa     10  3.18 0.224
##  5 A          20_dĂ­as biomasa     10  3.30 0.301
##  6 A          25_dĂ­as biomasa     10  3.43 0.326
##  7 A          30_dĂ­as biomasa     10  3.69 0.27 
##  8 A          35_dĂ­as biomasa     10  3.78 0.221
##  9 A          40_dĂ­as biomasa     10  4.32 0.24 
## 10 A          45_dĂ­as biomasa     10  4.47 0.361
## # ℹ 29 more rows
library(collapsibleTree)
## Warning: package 'collapsibleTree' was built under R version 4.2.3
# Crear un Ă¡rbol colapsable
tree <- collapsibleTree(data_2_larga, c("time", "dosis_fert","biomasa"), collapsed = TRUE)

# Visualizar el Ă¡rbol colapsable
tree
bxp <- ggboxplot(
data_2_larga, x = "time", y = "biomasa",
  color = "dosis_fert", palette = "Zissou1"
  )
bxp

data_2_larga %>%
  group_by(dosis_fert, time) %>%
  identify_outliers(biomasa)
## # A tibble: 8 Ă— 5
##   dosis_fert time    biomasa is.outlier is.extreme
##   <chr>      <fct>     <dbl> <lgl>      <lgl>     
## 1 A          05_dĂ­as    2.53 TRUE       FALSE     
## 2 A          15_dĂ­as    2.67 TRUE       FALSE     
## 3 A          20_dĂ­as    2.72 TRUE       FALSE     
## 4 A          60_dĂ­as    5.10 TRUE       FALSE     
## 5 B          30_dĂ­as    7.41 TRUE       FALSE     
## 6 B          45_dĂ­as    8.79 TRUE       FALSE     
## 7 C          45_dĂ­as   24.6  TRUE       FALSE     
## 8 C          45_dĂ­as   15.7  TRUE       FALSE
shapiro.test(data_2_larga$biomasa)
## 
##  Shapiro-Wilk normality test
## 
## data:  data_2_larga$biomasa
## W = 0.908, p-value = 1.2e-14
ggqqplot(data_2_larga, "biomasa", ggtheme = theme_bw()) +
  facet_grid(time ~ dosis_fert, labeller = "label_both")

#aplicar logaritmos para evitar datos atipicos en la biomasa
data_2_larga$log_biomasa= log(data_2_larga$biomasa)
data_2_larga %>%
  group_by(dosis_fert, time) %>%
  identify_outliers(log_biomasa)
## # A tibble: 10 Ă— 6
##    dosis_fert time    biomasa log_biomasa is.outlier is.extreme
##    <chr>      <fct>     <dbl>       <dbl> <lgl>      <lgl>     
##  1 A          05_dĂ­as    2.53       0.928 TRUE       FALSE     
##  2 A          15_dĂ­as    2.67       0.982 TRUE       FALSE     
##  3 A          20_dĂ­as    2.72       1.00  TRUE       FALSE     
##  4 A          60_dĂ­as    5.10       1.63  TRUE       FALSE     
##  5 B          30_dĂ­as    7.41       2.00  TRUE       FALSE     
##  6 B          45_dĂ­as    8.79       2.17  TRUE       FALSE     
##  7 B          50_dĂ­as    8.36       2.12  TRUE       FALSE     
##  8 C          15_dĂ­as    7.86       2.06  TRUE       FALSE     
##  9 C          45_dĂ­as   24.6        3.20  TRUE       FALSE     
## 10 C          45_dĂ­as   15.7        2.75  TRUE       FALSE
shapiro.test(data_2_larga$log_biomasa)
## 
##  Shapiro-Wilk normality test
## 
## data:  data_2_larga$log_biomasa
## W = 0.47889, p-value < 2.2e-16
ggqqplot(data_2_larga, "log_biomasa", ggtheme = theme_bw()) +
  facet_grid(time ~ dosis_fert, labeller = "label_both")

#aplicar raĂ­z cuadrada para evitar datos atipicos en la biomasa
data_2_larga$sqrt_biomasa= sqrt(data_2_larga$biomasa)
data_2_larga %>%
  group_by(dosis_fert, time) %>%
  identify_outliers(sqrt_biomasa)
## # A tibble: 9 Ă— 7
##   dosis_fert time    biomasa log_biomasa sqrt_biomasa is.outlier is.extreme
##   <chr>      <fct>     <dbl>       <dbl>        <dbl> <lgl>      <lgl>     
## 1 A          05_dĂ­as    2.53       0.928         1.59 TRUE       FALSE     
## 2 A          15_dĂ­as    2.67       0.982         1.63 TRUE       FALSE     
## 3 A          20_dĂ­as    2.72       1.00          1.65 TRUE       FALSE     
## 4 A          60_dĂ­as    5.10       1.63          2.26 TRUE       FALSE     
## 5 B          30_dĂ­as    7.41       2.00          2.72 TRUE       FALSE     
## 6 B          45_dĂ­as    8.79       2.17          2.96 TRUE       FALSE     
## 7 C          15_dĂ­as    7.86       2.06          2.80 TRUE       FALSE     
## 8 C          45_dĂ­as   24.6        3.20          4.96 TRUE       FALSE     
## 9 C          45_dĂ­as   15.7        2.75          3.96 TRUE       FALSE
shapiro.test(data_2_larga$sqrt_biomasa)
## 
##  Shapiro-Wilk normality test
## 
## data:  data_2_larga$sqrt_biomasa
## W = 0.9546, p-value = 1.354e-09
ggqqplot(data_2_larga, "sqrt_biomasa", ggtheme = theme_bw()) +
  facet_grid(time ~ dosis_fert, labeller = "label_both")

nrow(data_2_larga)
## [1] 390
data_2_larga$id= rep(seq(1,10),39)
# ANOVA 
res.aov2C <- anova_test(data = data_2_larga, dv = log_biomasa, wid = id, 
                       within =  time, between = dosis_fert)
## Warning: The 'wid' column contains duplicate ids across between-subjects
## variables. Automatic unique id will be created
res.aov2C
## ANOVA Table (type II tests)
## 
## $ANOVA
##            Effect DFn DFd        F         p p<.05   ges
## 1      dosis_fert   2  27 15847.65  3.59e-42     * 0.977
## 2            time  12 324 38726.64  0.00e+00     * 0.999
## 3 dosis_fert:time  24 324    68.45 1.38e-111     * 0.830
## 
## $`Mauchly's Test for Sphericity`
##            Effect        W        p p<.05
## 1            time 3.29e-05 2.12e-17     *
## 2 dosis_fert:time 3.29e-05 2.12e-17     *
## 
## $`Sphericity Corrections`
##            Effect   GGe       DF[GG]     p[GG] p[GG]<.05   HFe       DF[HF]
## 1            time 0.462 5.55, 149.85 3.96e-234         * 0.596 7.15, 193.08
## 2 dosis_fert:time 0.462 11.1, 149.85  6.54e-53         * 0.596 14.3, 193.08
##       p[HF] p[HF]<.05
## 1 6.24e-301         *
## 2  1.72e-67         *
# Obtener la tabla de ANOVA
get_anova_table(res.aov2C)
## ANOVA Table (type II tests)
## 
##            Effect   DFn    DFd        F         p p<.05   ges
## 1      dosis_fert  2.00  27.00 15847.65  3.59e-42     * 0.977
## 2            time  5.55 149.85 38726.64 3.96e-234     * 0.999
## 3 dosis_fert:time 11.10 149.85    68.45  6.54e-53     * 0.830
# Hay 3 hipotesis: Factor, Tiempo e interacciĂ³n 
# Hay interacciĂ³n 
# Hay efecto del tiempo;  Hay efecto del tratamiento
# Effect of time at each level of treatment
one.way2 <- data_2_larga %>%
  group_by(dosis_fert) %>%
  anova_test(dv = log_biomasa, wid = id, within = time) %>%
  get_anova_table() %>%
  adjust_pvalue(method = "bonferroni")
one.way2
## # A tibble: 3 Ă— 9
##   dosis_fert Effect   DFn   DFd      F         p `p<.05`   ges     p.adj
##   <chr>      <chr>  <dbl> <dbl>  <dbl>     <dbl> <chr>   <dbl>     <dbl>
## 1 A          time      12   108 18719. 3.26e-173 *       0.999 9.78e-173
## 2 B          time      12   108 19325. 5.84e-174 *       1     1.75e-173
## 3 C          time      12   108  8438. 1.53e-154 *       0.999 4.59e-154
# Convertir las columnas a factores si es necesario
data_2_larga$time <- as.factor(data_2_larga$time)
data_2_larga$dosis_fert <- as.factor(data_2_larga$dosis_fert)

# Realizar el ANOVA para la dosis de fertilizaciĂ³n
modelo_anova_dosis <- aov(log_biomasa ~ dosis_fert, data = data_2_larga)
summary(modelo_anova_dosis)
##              Df Sum Sq Mean Sq F value  Pr(>F)   
## dosis_fert    2    111   55.39   5.996 0.00273 **
## Residuals   387   3575    9.24                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Realizar la prueba de comparaciones mĂºltiples de Tukey para la dosis de fertilizaciĂ³n
tukey_result_dosis <- TukeyHSD(modelo_anova_dosis)

# Mostrar los resultados de la prueba de Tukey para la dosis de fertilizaciĂ³n
print(tukey_result_dosis)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = log_biomasa ~ dosis_fert, data = data_2_larga)
## 
## $dosis_fert
##          diff        lwr      upr     p adj
## B-A 0.7742015 -0.1127937 1.661197 0.1010691
## C-A 1.2974150  0.4104197 2.184410 0.0018531
## C-B 0.5232134 -0.3637818 1.410209 0.3482609
# Pairwise comparisons between time points
pwc2 <- data_2_larga %>%
  group_by(dosis_fert) %>%
  pairwise_t_test(
    log_biomasa ~ time, paired = TRUE,
    p.adjust.method = "bonferroni"
    )
pwc2
## # A tibble: 234 Ă— 11
##    dosis_fert .y.    group1 group2    n1    n2 statistic    df        p    p.adj
##  * <fct>      <chr>  <chr>  <chr>  <int> <int>     <dbl> <dbl>    <dbl>    <dbl>
##  1 A          log_b… 0_días 05_dí…    10    10     -599.     9 5.12e-22 3.99e-20
##  2 A          log_b… 0_días 10_dí…    10    10     -765.     9 5.68e-23 4.43e-21
##  3 A          log_b… 0_días 15_dí…    10    10     -447.     9 7.14e-21 5.57e-19
##  4 A          log_b… 0_días 20_dí…    10    10     -348.     9 6.75e-20 5.26e-18
##  5 A          log_b… 0_días 25_dí…    10    10     -344.     9 7.64e-20 5.96e-18
##  6 A          log_b… 0_días 30_dí…    10    10     -445.     9 7.42e-21 5.79e-19
##  7 A          log_b… 0_días 35_dí…    10    10     -565.     9 8.65e-22 6.75e-20
##  8 A          log_b… 0_días 40_dí…    10    10     -607.     9 4.56e-22 3.56e-20
##  9 A          log_b… 0_días 45_dí…    10    10     -422.     9 1.19e-20 9.28e-19
## 10 A          log_b… 0_días 50_dí…    10    10     -453.     9 6.29e-21 4.91e-19
## # ℹ 224 more rows
## # ℹ 1 more variable: p.adj.signif <chr>
# Realizar el ANOVA para el tiempo
modelo_anova_tiempo <- aov(log_biomasa ~ time, data = data_2_larga)
summary(modelo_anova_tiempo)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## time         12   3560  296.68   888.1 <2e-16 ***
## Residuals   377    126    0.33                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Realizar la prueba de comparaciones mĂºltiples de Tukey para el tiempo
tukey_result_tiempo <- TukeyHSD(modelo_anova_tiempo)

# Mostrar los resultados de la prueba de Tukey para el tiempo
print(tukey_result_tiempo)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = log_biomasa ~ time, data = data_2_larga)
## 
## $time
##                         diff          lwr        upr     p adj
## 05_dĂ­as-0_dĂ­as  11.000880548 10.503299554 11.4984615 0.0000000
## 10_dĂ­as-0_dĂ­as  11.095078459 10.597497465 11.5926595 0.0000000
## 15_dĂ­as-0_dĂ­as  11.123851950 10.626270956 11.6214329 0.0000000
## 20_dĂ­as-0_dĂ­as  11.117002081 10.619421087 11.6145831 0.0000000
## 25_dĂ­as-0_dĂ­as  11.201814314 10.704233320 11.6993953 0.0000000
## 30_dĂ­as-0_dĂ­as  11.230506748 10.732925754 11.7280877 0.0000000
## 35_dĂ­as-0_dĂ­as  11.291040612 10.793459618 11.7886216 0.0000000
## 40_dĂ­as-0_dĂ­as  11.437480183 10.939899189 11.9350612 0.0000000
## 45_dĂ­as-0_dĂ­as  11.462798204 10.965217210 11.9603792 0.0000000
## 50_dĂ­as-0_dĂ­as  11.500908623 11.003327629 11.9984896 0.0000000
## 55_dĂ­as-0_dĂ­as  11.580099810 11.082518816 12.0776808 0.0000000
## 60_dĂ­as-0_dĂ­as  11.709345430 11.211764435 12.2069264 0.0000000
## 10_dĂ­as-05_dĂ­as  0.094197911 -0.403383083  0.5917789 0.9999898
## 15_dĂ­as-05_dĂ­as  0.122971402 -0.374609592  0.6205524 0.9998193
## 20_dĂ­as-05_dĂ­as  0.116121533 -0.381459462  0.6137025 0.9999012
## 25_dĂ­as-05_dĂ­as  0.200933766 -0.296647228  0.6985148 0.9809345
## 30_dĂ­as-05_dĂ­as  0.229626200 -0.267954795  0.7272072 0.9463479
## 35_dĂ­as-05_dĂ­as  0.290160064 -0.207420931  0.7877411 0.7679244
## 40_dĂ­as-05_dĂ­as  0.436599635 -0.060981359  0.9341806 0.1537267
## 45_dĂ­as-05_dĂ­as  0.461917656 -0.035663338  0.9594987 0.0992773
## 50_dĂ­as-05_dĂ­as  0.500028074  0.002447080  0.9976091 0.0475651
## 55_dĂ­as-05_dĂ­as  0.579219262  0.081638267  1.0768003 0.0078797
## 60_dĂ­as-05_dĂ­as  0.708464881  0.210883887  1.2060459 0.0002156
## 15_dĂ­as-10_dĂ­as  0.028773491 -0.468807503  0.5263545 1.0000000
## 20_dĂ­as-10_dĂ­as  0.021923622 -0.475657372  0.5195046 1.0000000
## 25_dĂ­as-10_dĂ­as  0.106735855 -0.390845139  0.6043168 0.9999600
## 30_dĂ­as-10_dĂ­as  0.135428289 -0.362152705  0.6330093 0.9995113
## 35_dĂ­as-10_dĂ­as  0.195962153 -0.301618841  0.6935431 0.9845134
## 40_dĂ­as-10_dĂ­as  0.342401724 -0.155179270  0.8399827 0.5225218
## 45_dĂ­as-10_dĂ­as  0.367719745 -0.129861249  0.8653007 0.4017149
## 50_dĂ­as-10_dĂ­as  0.405830164 -0.091750831  0.9034112 0.2464616
## 55_dĂ­as-10_dĂ­as  0.485021351 -0.012559643  0.9826023 0.0642368
## 60_dĂ­as-10_dĂ­as  0.614266970  0.116685976  1.1118480 0.0032039
## 20_dĂ­as-15_dĂ­as -0.006849869 -0.504430863  0.4907311 1.0000000
## 25_dĂ­as-15_dĂ­as  0.077962364 -0.419618630  0.5755434 0.9999988
## 30_dĂ­as-15_dĂ­as  0.106654798 -0.390926197  0.6042358 0.9999603
## 35_dĂ­as-15_dĂ­as  0.167188662 -0.330392332  0.6647697 0.9961974
## 40_dĂ­as-15_dĂ­as  0.313628233 -0.183952761  0.8112092 0.6628932
## 45_dĂ­as-15_dĂ­as  0.338946254 -0.158634740  0.8365272 0.5395101
## 50_dĂ­as-15_dĂ­as  0.377056673 -0.120524322  0.8746377 0.3600430
## 55_dĂ­as-15_dĂ­as  0.456247860 -0.041333134  0.9538289 0.1098958
## 60_dĂ­as-15_dĂ­as  0.585493479  0.087912485  1.0830745 0.0067371
## 25_dĂ­as-20_dĂ­as  0.084812233 -0.412768761  0.5823932 0.9999968
## 30_dĂ­as-20_dĂ­as  0.113504667 -0.384076327  0.6110857 0.9999225
## 35_dĂ­as-20_dĂ­as  0.174038531 -0.323542463  0.6716195 0.9945047
## 40_dĂ­as-20_dĂ­as  0.320478102 -0.177102892  0.8180591 0.6300582
## 45_dĂ­as-20_dĂ­as  0.345796123 -0.151784871  0.8433771 0.5058932
## 50_dĂ­as-20_dĂ­as  0.383906542 -0.113674452  0.8814875 0.3308399
## 55_dĂ­as-20_dĂ­as  0.463097729 -0.034483265  0.9606787 0.0971741
## 60_dĂ­as-20_dĂ­as  0.592343348  0.094762354  1.0899243 0.0056653
## 30_dĂ­as-25_dĂ­as  0.028692434 -0.468888560  0.5262734 1.0000000
## 35_dĂ­as-25_dĂ­as  0.089226298 -0.408354696  0.5868073 0.9999944
## 40_dĂ­as-25_dĂ­as  0.235665869 -0.261915125  0.7332469 0.9353959
## 45_dĂ­as-25_dĂ­as  0.260983890 -0.236597104  0.7585649 0.8730040
## 50_dĂ­as-25_dĂ­as  0.299094309 -0.198486686  0.7966753 0.7296319
## 55_dĂ­as-25_dĂ­as  0.378285496 -0.119295498  0.8758665 0.3547140
## 60_dĂ­as-25_dĂ­as  0.507531115  0.009950121  1.0051121 0.0407238
## 35_dĂ­as-30_dĂ­as  0.060533864 -0.437047130  0.5581149 0.9999999
## 40_dĂ­as-30_dĂ­as  0.206973435 -0.290607559  0.7045544 0.9757524
## 45_dĂ­as-30_dĂ­as  0.232291456 -0.265289538  0.7298725 0.9416914
## 50_dĂ­as-30_dĂ­as  0.270401875 -0.227179119  0.7679829 0.8427975
## 55_dĂ­as-30_dĂ­as  0.349593062 -0.147987932  0.8471741 0.4873969
## 60_dĂ­as-30_dĂ­as  0.478838681 -0.018742313  0.9764197 0.0724115
## 40_dĂ­as-35_dĂ­as  0.146439571 -0.351141423  0.6440206 0.9989312
## 45_dĂ­as-35_dĂ­as  0.171757592 -0.325823402  0.6693386 0.9951264
## 50_dĂ­as-35_dĂ­as  0.209868011 -0.287712983  0.7074490 0.9729139
## 55_dĂ­as-35_dĂ­as  0.289059198 -0.208521796  0.7866402 0.7724694
## 60_dĂ­as-35_dĂ­as  0.418304817 -0.079276177  0.9158858 0.2051887
## 45_dĂ­as-40_dĂ­as  0.025318021 -0.472262973  0.5228990 1.0000000
## 50_dĂ­as-40_dĂ­as  0.063428440 -0.434152555  0.5610094 0.9999999
## 55_dĂ­as-40_dĂ­as  0.142619627 -0.354961367  0.6402006 0.9991776
## 60_dĂ­as-40_dĂ­as  0.271865246 -0.225715748  0.7694462 0.8377712
## 50_dĂ­as-45_dĂ­as  0.038110418 -0.459470576  0.5356914 1.0000000
## 55_dĂ­as-45_dĂ­as  0.117301606 -0.380279389  0.6148826 0.9998901
## 60_dĂ­as-45_dĂ­as  0.246547225 -0.251033769  0.7441282 0.9119246
## 55_dĂ­as-50_dĂ­as  0.079191187 -0.418389807  0.5767722 0.9999985
## 60_dĂ­as-50_dĂ­as  0.208436807 -0.289144188  0.7060178 0.9743475
## 60_dĂ­as-55_dĂ­as  0.129245619 -0.368335375  0.6268266 0.9996970
# Modelo Lineal Generalizado Mixto
model <- lmer(log_biomasa ~ dosis_fert * time + (1 | id), data = data_2_larga)
## boundary (singular) fit: see help('isSingular')
# Comparaciones por pares con letras de agrupamiento (Tukey)
comp <- glht(model, linfct = mcp(time = "Tukey"))
## Warning in mcp2matrix(model, linfct = linfct): covariate interactions found --
## default contrast might be inappropriate
summary(comp)
## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps
## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: lmer(formula = log_biomasa ~ dosis_fert * time + (1 | id), data = data_2_larga)
## 
## Linear Hypotheses:
##                        Estimate Std. Error z value Pr(>|z|)    
## 05_dĂ­as - 0_dĂ­as == 0  10.25341    0.03832 267.606    <0.01 ***
## 10_dĂ­as - 0_dĂ­as == 0  10.34771    0.03832 270.067    <0.01 ***
## 15_dĂ­as - 0_dĂ­as == 0  10.36654    0.03832 270.558    <0.01 ***
## 20_dĂ­as - 0_dĂ­as == 0  10.39892    0.03832 271.403    <0.01 ***
## 25_dĂ­as - 0_dĂ­as == 0  10.43790    0.03832 272.421    <0.01 ***
## 30_dĂ­as - 0_dĂ­as == 0  10.51241    0.03832 274.365    <0.01 ***
## 35_dĂ­as - 0_dĂ­as == 0  10.53867    0.03832 275.051    <0.01 ***
## 40_dĂ­as - 0_dĂ­as == 0  10.67216    0.03832 278.535    <0.01 ***
## 45_dĂ­as - 0_dĂ­as == 0  10.70418    0.03832 279.370    <0.01 ***
## 50_dĂ­as - 0_dĂ­as == 0  10.74669    0.03832 280.480    <0.01 ***
## 55_dĂ­as - 0_dĂ­as == 0  10.83565    0.03832 282.802    <0.01 ***
## 60_dĂ­as - 0_dĂ­as == 0  10.95958    0.03832 286.036    <0.01 ***
## 10_dĂ­as - 05_dĂ­as == 0  0.09429    0.03832   2.461   0.4006    
## 15_dĂ­as - 05_dĂ­as == 0  0.11313    0.03832   2.953   0.1401    
## 20_dĂ­as - 05_dĂ­as == 0  0.14551    0.03832   3.798    <0.01 ** 
## 25_dĂ­as - 05_dĂ­as == 0  0.18448    0.03832   4.815    <0.01 ***
## 30_dĂ­as - 05_dĂ­as == 0  0.25900    0.03832   6.760    <0.01 ***
## 35_dĂ­as - 05_dĂ­as == 0  0.28526    0.03832   7.445    <0.01 ***
## 40_dĂ­as - 05_dĂ­as == 0  0.41875    0.03832  10.929    <0.01 ***
## 45_dĂ­as - 05_dĂ­as == 0  0.45077    0.03832  11.765    <0.01 ***
## 50_dĂ­as - 05_dĂ­as == 0  0.49328    0.03832  12.874    <0.01 ***
## 55_dĂ­as - 05_dĂ­as == 0  0.58224    0.03832  15.196    <0.01 ***
## 60_dĂ­as - 05_dĂ­as == 0  0.70617    0.03832  18.430    <0.01 ***
## 15_dĂ­as - 10_dĂ­as == 0  0.01883    0.03832   0.492   1.0000    
## 20_dĂ­as - 10_dĂ­as == 0  0.05121    0.03832   1.337   0.9825    
## 25_dĂ­as - 10_dĂ­as == 0  0.09019    0.03832   2.354   0.4770    
## 30_dĂ­as - 10_dĂ­as == 0  0.16470    0.03832   4.299    <0.01 ** 
## 35_dĂ­as - 10_dĂ­as == 0  0.19096    0.03832   4.984    <0.01 ***
## 40_dĂ­as - 10_dĂ­as == 0  0.32445    0.03832   8.468    <0.01 ***
## 45_dĂ­as - 10_dĂ­as == 0  0.35647    0.03832   9.304    <0.01 ***
## 50_dĂ­as - 10_dĂ­as == 0  0.39899    0.03832  10.413    <0.01 ***
## 55_dĂ­as - 10_dĂ­as == 0  0.48794    0.03832  12.735    <0.01 ***
## 60_dĂ­as - 10_dĂ­as == 0  0.61187    0.03832  15.969    <0.01 ***
## 20_dĂ­as - 15_dĂ­as == 0  0.03238    0.03832   0.845   0.9998    
## 25_dĂ­as - 15_dĂ­as == 0  0.07136    0.03832   1.862   0.8179    
## 30_dĂ­as - 15_dĂ­as == 0  0.14587    0.03832   3.807    <0.01 ** 
## 35_dĂ­as - 15_dĂ­as == 0  0.17213    0.03832   4.492    <0.01 ***
## 40_dĂ­as - 15_dĂ­as == 0  0.30562    0.03832   7.976    <0.01 ***
## 45_dĂ­as - 15_dĂ­as == 0  0.33764    0.03832   8.812    <0.01 ***
## 50_dĂ­as - 15_dĂ­as == 0  0.38016    0.03832   9.922    <0.01 ***
## 55_dĂ­as - 15_dĂ­as == 0  0.46911    0.03832  12.243    <0.01 ***
## 60_dĂ­as - 15_dĂ­as == 0  0.59304    0.03832  15.478    <0.01 ***
## 25_dĂ­as - 20_dĂ­as == 0  0.03898    0.03832   1.017   0.9985    
## 30_dĂ­as - 20_dĂ­as == 0  0.11349    0.03832   2.962   0.1365    
## 35_dĂ­as - 20_dĂ­as == 0  0.13975    0.03832   3.647   0.0167 *  
## 40_dĂ­as - 20_dĂ­as == 0  0.27324    0.03832   7.131    <0.01 ***
## 45_dĂ­as - 20_dĂ­as == 0  0.30526    0.03832   7.967    <0.01 ***
## 50_dĂ­as - 20_dĂ­as == 0  0.34777    0.03832   9.077    <0.01 ***
## 55_dĂ­as - 20_dĂ­as == 0  0.43673    0.03832  11.398    <0.01 ***
## 60_dĂ­as - 20_dĂ­as == 0  0.56066    0.03832  14.633    <0.01 ***
## 30_dĂ­as - 25_dĂ­as == 0  0.07451    0.03832   1.945   0.7692    
## 35_dĂ­as - 25_dĂ­as == 0  0.10077    0.03832   2.630   0.2919    
## 40_dĂ­as - 25_dĂ­as == 0  0.23426    0.03832   6.114    <0.01 ***
## 45_dĂ­as - 25_dĂ­as == 0  0.26628    0.03832   6.950    <0.01 ***
## 50_dĂ­as - 25_dĂ­as == 0  0.30880    0.03832   8.059    <0.01 ***
## 55_dĂ­as - 25_dĂ­as == 0  0.39775    0.03832  10.381    <0.01 ***
## 60_dĂ­as - 25_dĂ­as == 0  0.52168    0.03832  13.616    <0.01 ***
## 35_dĂ­as - 30_dĂ­as == 0  0.02626    0.03832   0.685   1.0000    
## 40_dĂ­as - 30_dĂ­as == 0  0.15975    0.03832   4.169    <0.01 ** 
## 45_dĂ­as - 30_dĂ­as == 0  0.19177    0.03832   5.005    <0.01 ***
## 50_dĂ­as - 30_dĂ­as == 0  0.23429    0.03832   6.115    <0.01 ***
## 55_dĂ­as - 30_dĂ­as == 0  0.32324    0.03832   8.436    <0.01 ***
## 60_dĂ­as - 30_dĂ­as == 0  0.44717    0.03832  11.671    <0.01 ***
## 40_dĂ­as - 35_dĂ­as == 0  0.13349    0.03832   3.484   0.0286 *  
## 45_dĂ­as - 35_dĂ­as == 0  0.16551    0.03832   4.320    <0.01 ** 
## 50_dĂ­as - 35_dĂ­as == 0  0.20802    0.03832   5.429    <0.01 ***
## 55_dĂ­as - 35_dĂ­as == 0  0.29698    0.03832   7.751    <0.01 ***
## 60_dĂ­as - 35_dĂ­as == 0  0.42091    0.03832  10.985    <0.01 ***
## 45_dĂ­as - 40_dĂ­as == 0  0.03202    0.03832   0.836   0.9998    
## 50_dĂ­as - 40_dĂ­as == 0  0.07454    0.03832   1.945   0.7686    
## 55_dĂ­as - 40_dĂ­as == 0  0.16349    0.03832   4.267    <0.01 ** 
## 60_dĂ­as - 40_dĂ­as == 0  0.28742    0.03832   7.501    <0.01 ***
## 50_dĂ­as - 45_dĂ­as == 0  0.04252    0.03832   1.110   0.9967    
## 55_dĂ­as - 45_dĂ­as == 0  0.13147    0.03832   3.431   0.0337 *  
## 60_dĂ­as - 45_dĂ­as == 0  0.25540    0.03832   6.666    <0.01 ***
## 55_dĂ­as - 50_dĂ­as == 0  0.08896    0.03832   2.322   0.5012    
## 60_dĂ­as - 50_dĂ­as == 0  0.21289    0.03832   5.556    <0.01 ***
## 60_dĂ­as - 55_dĂ­as == 0  0.12393    0.03832   3.234   0.0637 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- single-step method)
# Obtener las letras de agrupamiento
cld_result <- cld(comp, level = 0.05)
## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps

## Warning in RET$pfunction("adjusted", ...): Completion with error > abseps
print(cld_result)
##  0_dĂ­as 05_dĂ­as 10_dĂ­as 15_dĂ­as 20_dĂ­as 25_dĂ­as 30_dĂ­as 35_dĂ­as 40_dĂ­as 45_dĂ­as 
##     "a"     "b"    "bc"    "bc"    "cd"    "ce"    "de"     "e"     "f"     "f" 
## 50_dĂ­as 55_dĂ­as 60_dĂ­as 
##    "fg"    "gh"     "h"
#Grupos significativamente diferentes: 
#0_dĂ­as, 05_dĂ­as, 35_dĂ­as.
#Grupos similares:
#10_dĂ­as y 15_dĂ­as.
#20_dĂ­as, 25_dĂ­as y 30_dĂ­as.
#40_dĂ­as y 45_dĂ­as.
#50_dĂ­as es similar a 40_dĂ­as y 45_dĂ­as.
#55_dĂ­as y 60_dĂ­as.
No me quizo cargar en el knit, sin embargo presento la Visualization del box plots with p-values
No me quizo cargar en el knit, sin embargo presento la Visualization del box plots with p-values