setwd("~/Library/CloudStorage/GoogleDrive-icarounam@gmail.com/Mi unidad/Agrosavia/Colaboraciones/René/1er_Cd/data")
datos<-read.table("percentage2.csv", header=T, sep=',')
datos$curva <- factor(datos$curva, levels = c("1", "2", "3"), 
                      labels = c("T3", "T1", "T2"))
datos$gen<-as.factor(datos$gen)
datos$curva<-as.factor(datos$curva)
datos$id<-as.factor(datos$id)
datos$muestra<-as.factor(datos$muestra)
datos$diam2<-as.factor(datos$diam2)
library(ggplot2)
library(Rmisc)
## Loading required package: lattice
## Loading required package: plyr
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.1.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ tibble  3.2.1     ✔ purrr   1.0.1
## ✔ tidyr   1.3.0     ✔ stringr 1.5.0
## ✔ readr   2.1.1     ✔ forcats 1.0.0
## Warning: package 'tibble' was built under R version 4.1.2
## Warning: package 'tidyr' was built under R version 4.1.2
## Warning: package 'purrr' was built under R version 4.1.2
## Warning: package 'stringr' was built under R version 4.1.2
## Warning: package 'forcats' was built under R version 4.1.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::arrange()   masks plyr::arrange()
## ✖ purrr::compact()   masks plyr::compact()
## ✖ dplyr::count()     masks plyr::count()
## ✖ dplyr::desc()      masks plyr::desc()
## ✖ dplyr::failwith()  masks plyr::failwith()
## ✖ dplyr::filter()    masks stats::filter()
## ✖ dplyr::id()        masks plyr::id()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ dplyr::mutate()    masks plyr::mutate()
## ✖ dplyr::rename()    masks plyr::rename()
## ✖ dplyr::summarise() masks plyr::summarise()
## ✖ dplyr::summarize() masks plyr::summarize()
library(ggpubr)
## 
## Attaching package: 'ggpubr'
## The following object is masked from 'package:plyr':
## 
##     mutate
library(rstatix)
## 
## Attaching package: 'rstatix'
## The following objects are masked from 'package:plyr':
## 
##     desc, mutate
## The following object is masked from 'package:stats':
## 
##     filter
library(emmeans)

## ITF
##Summary statistics
summ<-datos %>%
  group_by(curva, gen) %>%
  get_summary_stats(tf, type = "mean_sd")
summ %>% as_tibble() %>% print(n=Inf)
## # A tibble: 9 × 6
##   curva gen   variable     n  mean    sd
##   <fct> <fct> <chr>    <dbl> <dbl> <dbl>
## 1 T3    CCN51 tf           9 1.23  0.441
## 2 T3    ICS95 tf           9 1.14  0.331
## 3 T3    TCS01 tf           9 0.871 0.262
## 4 T1    CCN51 tf           9 1.53  0.396
## 5 T1    ICS95 tf           9 0.966 0.142
## 6 T1    TCS01 tf           9 0.962 0.192
## 7 T2    CCN51 tf           9 1.26  0.402
## 8 T2    ICS95 tf           9 0.81  0.132
## 9 T2    TCS01 tf           9 0.916 0.323
##Visualization
bxp <- ggboxplot(
  datos, x = "curva", y = "tf",
  palette = "jco",
  color = "gen", xlab = "Treatment", ylab = "ITF", legend.title = "Genotype"
)
bxp

##Check assumptions
##Outliers
datos %>%
  group_by(curva, gen) %>%
  identify_outliers(tf)
## # A tibble: 1 × 21
##   curva gen     ids trat  muestra id    diam2 cd.testa cd.grano pdcd.grano
##   <fct> <fct> <int> <chr> <fct>   <fct> <fct>    <dbl>    <dbl>      <dbl>
## 1 T2    ICS95    88 T2    14      22    6         11.3     10.2     -0.183
## # ℹ 11 more variables: picd.testa <dbl>, pdph.grano <dbl>, piph.testa <dbl>,
## #   ph.testa <dbl>, acidez.testa <dbl>, ph.grano <dbl>, acidez.grano <dbl>,
## #   tf <dbl>, pi.tf <dbl>, is.outlier <lgl>, is.extreme <lgl>
##Normality assumption
##Compute Shapiro-Wilk test for each combinations of factor levels:
norm<-datos %>%
  group_by(curva, gen) %>%
  shapiro_test(tf)
norm %>% as_tibble() %>% print(n=Inf)
## # A tibble: 9 × 5
##   curva gen   variable statistic      p
##   <fct> <fct> <chr>        <dbl>  <dbl>
## 1 T3    CCN51 tf           0.916 0.357 
## 2 T3    ICS95 tf           0.896 0.228 
## 3 T3    TCS01 tf           0.973 0.917 
## 4 T1    CCN51 tf           0.937 0.547 
## 5 T1    ICS95 tf           0.887 0.187 
## 6 T1    TCS01 tf           0.966 0.863 
## 7 T2    CCN51 tf           0.806 0.0238
## 8 T2    ICS95 tf           0.869 0.121 
## 9 T2    TCS01 tf           0.920 0.394
##Create QQ plot for each cell of design:
ggqqplot(datos, "tf", ggtheme = theme_bw()) +
  facet_grid(curva~ gen, labeller = "label_both")
## Warning: The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## Warning: The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

##Homogneity of variance assumption
##Compute the Levene’s test at each level of the within-subjects factor, here time variable:
lev<-datos %>%
  group_by(curva) %>%
  levene_test(tf ~ gen)
lev %>% as_tibble() %>% print(n=Inf)
## # A tibble: 3 × 5
##   curva   df1   df2 statistic      p
##   <fct> <int> <int>     <dbl>  <dbl>
## 1 T3        2    24      1.07 0.359 
## 2 T1        2    24      3.81 0.0366
## 3 T2        2    24      2.09 0.146
##Computation
res.aov <- anova_test(
  data = datos, dv = tf, wid = id,
  within = diam2, between = c(curva, gen)
)
res.aov
## ANOVA Table (type II tests)
## 
## $ANOVA
##            Effect DFn DFd       F        p p<.05   ges
## 1           curva   2  18   6.083 1.00e-02     * 0.241
## 2             gen   2  18  53.431 2.69e-08     * 0.736
## 3           diam2   2  36 156.491 1.75e-18     * 0.822
## 4       curva:gen   4  18   6.277 2.00e-03     * 0.396
## 5     curva:diam2   4  36   3.015 3.00e-02     * 0.151
## 6       gen:diam2   4  36  11.210 5.21e-06     * 0.397
## 7 curva:gen:diam2   8  36   2.873 1.40e-02     * 0.253
## 
## $`Mauchly's Test for Sphericity`
##            Effect     W     p p<.05
## 1           diam2 0.983 0.867      
## 2     curva:diam2 0.983 0.867      
## 3       gen:diam2 0.983 0.867      
## 4 curva:gen:diam2 0.983 0.867      
## 
## $`Sphericity Corrections`
##            Effect   GGe      DF[GG]    p[GG] p[GG]<.05   HFe      DF[HF]
## 1           diam2 0.984 1.97, 35.41 3.24e-18         * 1.103 2.21, 39.72
## 2     curva:diam2 0.984 3.93, 35.41 3.10e-02         * 1.103 4.41, 39.72
## 3       gen:diam2 0.984 3.93, 35.41 6.11e-06         * 1.103 4.41, 39.72
## 4 curva:gen:diam2 0.984 7.87, 35.41 1.50e-02         * 1.103 8.83, 39.72
##      p[HF] p[HF]<.05
## 1 1.75e-18         *
## 2 3.00e-02         *
## 3 5.21e-06         *
## 4 1.40e-02         *
get_anova_table(res.aov)
## ANOVA Table (type II tests)
## 
##            Effect DFn DFd       F        p p<.05   ges
## 1           curva   2  18   6.083 1.00e-02     * 0.241
## 2             gen   2  18  53.431 2.69e-08     * 0.736
## 3           diam2   2  36 156.491 1.75e-18     * 0.822
## 4       curva:gen   4  18   6.277 2.00e-03     * 0.396
## 5     curva:diam2   4  36   3.015 3.00e-02     * 0.151
## 6       gen:diam2   4  36  11.210 5.21e-06     * 0.397
## 7 curva:gen:diam2   8  36   2.873 1.40e-02     * 0.253
#Table by error
res.aov.error <- aov(tf ~ diam2*curva*gen + Error(id/diam2), datos)
res.aov.error
## 
## Call:
## aov(formula = tf ~ diam2 * curva * gen + Error(id/diam2), data = datos)
## 
## Grand Mean: 1.076272
## 
## Stratum 1: id
## 
## Terms:
##                     curva       gen curva:gen Residuals
## Sum of Squares  0.3267770 2.8702724 0.6743588 0.4834690
## Deg. of Freedom         2         2         4        18
## 
## Residual standard error: 0.1638883
## 16 out of 24 effects not estimable
## Estimated effects may be unbalanced
## 
## Stratum 2: id:diam2
## 
## Terms:
##                    diam2 diam2:curva diam2:gen diam2:curva:gen Residuals
## Sum of Squares  4.729690    0.182254  0.677613        0.347289  0.544020
## Deg. of Freedom        2           4         4               8        36
## 
## Residual standard error: 0.1229295
## Estimated effects may be unbalanced
summary(res.aov.error)
## 
## Error: id
##           Df Sum Sq Mean Sq F value   Pr(>F)    
## curva      2 0.3268  0.1634   6.083  0.00959 ** 
## gen        2 2.8703  1.4351  53.431 2.69e-08 ***
## curva:gen  4 0.6744  0.1686   6.277  0.00241 ** 
## Residuals 18 0.4835  0.0269                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: id:diam2
##                 Df Sum Sq Mean Sq F value   Pr(>F)    
## diam2            2  4.730  2.3648 156.491  < 2e-16 ***
## diam2:curva      4  0.182  0.0456   3.015   0.0304 *  
## diam2:gen        4  0.678  0.1694  11.210 5.21e-06 ***
## diam2:curva:gen  8  0.347  0.0434   2.873   0.0140 *  
## Residuals       36  0.544  0.0151                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Emmeans
emmip(res.aov.error, gen ~ diam2 | curva)
## Note: re-fitting model with sum-to-zero contrasts

emm_curva <- emmeans(res.aov.error, pairwise ~ curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_curva
## $emmeans
##  curva emmean     SE df lower.CL upper.CL
##  T3     1.081 0.0315 18     1.02     1.15
##  T1     1.151 0.0315 18     1.09     1.22
##  T2     0.996 0.0315 18     0.93     1.06
## 
## Results are averaged over the levels of: diam2, gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate     SE df t.ratio p.value
##  T3 - T1   -0.0701 0.0446 18  -1.573  0.2826
##  T3 - T2    0.0852 0.0446 18   1.910  0.1646
##  T1 - T2    0.1553 0.0446 18   3.483  0.0071
## 
## Results are averaged over the levels of: diam2, gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_curva <- emmeans(res.aov.error, pairwise ~ gen | curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_curva
## $emmeans
## curva = T3:
##  gen   emmean     SE df lower.CL upper.CL
##  CCN51  1.233 0.0546 18    1.118    1.348
##  ICS95  1.140 0.0546 18    1.026    1.255
##  TCS01  0.871 0.0546 18    0.756    0.985
## 
## curva = T1:
##  gen   emmean     SE df lower.CL upper.CL
##  CCN51  1.527 0.0546 18    1.412    1.642
##  ICS95  0.966 0.0546 18    0.851    1.080
##  TCS01  0.962 0.0546 18    0.847    1.077
## 
## curva = T2:
##  gen   emmean     SE df lower.CL upper.CL
##  CCN51  1.262 0.0546 18    1.147    1.377
##  ICS95  0.810 0.0546 18    0.695    0.925
##  TCS01  0.916 0.0546 18    0.802    1.031
## 
## Results are averaged over the levels of: diam2 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast      estimate     SE df t.ratio p.value
##  CCN51 - ICS95  0.09258 0.0773 18   1.198  0.4692
##  CCN51 - TCS01  0.36237 0.0773 18   4.690  0.0005
##  ICS95 - TCS01  0.26978 0.0773 18   3.492  0.0070
## 
## curva = T1:
##  contrast      estimate     SE df t.ratio p.value
##  CCN51 - ICS95  0.56119 0.0773 18   7.264  <.0001
##  CCN51 - TCS01  0.56473 0.0773 18   7.310  <.0001
##  ICS95 - TCS01  0.00354 0.0773 18   0.046  0.9988
## 
## curva = T2:
##  contrast      estimate     SE df t.ratio p.value
##  CCN51 - ICS95  0.45195 0.0773 18   5.850  <.0001
##  CCN51 - TCS01  0.34560 0.0773 18   4.473  0.0008
##  ICS95 - TCS01 -0.10635 0.0773 18  -1.377  0.3735
## 
## Results are averaged over the levels of: diam2 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_diam2 <- emmeans(res.aov.error, pairwise ~ curva*gen)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_diam2
## $emmeans
##  curva gen   emmean     SE df lower.CL upper.CL
##  T3    CCN51  1.233 0.0546 18    1.118    1.348
##  T1    CCN51  1.527 0.0546 18    1.412    1.642
##  T2    CCN51  1.262 0.0546 18    1.147    1.377
##  T3    ICS95  1.140 0.0546 18    1.026    1.255
##  T1    ICS95  0.966 0.0546 18    0.851    1.080
##  T2    ICS95  0.810 0.0546 18    0.695    0.925
##  T3    TCS01  0.871 0.0546 18    0.756    0.985
##  T1    TCS01  0.962 0.0546 18    0.847    1.077
##  T2    TCS01  0.916 0.0546 18    0.802    1.031
## 
## Results are averaged over the levels of: diam2 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast            estimate     SE df t.ratio p.value
##  T3 CCN51 - T1 CCN51 -0.29380 0.0773 18  -3.803  0.0276
##  T3 CCN51 - T2 CCN51 -0.02901 0.0773 18  -0.375  1.0000
##  T3 CCN51 - T3 ICS95  0.09258 0.0773 18   1.198  0.9467
##  T3 CCN51 - T1 ICS95  0.26739 0.0773 18   3.461  0.0544
##  T3 CCN51 - T2 ICS95  0.42295 0.0773 18   5.474  0.0009
##  T3 CCN51 - T3 TCS01  0.36237 0.0773 18   4.690  0.0045
##  T3 CCN51 - T1 TCS01  0.27093 0.0773 18   3.507  0.0497
##  T3 CCN51 - T2 TCS01  0.31659 0.0773 18   4.098  0.0152
##  T1 CCN51 - T2 CCN51  0.26480 0.0773 18   3.427  0.0580
##  T1 CCN51 - T3 ICS95  0.38639 0.0773 18   5.001  0.0023
##  T1 CCN51 - T1 ICS95  0.56119 0.0773 18   7.264  <.0001
##  T1 CCN51 - T2 ICS95  0.71675 0.0773 18   9.277  <.0001
##  T1 CCN51 - T3 TCS01  0.65617 0.0773 18   8.493  <.0001
##  T1 CCN51 - T1 TCS01  0.56473 0.0773 18   7.310  <.0001
##  T1 CCN51 - T2 TCS01  0.61040 0.0773 18   7.901  <.0001
##  T2 CCN51 - T3 ICS95  0.12159 0.0773 18   1.574  0.8064
##  T2 CCN51 - T1 ICS95  0.29639 0.0773 18   3.836  0.0258
##  T2 CCN51 - T2 ICS95  0.45195 0.0773 18   5.850  0.0004
##  T2 CCN51 - T3 TCS01  0.39137 0.0773 18   5.066  0.0020
##  T2 CCN51 - T1 TCS01  0.29994 0.0773 18   3.882  0.0235
##  T2 CCN51 - T2 TCS01  0.34560 0.0773 18   4.473  0.0070
##  T3 ICS95 - T1 ICS95  0.17480 0.0773 18   2.263  0.4105
##  T3 ICS95 - T2 ICS95  0.33036 0.0773 18   4.276  0.0105
##  T3 ICS95 - T3 TCS01  0.26978 0.0773 18   3.492  0.0512
##  T3 ICS95 - T1 TCS01  0.17835 0.0773 18   2.308  0.3861
##  T3 ICS95 - T2 TCS01  0.22401 0.0773 18   2.900  0.1536
##  T1 ICS95 - T2 ICS95  0.15556 0.0773 18   2.014  0.5536
##  T1 ICS95 - T3 TCS01  0.09498 0.0773 18   1.229  0.9390
##  T1 ICS95 - T1 TCS01  0.00354 0.0773 18   0.046  1.0000
##  T1 ICS95 - T2 TCS01  0.04921 0.0773 18   0.637  0.9990
##  T2 ICS95 - T3 TCS01 -0.06058 0.0773 18  -0.784  0.9960
##  T2 ICS95 - T1 TCS01 -0.15201 0.0773 18  -1.968  0.5812
##  T2 ICS95 - T2 TCS01 -0.10635 0.0773 18  -1.377  0.8927
##  T3 TCS01 - T1 TCS01 -0.09144 0.0773 18  -1.184  0.9502
##  T3 TCS01 - T2 TCS01 -0.04577 0.0773 18  -0.592  0.9994
##  T1 TCS01 - T2 TCS01  0.04566 0.0773 18   0.591  0.9994
## 
## Results are averaged over the levels of: diam2 
## P value adjustment: tukey method for comparing a family of 9 estimates
emm_gen_diam2_trend <- emmeans(res.aov.error, pairwise ~ gen)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_diam2_trend
## $emmeans
##  gen   emmean     SE df lower.CL upper.CL
##  CCN51  1.341 0.0315 18    1.274    1.407
##  ICS95  0.972 0.0315 18    0.906    1.038
##  TCS01  0.916 0.0315 18    0.850    0.983
## 
## Results are averaged over the levels of: diam2, curva 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast      estimate     SE df t.ratio p.value
##  CCN51 - ICS95   0.3686 0.0446 18   8.263  <.0001
##  CCN51 - TCS01   0.4242 0.0446 18   9.511  <.0001
##  ICS95 - TCS01   0.0557 0.0446 18   1.248  0.4416
## 
## Results are averaged over the levels of: diam2, curva 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_diam2 <- emmeans(res.aov.error, pairwise ~ diam2)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_diam2
## $emmeans
##  diam2 emmean     SE   df lower.CL upper.CL
##  2      0.753 0.0265 49.8    0.699    0.806
##  5      1.143 0.0265 49.8    1.089    1.196
##  6      1.333 0.0265 49.8    1.280    1.387
## 
## Results are averaged over the levels of: curva, gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate     SE df t.ratio p.value
##  2 - 5      -0.390 0.0335 36 -11.657  <.0001
##  2 - 6      -0.581 0.0335 36 -17.353  <.0001
##  5 - 6      -0.191 0.0335 36  -5.696  <.0001
## 
## Results are averaged over the levels of: curva, gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_diam2_curva <- emmeans(res.aov.error, pairwise ~ diam2 | curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_diam2_curva
## $emmeans
## curva = T3:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.683 0.046 49.8    0.591    0.775
##  5      1.144 0.046 49.8    1.052    1.236
##  6      1.417 0.046 49.8    1.324    1.509
## 
## curva = T1:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.872 0.046 49.8    0.779    0.964
##  5      1.242 0.046 49.8    1.149    1.334
##  6      1.341 0.046 49.8    1.249    1.434
## 
## curva = T2:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.704 0.046 49.8    0.611    0.796
##  5      1.043 0.046 49.8    0.950    1.135
##  6      1.242 0.046 49.8    1.150    1.334
## 
## Results are averaged over the levels of: gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast estimate     SE df t.ratio p.value
##  2 - 5     -0.4611 0.0579 36  -7.957  <.0001
##  2 - 6     -0.7338 0.0579 36 -12.664  <.0001
##  5 - 6     -0.2727 0.0579 36  -4.706  0.0001
## 
## curva = T1:
##  contrast estimate     SE df t.ratio p.value
##  2 - 5     -0.3700 0.0579 36  -6.384  <.0001
##  2 - 6     -0.4696 0.0579 36  -8.104  <.0001
##  5 - 6     -0.0996 0.0579 36  -1.720  0.2118
## 
## curva = T2:
##  contrast estimate     SE df t.ratio p.value
##  2 - 5     -0.3390 0.0579 36  -5.849  <.0001
##  2 - 6     -0.5383 0.0579 36  -9.290  <.0001
##  5 - 6     -0.1994 0.0579 36  -3.441  0.0041
## 
## Results are averaged over the levels of: gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
## PI-ITF
##Summary statistics
summ<-datos %>%
  group_by(curva, gen) %>%
  get_summary_stats(pi.tf, type = "mean_sd")
summ %>% as_tibble() %>% print(n=Inf)
## # A tibble: 9 × 6
##   curva gen   variable     n  mean    sd
##   <fct> <fct> <chr>    <dbl> <dbl> <dbl>
## 1 T3    CCN51 pi.tf        9 1.88  1.07 
## 2 T3    ICS95 pi.tf        9 1.44  0.785
## 3 T3    TCS01 pi.tf        9 1.95  0.849
## 4 T1    CCN51 pi.tf        9 1.67  1.17 
## 5 T1    ICS95 pi.tf        9 0.517 0.227
## 6 T1    TCS01 pi.tf        9 0.997 0.548
## 7 T2    CCN51 pi.tf        9 0.801 0.577
## 8 T2    ICS95 pi.tf        9 0.433 0.203
## 9 T2    TCS01 pi.tf        9 1.04  0.693
##Visualization
bxp <- ggboxplot(
  datos, x = "curva", y = "pi.tf",
  palette = "jco",
  color = "gen", xlab = "Treatment", ylab = "PI-ITF", legend.title = "Genotype"
)
bxp

##Check assumptions
##Outliers
datos %>%
  group_by(curva, gen) %>%
  identify_outliers(pi.tf)
## # A tibble: 4 × 21
##   curva gen     ids trat  muestra id    diam2 cd.testa cd.grano pdcd.grano
##   <fct> <fct> <int> <chr> <fct>   <fct> <fct>    <dbl>    <dbl>      <dbl>
## 1 T3    TCS01    32 T3    25      8     6         8.89     7.02     -0.260
## 2 T1    CCN51    39 T1    14      10    5        12.0      7.68     -0.232
## 3 T1    CCN51    40 T1    14      10    6        13.7      7.64     -0.235
## 4 T2    ICS95    88 T2    14      22    6        11.3     10.2      -0.183
## # ℹ 11 more variables: picd.testa <dbl>, pdph.grano <dbl>, piph.testa <dbl>,
## #   ph.testa <dbl>, acidez.testa <dbl>, ph.grano <dbl>, acidez.grano <dbl>,
## #   tf <dbl>, pi.tf <dbl>, is.outlier <lgl>, is.extreme <lgl>
##Normality assumption
##Compute Shapiro-Wilk test for each combinations of factor levels:
norm<-datos %>%
  group_by(curva, gen) %>%
  shapiro_test(pi.tf)
norm %>% as_tibble() %>% print(n=Inf)
## # A tibble: 9 × 5
##   curva gen   variable statistic      p
##   <fct> <fct> <chr>        <dbl>  <dbl>
## 1 T3    CCN51 pi.tf        0.948 0.672 
## 2 T3    ICS95 pi.tf        0.943 0.609 
## 3 T3    TCS01 pi.tf        0.968 0.876 
## 4 T1    CCN51 pi.tf        0.909 0.311 
## 5 T1    ICS95 pi.tf        0.910 0.317 
## 6 T1    TCS01 pi.tf        0.940 0.581 
## 7 T2    CCN51 pi.tf        0.842 0.0613
## 8 T2    ICS95 pi.tf        0.952 0.707 
## 9 T2    TCS01 pi.tf        0.925 0.433
##Create QQ plot for each cell of design:
ggqqplot(datos, "pi.tf", ggtheme = theme_bw()) +
  facet_grid(curva~ gen, labeller = "label_both")
## Warning: The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

##Homogneity of variance assumption
##Compute the Levene’s test at each level of the within-subjects factor, here time variable:
lev<-datos %>%
  group_by(curva) %>%
  levene_test(pi.tf ~ gen)
lev %>% as_tibble() %>% print(n=Inf)
## # A tibble: 3 × 5
##   curva   df1   df2 statistic      p
##   <fct> <int> <int>     <dbl>  <dbl>
## 1 T3        2    24     0.633 0.540 
## 2 T1        2    24     3.57  0.0438
## 3 T2        2    24     2.58  0.0966
#Table by error
res.aov.error <- aov(pi.tf ~ diam2*curva*gen + Error(id/diam2), datos)
res.aov.error
## 
## Call:
## aov(formula = pi.tf ~ diam2 * curva * gen + Error(id/diam2), 
##     data = datos)
## 
## Grand Mean: 1.191778
## 
## Stratum 1: id
## 
## Terms:
##                     curva       gen curva:gen Residuals
## Sum of Squares  14.036789  6.568553  2.580395 10.130900
## Deg. of Freedom         2         2         4        18
## 
## Residual standard error: 0.7502185
## 16 out of 24 effects not estimable
## Estimated effects may be unbalanced
## 
## Stratum 2: id:diam2
## 
## Terms:
##                     diam2 diam2:curva diam2:gen diam2:curva:gen Residuals
## Sum of Squares  20.804200    2.729280  2.109180        0.925020  3.765823
## Deg. of Freedom         2           4         4               8        36
## 
## Residual standard error: 0.3234288
## Estimated effects may be unbalanced
summary(res.aov.error)
## 
## Error: id
##           Df Sum Sq Mean Sq F value Pr(>F)    
## curva      2 14.037   7.018  12.470 0.0004 ***
## gen        2  6.569   3.284   5.835 0.0111 *  
## curva:gen  4  2.580   0.645   1.146 0.3668    
## Residuals 18 10.131   0.563                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: id:diam2
##                 Df Sum Sq Mean Sq F value   Pr(>F)    
## diam2            2 20.804  10.402  99.441 2.18e-15 ***
## diam2:curva      4  2.729   0.682   6.523 0.000469 ***
## diam2:gen        4  2.109   0.527   5.041 0.002490 ** 
## diam2:curva:gen  8  0.925   0.116   1.105 0.382569    
## Residuals       36  3.766   0.105                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Emmeans
emmip(res.aov.error, gen ~ diam2 | curva)
## Note: re-fitting model with sum-to-zero contrasts

emm_curva <- emmeans(res.aov.error, pairwise ~ curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_curva
## $emmeans
##  curva emmean    SE df lower.CL upper.CL
##  T3     1.754 0.144 18    1.450     2.06
##  T1     1.062 0.144 18    0.759     1.37
##  T2     0.759 0.144 18    0.456     1.06
## 
## Results are averaged over the levels of: diam2, gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate    SE df t.ratio p.value
##  T3 - T1     0.691 0.204 18   3.386  0.0088
##  T3 - T2     0.995 0.204 18   4.872  0.0003
##  T1 - T2     0.303 0.204 18   1.486  0.3207
## 
## Results are averaged over the levels of: diam2, gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_curva <- emmeans(res.aov.error, pairwise ~ gen | curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_curva
## $emmeans
## curva = T3:
##  gen   emmean   SE df lower.CL upper.CL
##  CCN51  1.880 0.25 18   1.3548    2.406
##  ICS95  1.436 0.25 18   0.9102    1.961
##  TCS01  1.946 0.25 18   1.4203    2.471
## 
## curva = T1:
##  gen   emmean   SE df lower.CL upper.CL
##  CCN51  1.673 0.25 18   1.1476    2.198
##  ICS95  0.517 0.25 18  -0.0081    1.043
##  TCS01  0.997 0.25 18   0.4718    1.523
## 
## curva = T2:
##  gen   emmean   SE df lower.CL upper.CL
##  CCN51  0.801 0.25 18   0.2759    1.327
##  ICS95  0.433 0.25 18  -0.0921    0.959
##  TCS01  1.043 0.25 18   0.5172    1.568
## 
## Results are averaged over the levels of: diam2 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast      estimate    SE df t.ratio p.value
##  CCN51 - ICS95   0.4446 0.354 18   1.257  0.4364
##  CCN51 - TCS01  -0.0654 0.354 18  -0.185  0.9813
##  ICS95 - TCS01  -0.5101 0.354 18  -1.442  0.3412
## 
## curva = T1:
##  contrast      estimate    SE df t.ratio p.value
##  CCN51 - ICS95   1.1557 0.354 18   3.268  0.0113
##  CCN51 - TCS01   0.6758 0.354 18   1.911  0.1644
##  ICS95 - TCS01  -0.4799 0.354 18  -1.357  0.3835
## 
## curva = T2:
##  contrast      estimate    SE df t.ratio p.value
##  CCN51 - ICS95   0.3681 0.354 18   1.041  0.5616
##  CCN51 - TCS01  -0.2412 0.354 18  -0.682  0.7767
##  ICS95 - TCS01  -0.6093 0.354 18  -1.723  0.2241
## 
## Results are averaged over the levels of: diam2 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_diam2 <- emmeans(res.aov.error, pairwise ~ curva*gen)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_diam2
## $emmeans
##  curva gen   emmean   SE df lower.CL upper.CL
##  T3    CCN51  1.880 0.25 18   1.3548    2.406
##  T1    CCN51  1.673 0.25 18   1.1476    2.198
##  T2    CCN51  0.801 0.25 18   0.2759    1.327
##  T3    ICS95  1.436 0.25 18   0.9102    1.961
##  T1    ICS95  0.517 0.25 18  -0.0081    1.043
##  T2    ICS95  0.433 0.25 18  -0.0921    0.959
##  T3    TCS01  1.946 0.25 18   1.4203    2.471
##  T1    TCS01  0.997 0.25 18   0.4718    1.523
##  T2    TCS01  1.043 0.25 18   0.5172    1.568
## 
## Results are averaged over the levels of: diam2 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast            estimate    SE df t.ratio p.value
##  T3 CCN51 - T1 CCN51   0.2073 0.354 18   0.586  0.9995
##  T3 CCN51 - T2 CCN51   1.0789 0.354 18   3.051  0.1175
##  T3 CCN51 - T3 ICS95   0.4446 0.354 18   1.257  0.9314
##  T3 CCN51 - T1 ICS95   1.3629 0.354 18   3.854  0.0249
##  T3 CCN51 - T2 ICS95   1.4470 0.354 18   4.091  0.0154
##  T3 CCN51 - T3 TCS01  -0.0654 0.354 18  -0.185  1.0000
##  T3 CCN51 - T1 TCS01   0.8830 0.354 18   2.497  0.2952
##  T3 CCN51 - T2 TCS01   0.8377 0.354 18   2.369  0.3555
##  T1 CCN51 - T2 CCN51   0.8716 0.354 18   2.465  0.3097
##  T1 CCN51 - T3 ICS95   0.2374 0.354 18   0.671  0.9986
##  T1 CCN51 - T1 ICS95   1.1557 0.354 18   3.268  0.0787
##  T1 CCN51 - T2 ICS95   1.2397 0.354 18   3.505  0.0498
##  T1 CCN51 - T3 TCS01  -0.2727 0.354 18  -0.771  0.9964
##  T1 CCN51 - T1 TCS01   0.6758 0.354 18   1.911  0.6156
##  T1 CCN51 - T2 TCS01   0.6304 0.354 18   1.783  0.6921
##  T2 CCN51 - T3 ICS95  -0.6343 0.354 18  -1.793  0.6857
##  T2 CCN51 - T1 ICS95   0.2840 0.354 18   0.803  0.9953
##  T2 CCN51 - T2 ICS95   0.3681 0.354 18   1.041  0.9759
##  T2 CCN51 - T3 TCS01  -1.1444 0.354 18  -3.236  0.0836
##  T2 CCN51 - T1 TCS01  -0.1959 0.354 18  -0.554  0.9997
##  T2 CCN51 - T2 TCS01  -0.2412 0.354 18  -0.682  0.9985
##  T3 ICS95 - T1 ICS95   0.9183 0.354 18   2.597  0.2535
##  T3 ICS95 - T2 ICS95   1.0023 0.354 18   2.834  0.1718
##  T3 ICS95 - T3 TCS01  -0.5101 0.354 18  -1.442  0.8668
##  T3 ICS95 - T1 TCS01   0.4384 0.354 18   1.240  0.9363
##  T3 ICS95 - T2 TCS01   0.3930 0.354 18   1.111  0.9648
##  T1 ICS95 - T2 ICS95   0.0840 0.354 18   0.238  1.0000
##  T1 ICS95 - T3 TCS01  -1.4284 0.354 18  -4.039  0.0171
##  T1 ICS95 - T1 TCS01  -0.4799 0.354 18  -1.357  0.8997
##  T1 ICS95 - T2 TCS01  -0.5253 0.354 18  -1.485  0.8484
##  T2 ICS95 - T3 TCS01  -1.5124 0.354 18  -4.277  0.0105
##  T2 ICS95 - T1 TCS01  -0.5640 0.354 18  -1.595  0.7959
##  T2 ICS95 - T2 TCS01  -0.6093 0.354 18  -1.723  0.7265
##  T3 TCS01 - T1 TCS01   0.9485 0.354 18   2.682  0.2213
##  T3 TCS01 - T2 TCS01   0.9031 0.354 18   2.554  0.2709
##  T1 TCS01 - T2 TCS01  -0.0453 0.354 18  -0.128  1.0000
## 
## Results are averaged over the levels of: diam2 
## P value adjustment: tukey method for comparing a family of 9 estimates
emm_gen_diam2_trend <- emmeans(res.aov.error, pairwise ~ gen)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_diam2_trend
## $emmeans
##  gen   emmean    SE df lower.CL upper.CL
##  CCN51  1.451 0.144 18    1.148     1.75
##  ICS95  0.795 0.144 18    0.492     1.10
##  TCS01  1.328 0.144 18    1.025     1.63
## 
## Results are averaged over the levels of: diam2, curva 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast      estimate    SE df t.ratio p.value
##  CCN51 - ICS95    0.656 0.204 18   3.213  0.0127
##  CCN51 - TCS01    0.123 0.204 18   0.603  0.8205
##  ICS95 - TCS01   -0.533 0.204 18  -2.611  0.0445
## 
## Results are averaged over the levels of: diam2, curva 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_diam2 <- emmeans(res.aov.error, pairwise ~ diam2)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_diam2
## $emmeans
##  diam2 emmean     SE   df lower.CL upper.CL
##  2       0.52 0.0976 31.7    0.322    0.719
##  5       1.31 0.0976 31.7    1.111    1.509
##  6       1.74 0.0976 31.7    1.546    1.944
## 
## Results are averaged over the levels of: curva, gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate    SE df t.ratio p.value
##  2 - 5      -0.790 0.088 36  -8.970  <.0001
##  2 - 6      -1.224 0.088 36 -13.909  <.0001
##  5 - 6      -0.435 0.088 36  -4.940  0.0001
## 
## Results are averaged over the levels of: curva, gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_diam2_curva <- emmeans(res.aov.error, pairwise ~ diam2 | curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_diam2_curva
## $emmeans
## curva = T3:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.755 0.169 31.7   0.4104    1.100
##  5      1.903 0.169 31.7   1.5586    2.248
##  6      2.603 0.169 31.7   2.2587    2.948
## 
## curva = T1:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.554 0.169 31.7   0.2097    0.899
##  5      1.213 0.169 31.7   0.8685    1.558
##  6      1.420 0.169 31.7   1.0755    1.765
## 
## curva = T2:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.252 0.169 31.7  -0.0925    0.597
##  5      0.814 0.169 31.7   0.4692    1.158
##  6      1.211 0.169 31.7   0.8666    1.556
## 
## Results are averaged over the levels of: gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5      -1.148 0.152 36  -7.531  <.0001
##  2 - 6      -1.848 0.152 36 -12.123  <.0001
##  5 - 6      -0.700 0.152 36  -4.592  0.0002
## 
## curva = T1:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5      -0.659 0.152 36  -4.321  0.0003
##  2 - 6      -0.866 0.152 36  -5.678  <.0001
##  5 - 6      -0.207 0.152 36  -1.357  0.3736
## 
## curva = T2:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5      -0.562 0.152 36  -3.684  0.0021
##  2 - 6      -0.959 0.152 36  -6.290  <.0001
##  5 - 6      -0.397 0.152 36  -2.606  0.0345
## 
## Results are averaged over the levels of: gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
## PD-Cd
##Summary statistics
summ<-datos %>%
  group_by(curva, gen) %>%
  get_summary_stats(pdcd.grano, type = "mean_sd")
summ %>% as_tibble() %>% print(n=Inf)
## # A tibble: 9 × 6
##   curva gen   variable       n   mean    sd
##   <fct> <fct> <chr>      <dbl>  <dbl> <dbl>
## 1 T3    CCN51 pdcd.grano     9 -0.106 0.074
## 2 T3    ICS95 pdcd.grano     9 -0.074 0.066
## 3 T3    TCS01 pdcd.grano     9 -0.192 0.104
## 4 T1    CCN51 pdcd.grano     9 -0.162 0.062
## 5 T1    ICS95 pdcd.grano     9 -0.08  0.05 
## 6 T1    TCS01 pdcd.grano     9 -0.134 0.114
## 7 T2    CCN51 pdcd.grano     9 -0.121 0.089
## 8 T2    ICS95 pdcd.grano     9 -0.074 0.05 
## 9 T2    TCS01 pdcd.grano     9 -0.122 0.105
##Visualization
bxp <- ggboxplot(
  datos, x = "curva", y = "pdcd.grano",
  palette = "jco",
  color = "gen", xlab = "Treatment", ylab = "PD-Cd", legend.title = "Genotype"
)
bxp

##Check assumptions
##Outliers
datos %>%
  group_by(curva, gen) %>%
  identify_outliers(pdcd.grano)
## # A tibble: 3 × 21
##   curva gen     ids trat  muestra id    diam2 cd.testa cd.grano pdcd.grano
##   <fct> <fct> <int> <chr> <fct>   <fct> <fct>    <dbl>    <dbl>      <dbl>
## 1 T3    ICS95    24 T3    36      6     6        14.4      9.48     -0.197
## 2 T1    ICS95    60 T1    36      15    6         8.69     8.06     -0.185
## 3 T2    ICS95    88 T2    14      22    6        11.3     10.2      -0.183
## # ℹ 11 more variables: picd.testa <dbl>, pdph.grano <dbl>, piph.testa <dbl>,
## #   ph.testa <dbl>, acidez.testa <dbl>, ph.grano <dbl>, acidez.grano <dbl>,
## #   tf <dbl>, pi.tf <dbl>, is.outlier <lgl>, is.extreme <lgl>
##Normality assumption
##Compute Shapiro-Wilk test for each combinations of factor levels:
norm<-datos %>%
  group_by(curva, gen) %>%
  shapiro_test(pdcd.grano)
norm %>% as_tibble() %>% print(n=Inf)
## # A tibble: 9 × 5
##   curva gen   variable   statistic      p
##   <fct> <fct> <chr>          <dbl>  <dbl>
## 1 T3    CCN51 pdcd.grano     0.907 0.297 
## 2 T3    ICS95 pdcd.grano     0.852 0.0783
## 3 T3    TCS01 pdcd.grano     0.966 0.856 
## 4 T1    CCN51 pdcd.grano     0.945 0.632 
## 5 T1    ICS95 pdcd.grano     0.905 0.282 
## 6 T1    TCS01 pdcd.grano     0.893 0.215 
## 7 T2    CCN51 pdcd.grano     0.917 0.369 
## 8 T2    ICS95 pdcd.grano     0.916 0.360 
## 9 T2    TCS01 pdcd.grano     0.844 0.0642
##Create QQ plot for each cell of design:
ggqqplot(datos, "pdcd.grano", ggtheme = theme_bw()) +
  facet_grid(curva~ gen, labeller = "label_both")
## Warning: The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

##Homogneity of variance assumption

##Compute the Levene’s test at each level of the within-subjects factor, here time variable:
lev<-datos %>%
  group_by(curva) %>%
  levene_test(pdcd.grano ~ gen)
lev %>% as_tibble() %>% print(n=Inf)
## # A tibble: 3 × 5
##   curva   df1   df2 statistic      p
##   <fct> <int> <int>     <dbl>  <dbl>
## 1 T3        2    24     0.868 0.432 
## 2 T1        2    24     2.74  0.0845
## 3 T2        2    24     2.03  0.154
##Computation
res.aov <- anova_test(
  data = datos, dv = pdcd.grano, wid = id,
  within = diam2, between = c(curva, gen)
)
res.aov
## ANOVA Table (type II tests)
## 
## $ANOVA
##            Effect DFn DFd      F        p p<.05   ges
## 1           curva   2  18  0.241 7.89e-01       0.023
## 2             gen   2  18  2.918 8.00e-02       0.221
## 3           diam2   2  36 90.975 8.38e-15     * 0.384
## 4       curva:gen   4  18  0.634 6.45e-01       0.110
## 5     curva:diam2   4  36  5.825 1.00e-03     * 0.074
## 6       gen:diam2   4  36  1.669 1.79e-01       0.022
## 7 curva:gen:diam2   8  36  2.783 1.70e-02     * 0.071
## 
## $`Mauchly's Test for Sphericity`
##            Effect     W     p p<.05
## 1           diam2 0.867 0.297      
## 2     curva:diam2 0.867 0.297      
## 3       gen:diam2 0.867 0.297      
## 4 curva:gen:diam2 0.867 0.297      
## 
## $`Sphericity Corrections`
##            Effect   GGe      DF[GG]    p[GG] p[GG]<.05   HFe      DF[HF]
## 1           diam2 0.883 1.77, 31.77 2.56e-13         * 0.971 1.94, 34.97
## 2     curva:diam2 0.883 3.53, 31.77 2.00e-03         * 0.971 3.89, 34.97
## 3       gen:diam2 0.883 3.53, 31.77 1.87e-01           0.971 3.89, 34.97
## 4 curva:gen:diam2 0.883 7.06, 31.77 2.20e-02         * 0.971 7.77, 34.97
##      p[HF] p[HF]<.05
## 1 1.93e-14         *
## 2 1.00e-03         *
## 3 1.81e-01          
## 4 1.80e-02         *
get_anova_table(res.aov)
## ANOVA Table (type II tests)
## 
##            Effect DFn DFd      F        p p<.05   ges
## 1           curva   2  18  0.241 7.89e-01       0.023
## 2             gen   2  18  2.918 8.00e-02       0.221
## 3           diam2   2  36 90.975 8.38e-15     * 0.384
## 4       curva:gen   4  18  0.634 6.45e-01       0.110
## 5     curva:diam2   4  36  5.825 1.00e-03     * 0.074
## 6       gen:diam2   4  36  1.669 1.79e-01       0.022
## 7 curva:gen:diam2   8  36  2.783 1.70e-02     * 0.071
#Table by error
res.aov.error <- aov(pdcd.grano ~ diam2*curva*gen + Error(id/diam2), datos)
res.aov.error
## 
## Call:
## aov(formula = pdcd.grano ~ diam2 * curva * gen + Error(id/diam2), 
##     data = datos)
## 
## Grand Mean: -0.1183527
## 
## Stratum 1: id
## 
## Terms:
##                      curva        gen  curva:gen  Residuals
## Sum of Squares  0.00644012 0.07806532 0.03390014 0.24078781
## Deg. of Freedom          2          2          4         18
## 
## Residual standard error: 0.1156594
## 16 out of 24 effects not estimable
## Estimated effects may be unbalanced
## 
## Stratum 2: id:diam2
## 
## Terms:
##                      diam2 diam2:curva  diam2:gen diam2:curva:gen  Residuals
## Sum of Squares  0.17081800  0.02187461 0.00626723      0.02090317 0.03379761
## Deg. of Freedom          2           4          4               8         36
## 
## Residual standard error: 0.03064021
## Estimated effects may be unbalanced
summary(res.aov.error)
## 
## Error: id
##           Df  Sum Sq Mean Sq F value Pr(>F)  
## curva      2 0.00644 0.00322   0.241 0.7886  
## gen        2 0.07807 0.03903   2.918 0.0799 .
## curva:gen  4 0.03390 0.00848   0.634 0.6450  
## Residuals 18 0.24079 0.01338                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: id:diam2
##                 Df  Sum Sq Mean Sq F value   Pr(>F)    
## diam2            2 0.17082 0.08541  90.975 8.38e-15 ***
## diam2:curva      4 0.02187 0.00547   5.825  0.00101 ** 
## diam2:gen        4 0.00627 0.00157   1.669  0.17856    
## diam2:curva:gen  8 0.02090 0.00261   2.783  0.01661 *  
## Residuals       36 0.03380 0.00094                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Emmeans
emmip(res.aov.error, gen ~ diam2 | curva)
## Note: re-fitting model with sum-to-zero contrasts

emm_curva <- emmeans(res.aov.error, pairwise ~ curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_curva
## $emmeans
##  curva emmean     SE df lower.CL upper.CL
##  T3    -0.124 0.0223 18   -0.171  -0.0772
##  T1    -0.125 0.0223 18   -0.172  -0.0786
##  T2    -0.106 0.0223 18   -0.153  -0.0590
## 
## Results are averaged over the levels of: diam2, gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate     SE df t.ratio p.value
##  T3 - T1   0.00137 0.0315 18   0.044  0.9990
##  T3 - T2  -0.01819 0.0315 18  -0.578  0.8335
##  T1 - T2  -0.01956 0.0315 18  -0.622  0.8103
## 
## Results are averaged over the levels of: diam2, gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_curva <- emmeans(res.aov.error, pairwise ~ gen | curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_curva
## $emmeans
## curva = T3:
##  gen    emmean     SE df lower.CL upper.CL
##  CCN51 -0.1060 0.0386 18   -0.187 -0.02496
##  ICS95 -0.0741 0.0386 18   -0.155  0.00693
##  TCS01 -0.1918 0.0386 18   -0.273 -0.11085
## 
## curva = T1:
##  gen    emmean     SE df lower.CL upper.CL
##  CCN51 -0.1621 0.0386 18   -0.243 -0.08108
##  ICS95 -0.0797 0.0386 18   -0.161  0.00132
##  TCS01 -0.1343 0.0386 18   -0.215 -0.05325
## 
## curva = T2:
##  gen    emmean     SE df lower.CL upper.CL
##  CCN51 -0.1211 0.0386 18   -0.202 -0.04008
##  ICS95 -0.0741 0.0386 18   -0.155  0.00689
##  TCS01 -0.1221 0.0386 18   -0.203 -0.04113
## 
## Results are averaged over the levels of: diam2 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast      estimate     SE df t.ratio p.value
##  CCN51 - ICS95 -0.03189 0.0545 18  -0.585  0.8299
##  CCN51 - TCS01  0.08589 0.0545 18   1.575  0.2814
##  ICS95 - TCS01  0.11778 0.0545 18   2.160  0.1057
## 
## curva = T1:
##  contrast      estimate     SE df t.ratio p.value
##  CCN51 - ICS95 -0.08240 0.0545 18  -1.511  0.3093
##  CCN51 - TCS01 -0.02782 0.0545 18  -0.510  0.8673
##  ICS95 - TCS01  0.05458 0.0545 18   1.001  0.5857
## 
## curva = T2:
##  contrast      estimate     SE df t.ratio p.value
##  CCN51 - ICS95 -0.04697 0.0545 18  -0.862  0.6706
##  CCN51 - TCS01  0.00105 0.0545 18   0.019  0.9998
##  ICS95 - TCS01  0.04802 0.0545 18   0.881  0.6589
## 
## Results are averaged over the levels of: diam2 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_diam2 <- emmeans(res.aov.error, pairwise ~ diam2 | curva*gen)
## Note: re-fitting model with sum-to-zero contrasts
emm_gen_diam2
## $emmeans
## curva = T3, gen = CCN51:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.0580 0.0412 23.2   -0.143  0.027121
##  5     -0.1071 0.0412 23.2   -0.192 -0.021958
##  6     -0.1528 0.0412 23.2   -0.238 -0.067644
## 
## curva = T1, gen = CCN51:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.1213 0.0412 23.2   -0.206 -0.036186
##  5     -0.1721 0.0412 23.2   -0.257 -0.086960
##  6     -0.1928 0.0412 23.2   -0.278 -0.107680
## 
## curva = T2, gen = CCN51:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.0399 0.0412 23.2   -0.125  0.045262
##  5     -0.1073 0.0412 23.2   -0.192 -0.022143
##  6     -0.2161 0.0412 23.2   -0.301 -0.130954
## 
## curva = T3, gen = ICS95:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.0231 0.0412 23.2   -0.108  0.062048
##  5     -0.0684 0.0412 23.2   -0.154  0.016700
##  6     -0.1307 0.0412 23.2   -0.216 -0.045567
## 
## curva = T1, gen = ICS95:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.0392 0.0412 23.2   -0.124  0.045882
##  5     -0.0714 0.0412 23.2   -0.157  0.013683
##  6     -0.1283 0.0412 23.2   -0.213 -0.043192
## 
## curva = T2, gen = ICS95:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.0501 0.0412 23.2   -0.135  0.035048
##  5     -0.0597 0.0412 23.2   -0.145  0.025412
##  6     -0.1125 0.0412 23.2   -0.198 -0.027379
## 
## curva = T3, gen = TCS01:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.1271 0.0412 23.2   -0.212 -0.041989
##  5     -0.1886 0.0412 23.2   -0.274 -0.103512
##  6     -0.2598 0.0412 23.2   -0.345 -0.174653
## 
## curva = T1, gen = TCS01:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.1121 0.0412 23.2   -0.197 -0.026965
##  5     -0.1369 0.0412 23.2   -0.222 -0.051787
##  6     -0.1537 0.0412 23.2   -0.239 -0.068609
## 
## curva = T2, gen = TCS01:
##  diam2  emmean     SE   df lower.CL  upper.CL
##  2     -0.0261 0.0412 23.2   -0.111  0.059008
##  5     -0.0847 0.0412 23.2   -0.170  0.000429
##  6     -0.2555 0.0412 23.2   -0.341 -0.170417
## 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3, gen = CCN51:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.04908 0.025 36   1.962  0.1364
##  2 - 6     0.09477 0.025 36   3.788  0.0016
##  5 - 6     0.04569 0.025 36   1.826  0.1755
## 
## curva = T1, gen = CCN51:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.05077 0.025 36   2.030  0.1197
##  2 - 6     0.07149 0.025 36   2.858  0.0189
##  5 - 6     0.02072 0.025 36   0.828  0.6882
## 
## curva = T2, gen = CCN51:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.06740 0.025 36   2.694  0.0280
##  2 - 6     0.17622 0.025 36   7.044  <.0001
##  5 - 6     0.10881 0.025 36   4.349  0.0003
## 
## curva = T3, gen = ICS95:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.04535 0.025 36   1.813  0.1799
##  2 - 6     0.10762 0.025 36   4.302  0.0004
##  5 - 6     0.06227 0.025 36   2.489  0.0452
## 
## curva = T1, gen = ICS95:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.03220 0.025 36   1.287  0.4115
##  2 - 6     0.08907 0.025 36   3.560  0.0030
##  5 - 6     0.05688 0.025 36   2.273  0.0726
## 
## curva = T2, gen = ICS95:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.00964 0.025 36   0.385  0.9216
##  2 - 6     0.06243 0.025 36   2.495  0.0446
##  5 - 6     0.05279 0.025 36   2.110  0.1019
## 
## curva = T3, gen = TCS01:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.06152 0.025 36   2.459  0.0484
##  2 - 6     0.13266 0.025 36   5.303  <.0001
##  5 - 6     0.07114 0.025 36   2.844  0.0195
## 
## curva = T1, gen = TCS01:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.02482 0.025 36   0.992  0.5865
##  2 - 6     0.04164 0.025 36   1.665  0.2326
##  5 - 6     0.01682 0.025 36   0.672  0.7809
## 
## curva = T2, gen = TCS01:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5     0.05858 0.025 36   2.342  0.0627
##  2 - 6     0.22943 0.025 36   9.171  <.0001
##  5 - 6     0.17085 0.025 36   6.829  <.0001
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_diam2_trend <- emmeans(res.aov.error, pairwise ~ diam2*gen | curva)
## Note: re-fitting model with sum-to-zero contrasts
emm_gen_diam2_trend
## $emmeans
## curva = T3:
##  diam2 gen    emmean     SE   df lower.CL  upper.CL
##  2     CCN51 -0.0580 0.0412 23.2   -0.143  0.027121
##  5     CCN51 -0.1071 0.0412 23.2   -0.192 -0.021958
##  6     CCN51 -0.1528 0.0412 23.2   -0.238 -0.067644
##  2     ICS95 -0.0231 0.0412 23.2   -0.108  0.062048
##  5     ICS95 -0.0684 0.0412 23.2   -0.154  0.016700
##  6     ICS95 -0.1307 0.0412 23.2   -0.216 -0.045567
##  2     TCS01 -0.1271 0.0412 23.2   -0.212 -0.041989
##  5     TCS01 -0.1886 0.0412 23.2   -0.274 -0.103512
##  6     TCS01 -0.2598 0.0412 23.2   -0.345 -0.174653
## 
## curva = T1:
##  diam2 gen    emmean     SE   df lower.CL  upper.CL
##  2     CCN51 -0.1213 0.0412 23.2   -0.206 -0.036186
##  5     CCN51 -0.1721 0.0412 23.2   -0.257 -0.086960
##  6     CCN51 -0.1928 0.0412 23.2   -0.278 -0.107680
##  2     ICS95 -0.0392 0.0412 23.2   -0.124  0.045882
##  5     ICS95 -0.0714 0.0412 23.2   -0.157  0.013683
##  6     ICS95 -0.1283 0.0412 23.2   -0.213 -0.043192
##  2     TCS01 -0.1121 0.0412 23.2   -0.197 -0.026965
##  5     TCS01 -0.1369 0.0412 23.2   -0.222 -0.051787
##  6     TCS01 -0.1537 0.0412 23.2   -0.239 -0.068609
## 
## curva = T2:
##  diam2 gen    emmean     SE   df lower.CL  upper.CL
##  2     CCN51 -0.0399 0.0412 23.2   -0.125  0.045262
##  5     CCN51 -0.1073 0.0412 23.2   -0.192 -0.022143
##  6     CCN51 -0.2161 0.0412 23.2   -0.301 -0.130954
##  2     ICS95 -0.0501 0.0412 23.2   -0.135  0.035048
##  5     ICS95 -0.0597 0.0412 23.2   -0.145  0.025412
##  6     ICS95 -0.1125 0.0412 23.2   -0.198 -0.027379
##  2     TCS01 -0.0261 0.0412 23.2   -0.111  0.059008
##  5     TCS01 -0.0847 0.0412 23.2   -0.170  0.000429
##  6     TCS01 -0.2555 0.0412 23.2   -0.341 -0.170417
## 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast          estimate     SE   df t.ratio p.value
##  2 CCN51 - 5 CCN51  0.04908 0.0250 36.0   1.962  0.5780
##  2 CCN51 - 6 CCN51  0.09477 0.0250 36.0   3.788  0.0145
##  2 CCN51 - 2 ICS95 -0.03493 0.0582 23.2  -0.600  0.9994
##  2 CCN51 - 5 ICS95  0.01042 0.0582 23.2   0.179  1.0000
##  2 CCN51 - 6 ICS95  0.07269 0.0582 23.2   1.248  0.9363
##  2 CCN51 - 2 TCS01  0.06911 0.0582 23.2   1.187  0.9515
##  2 CCN51 - 5 TCS01  0.13063 0.0582 23.2   2.244  0.4123
##  2 CCN51 - 6 TCS01  0.20177 0.0582 23.2   3.466  0.0444
##  5 CCN51 - 6 CCN51  0.04569 0.0250 36.0   1.826  0.6653
##  5 CCN51 - 2 ICS95 -0.08401 0.0582 23.2  -1.443  0.8695
##  5 CCN51 - 5 ICS95 -0.03866 0.0582 23.2  -0.664  0.9988
##  5 CCN51 - 6 ICS95  0.02361 0.0582 23.2   0.405  1.0000
##  5 CCN51 - 2 TCS01  0.02003 0.0582 23.2   0.344  1.0000
##  5 CCN51 - 5 TCS01  0.08155 0.0582 23.2   1.401  0.8864
##  5 CCN51 - 6 TCS01  0.15269 0.0582 23.2   2.623  0.2303
##  6 CCN51 - 2 ICS95 -0.12969 0.0582 23.2  -2.228  0.4215
##  6 CCN51 - 5 ICS95 -0.08434 0.0582 23.2  -1.449  0.8671
##  6 CCN51 - 6 ICS95 -0.02208 0.0582 23.2  -0.379  1.0000
##  6 CCN51 - 2 TCS01 -0.02565 0.0582 23.2  -0.441  0.9999
##  6 CCN51 - 5 TCS01  0.03587 0.0582 23.2   0.616  0.9993
##  6 CCN51 - 6 TCS01  0.10701 0.0582 23.2   1.838  0.6587
##  2 ICS95 - 5 ICS95  0.04535 0.0250 36.0   1.813  0.6739
##  2 ICS95 - 6 ICS95  0.10762 0.0250 36.0   4.302  0.0035
##  2 ICS95 - 2 TCS01  0.10404 0.0582 23.2   1.787  0.6897
##  2 ICS95 - 5 TCS01  0.16556 0.0582 23.2   2.844  0.1556
##  2 ICS95 - 6 TCS01  0.23670 0.0582 23.2   4.065  0.0116
##  5 ICS95 - 6 ICS95  0.06227 0.0250 36.0   2.489  0.2708
##  5 ICS95 - 2 TCS01  0.05869 0.0582 23.2   1.008  0.9812
##  5 ICS95 - 5 TCS01  0.12021 0.0582 23.2   2.065  0.5181
##  5 ICS95 - 6 TCS01  0.19135 0.0582 23.2   3.287  0.0649
##  6 ICS95 - 2 TCS01 -0.00358 0.0582 23.2  -0.061  1.0000
##  6 ICS95 - 5 TCS01  0.05795 0.0582 23.2   0.995  0.9826
##  6 ICS95 - 6 TCS01  0.12909 0.0582 23.2   2.217  0.4274
##  2 TCS01 - 5 TCS01  0.06152 0.0250 36.0   2.459  0.2849
##  2 TCS01 - 6 TCS01  0.13266 0.0250 36.0   5.303  0.0002
##  5 TCS01 - 6 TCS01  0.07114 0.0250 36.0   2.844  0.1378
## 
## curva = T1:
##  contrast          estimate     SE   df t.ratio p.value
##  2 CCN51 - 5 CCN51  0.05077 0.0250 36.0   2.030  0.5341
##  2 CCN51 - 6 CCN51  0.07149 0.0250 36.0   2.858  0.1338
##  2 CCN51 - 2 ICS95 -0.08207 0.0582 23.2  -1.410  0.8830
##  2 CCN51 - 5 ICS95 -0.04987 0.0582 23.2  -0.857  0.9933
##  2 CCN51 - 6 ICS95  0.00701 0.0582 23.2   0.120  1.0000
##  2 CCN51 - 2 TCS01 -0.00922 0.0582 23.2  -0.158  1.0000
##  2 CCN51 - 5 TCS01  0.01560 0.0582 23.2   0.268  1.0000
##  2 CCN51 - 6 TCS01  0.03242 0.0582 23.2   0.557  0.9997
##  5 CCN51 - 6 CCN51  0.02072 0.0250 36.0   0.828  0.9952
##  5 CCN51 - 2 ICS95 -0.13284 0.0582 23.2  -2.282  0.3913
##  5 CCN51 - 5 ICS95 -0.10064 0.0582 23.2  -1.729  0.7242
##  5 CCN51 - 6 ICS95 -0.04377 0.0582 23.2  -0.752  0.9972
##  5 CCN51 - 2 TCS01 -0.05999 0.0582 23.2  -1.030  0.9785
##  5 CCN51 - 5 TCS01 -0.03517 0.0582 23.2  -0.604  0.9994
##  5 CCN51 - 6 TCS01 -0.01835 0.0582 23.2  -0.315  1.0000
##  6 CCN51 - 2 ICS95 -0.15356 0.0582 23.2  -2.637  0.2245
##  6 CCN51 - 5 ICS95 -0.12136 0.0582 23.2  -2.084  0.5061
##  6 CCN51 - 6 ICS95 -0.06449 0.0582 23.2  -1.108  0.9671
##  6 CCN51 - 2 TCS01 -0.08072 0.0582 23.2  -1.386  0.8919
##  6 CCN51 - 5 TCS01 -0.05589 0.0582 23.2  -0.960  0.9861
##  6 CCN51 - 6 TCS01 -0.03907 0.0582 23.2  -0.671  0.9987
##  2 ICS95 - 5 ICS95  0.03220 0.0250 36.0   1.287  0.9287
##  2 ICS95 - 6 ICS95  0.08907 0.0250 36.0   3.560  0.0261
##  2 ICS95 - 2 TCS01  0.07285 0.0582 23.2   1.251  0.9356
##  2 ICS95 - 5 TCS01  0.09767 0.0582 23.2   1.677  0.7534
##  2 ICS95 - 6 TCS01  0.11449 0.0582 23.2   1.966  0.5790
##  5 ICS95 - 6 ICS95  0.05688 0.0250 36.0   2.273  0.3837
##  5 ICS95 - 2 TCS01  0.04065 0.0582 23.2   0.698  0.9983
##  5 ICS95 - 5 TCS01  0.06547 0.0582 23.2   1.124  0.9642
##  5 ICS95 - 6 TCS01  0.08229 0.0582 23.2   1.413  0.8815
##  6 ICS95 - 2 TCS01 -0.01623 0.0582 23.2  -0.279  1.0000
##  6 ICS95 - 5 TCS01  0.00860 0.0582 23.2   0.148  1.0000
##  6 ICS95 - 6 TCS01  0.02542 0.0582 23.2   0.437  0.9999
##  2 TCS01 - 5 TCS01  0.02482 0.0250 36.0   0.992  0.9843
##  2 TCS01 - 6 TCS01  0.04164 0.0250 36.0   1.665  0.7630
##  5 TCS01 - 6 TCS01  0.01682 0.0250 36.0   0.672  0.9989
## 
## curva = T2:
##  contrast          estimate     SE   df t.ratio p.value
##  2 CCN51 - 5 CCN51  0.06740 0.0250 36.0   2.694  0.1858
##  2 CCN51 - 6 CCN51  0.17622 0.0250 36.0   7.044  <.0001
##  2 CCN51 - 2 ICS95  0.01021 0.0582 23.2   0.175  1.0000
##  2 CCN51 - 5 ICS95  0.01985 0.0582 23.2   0.341  1.0000
##  2 CCN51 - 6 ICS95  0.07264 0.0582 23.2   1.248  0.9365
##  2 CCN51 - 2 TCS01 -0.01375 0.0582 23.2  -0.236  1.0000
##  2 CCN51 - 5 TCS01  0.04483 0.0582 23.2   0.770  0.9967
##  2 CCN51 - 6 TCS01  0.21568 0.0582 23.2   3.704  0.0263
##  5 CCN51 - 6 CCN51  0.10881 0.0250 36.0   4.349  0.0031
##  5 CCN51 - 2 ICS95 -0.05719 0.0582 23.2  -0.982  0.9840
##  5 CCN51 - 5 ICS95 -0.04755 0.0582 23.2  -0.817  0.9951
##  5 CCN51 - 6 ICS95  0.00524 0.0582 23.2   0.090  1.0000
##  5 CCN51 - 2 TCS01 -0.08115 0.0582 23.2  -1.394  0.8891
##  5 CCN51 - 5 TCS01 -0.02257 0.0582 23.2  -0.388  1.0000
##  5 CCN51 - 6 TCS01  0.14827 0.0582 23.2   2.547  0.2613
##  6 CCN51 - 2 ICS95 -0.16600 0.0582 23.2  -2.851  0.1534
##  6 CCN51 - 5 ICS95 -0.15637 0.0582 23.2  -2.686  0.2066
##  6 CCN51 - 6 ICS95 -0.10358 0.0582 23.2  -1.779  0.6944
##  6 CCN51 - 2 TCS01 -0.18996 0.0582 23.2  -3.263  0.0682
##  6 CCN51 - 5 TCS01 -0.13138 0.0582 23.2  -2.257  0.4051
##  6 CCN51 - 6 TCS01  0.03946 0.0582 23.2   0.678  0.9986
##  2 ICS95 - 5 ICS95  0.00964 0.0250 36.0   0.385  1.0000
##  2 ICS95 - 6 ICS95  0.06243 0.0250 36.0   2.495  0.2678
##  2 ICS95 - 2 TCS01 -0.02396 0.0582 23.2  -0.412  1.0000
##  2 ICS95 - 5 TCS01  0.03462 0.0582 23.2   0.595  0.9995
##  2 ICS95 - 6 TCS01  0.20547 0.0582 23.2   3.529  0.0387
##  5 ICS95 - 6 ICS95  0.05279 0.0250 36.0   2.110  0.4826
##  5 ICS95 - 2 TCS01 -0.03360 0.0582 23.2  -0.577  0.9996
##  5 ICS95 - 5 TCS01  0.02498 0.0582 23.2   0.429  1.0000
##  5 ICS95 - 6 TCS01  0.19583 0.0582 23.2   3.363  0.0552
##  6 ICS95 - 2 TCS01 -0.08639 0.0582 23.2  -1.484  0.8518
##  6 ICS95 - 5 TCS01 -0.02781 0.0582 23.2  -0.478  0.9999
##  6 ICS95 - 6 TCS01  0.14304 0.0582 23.2   2.457  0.3017
##  2 TCS01 - 5 TCS01  0.05858 0.0250 36.0   2.342  0.3456
##  2 TCS01 - 6 TCS01  0.22943 0.0250 36.0   9.171  <.0001
##  5 TCS01 - 6 TCS01  0.17085 0.0250 36.0   6.829  <.0001
## 
## P value adjustment: tukey method for comparing a family of 9 estimates
emm_diam2 <- emmeans(res.aov.error, pairwise ~ diam2)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_diam2
## $emmeans
##  diam2  emmean     SE   df lower.CL upper.CL
##  2     -0.0663 0.0137 23.2  -0.0947  -0.0380
##  5     -0.1107 0.0137 23.2  -0.1391  -0.0823
##  6     -0.1780 0.0137 23.2  -0.2064  -0.1497
## 
## Results are averaged over the levels of: curva, gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate      SE df t.ratio p.value
##  2 - 5      0.0444 0.00834 36   5.321  <.0001
##  2 - 6      0.1117 0.00834 36  13.395  <.0001
##  5 - 6      0.0673 0.00834 36   8.074  <.0001
## 
## Results are averaged over the levels of: curva, gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_diam2_curva <- emmeans(res.aov.error, pairwise ~ diam2 | curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_diam2_curva
## $emmeans
## curva = T3:
##  diam2  emmean     SE   df lower.CL upper.CL
##  2     -0.0694 0.0238 23.2  -0.1186  -0.0203
##  5     -0.1214 0.0238 23.2  -0.1705  -0.0722
##  6     -0.1811 0.0238 23.2  -0.2302  -0.1319
## 
## curva = T1:
##  diam2  emmean     SE   df lower.CL upper.CL
##  2     -0.0909 0.0238 23.2  -0.1400  -0.0417
##  5     -0.1268 0.0238 23.2  -0.1760  -0.0777
##  6     -0.1583 0.0238 23.2  -0.2074  -0.1091
## 
## curva = T2:
##  diam2  emmean     SE   df lower.CL upper.CL
##  2     -0.0387 0.0238 23.2  -0.0878   0.0105
##  5     -0.0839 0.0238 23.2  -0.1330  -0.0347
##  6     -0.1947 0.0238 23.2  -0.2439  -0.1456
## 
## Results are averaged over the levels of: gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast estimate     SE df t.ratio p.value
##  2 - 5      0.0520 0.0144 36   3.599  0.0027
##  2 - 6      0.1117 0.0144 36   7.732  <.0001
##  5 - 6      0.0597 0.0144 36   4.133  0.0006
## 
## curva = T1:
##  contrast estimate     SE df t.ratio p.value
##  2 - 5      0.0359 0.0144 36   2.488  0.0453
##  2 - 6      0.0674 0.0144 36   4.667  0.0001
##  5 - 6      0.0315 0.0144 36   2.179  0.0886
## 
## curva = T2:
##  contrast estimate     SE df t.ratio p.value
##  2 - 5      0.0452 0.0144 36   3.130  0.0095
##  2 - 6      0.1560 0.0144 36  10.802  <.0001
##  5 - 6      0.1108 0.0144 36   7.672  <.0001
## 
## Results are averaged over the levels of: gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
## PI-Cd
##Summary statistics
summ<-datos %>%
  group_by(curva, gen) %>%
  get_summary_stats(picd.testa, type = "mean_sd")
summ %>% as_tibble() %>% print(n=Inf)
## # A tibble: 9 × 6
##   curva gen   variable       n  mean    sd
##   <fct> <fct> <chr>      <dbl> <dbl> <dbl>
## 1 T3    CCN51 picd.testa     9 1.52  0.809
## 2 T3    ICS95 picd.testa     9 1.22  0.578
## 3 T3    TCS01 picd.testa     9 1.34  0.609
## 4 T1    CCN51 picd.testa     9 1.18  0.812
## 5 T1    ICS95 picd.testa     9 0.389 0.166
## 6 T1    TCS01 picd.testa     9 0.686 0.319
## 7 T2    CCN51 picd.testa     9 0.553 0.444
## 8 T2    ICS95 picd.testa     9 0.32  0.134
## 9 T2    TCS01 picd.testa     9 0.733 0.394
##Visualization
bxp <- ggboxplot(
  datos, x = "curva", y = "picd.testa",
  palette = "jco",
  color = "gen", xlab = "Treatment", ylab = "PI-Cd", legend.title = "Genotype"
)
bxp

##Check assumptions
##Outliers
datos %>%
  group_by(curva, gen) %>%
  identify_outliers(picd.testa)
## # A tibble: 2 × 21
##   curva gen     ids trat  muestra id    diam2 cd.testa cd.grano pdcd.grano
##   <fct> <fct> <int> <chr> <fct>   <fct> <fct>    <dbl>    <dbl>      <dbl>
## 1 T1    CCN51    39 T1    14      10    5         12.0     7.68     -0.232
## 2 T1    CCN51    40 T1    14      10    6         13.7     7.64     -0.235
## # ℹ 11 more variables: picd.testa <dbl>, pdph.grano <dbl>, piph.testa <dbl>,
## #   ph.testa <dbl>, acidez.testa <dbl>, ph.grano <dbl>, acidez.grano <dbl>,
## #   tf <dbl>, pi.tf <dbl>, is.outlier <lgl>, is.extreme <lgl>
##Normality assumption
##Compute Shapiro-Wilk test for each combinations of factor levels:
norm<-datos %>%
  group_by(curva, gen) %>%
  shapiro_test(picd.testa)
norm %>% as_tibble() %>% print(n=Inf)
## # A tibble: 9 × 5
##   curva gen   variable   statistic     p
##   <fct> <fct> <chr>          <dbl> <dbl>
## 1 T3    CCN51 picd.testa     0.908 0.299
## 2 T3    ICS95 picd.testa     0.913 0.335
## 3 T3    TCS01 picd.testa     0.929 0.472
## 4 T1    CCN51 picd.testa     0.912 0.329
## 5 T1    ICS95 picd.testa     0.966 0.859
## 6 T1    TCS01 picd.testa     0.957 0.764
## 7 T2    CCN51 picd.testa     0.934 0.518
## 8 T2    ICS95 picd.testa     0.935 0.535
## 9 T2    TCS01 picd.testa     0.906 0.287
##Create QQ plot for each cell of design:
ggqqplot(datos, "picd.testa", ggtheme = theme_bw()) +
  facet_grid(curva~ gen, labeller = "label_both")
## Warning: The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?
## The following aesthetics were dropped during statistical transformation: sample
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

##Homogneity of variance assumption

##Compute the Levene’s test at each level of the within-subjects factor, here time variable:
lev<-datos %>%
  group_by(curva) %>%
  levene_test(picd.testa ~ gen)
lev %>% as_tibble() %>% print(n=Inf)
## # A tibble: 3 × 5
##   curva   df1   df2 statistic      p
##   <fct> <int> <int>     <dbl>  <dbl>
## 1 T3        2    24     0.490 0.619 
## 2 T1        2    24     3.52  0.0457
## 3 T2        2    24     2.54  0.0998
#Table by error
res.aov.error <- aov(picd.testa ~ diam2*curva*gen + Error(id/diam2), datos)
res.aov.error
## 
## Call:
## aov(formula = picd.testa ~ diam2 * curva * gen + Error(id/diam2), 
##     data = datos)
## 
## Grand Mean: 0.8822763
## 
## Stratum 1: id
## 
## Terms:
##                    curva      gen curva:gen Residuals
## Sum of Squares  9.844743 2.728207  1.373165  4.481510
## Deg. of Freedom        2        2         4        18
## 
## Residual standard error: 0.4989717
## 16 out of 24 effects not estimable
## Estimated effects may be unbalanced
## 
## Stratum 2: id:diam2
## 
## Terms:
##                    diam2 diam2:curva diam2:gen diam2:curva:gen Residuals
## Sum of Squares  9.974819    1.679655  1.110548        0.662912  2.229649
## Deg. of Freedom        2           4         4               8        36
## 
## Residual standard error: 0.2488668
## Estimated effects may be unbalanced
summary(res.aov.error)
## 
## Error: id
##           Df Sum Sq Mean Sq F value   Pr(>F)    
## curva      2  9.845   4.922  19.771 2.87e-05 ***
## gen        2  2.728   1.364   5.479   0.0139 *  
## curva:gen  4  1.373   0.343   1.379   0.2807    
## Residuals 18  4.482   0.249                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: id:diam2
##                 Df Sum Sq Mean Sq F value   Pr(>F)    
## diam2            2  9.975   4.987  80.527 5.14e-14 ***
## diam2:curva      4  1.680   0.420   6.780 0.000356 ***
## diam2:gen        4  1.111   0.278   4.483 0.004836 ** 
## diam2:curva:gen  8  0.663   0.083   1.338 0.256842    
## Residuals       36  2.230   0.062                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Emmeans
emmip(res.aov.error, gen ~ diam2 | curva)
## Note: re-fitting model with sum-to-zero contrasts

emm_curva <- emmeans(res.aov.error, pairwise ~ curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_curva
## $emmeans
##  curva emmean    SE df lower.CL upper.CL
##  T3     1.359 0.096 18    1.157    1.561
##  T1     0.752 0.096 18    0.551    0.954
##  T2     0.535 0.096 18    0.334    0.737
## 
## Results are averaged over the levels of: diam2, gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate    SE df t.ratio p.value
##  T3 - T1     0.607 0.136 18   4.468  0.0008
##  T3 - T2     0.824 0.136 18   6.066  <.0001
##  T1 - T2     0.217 0.136 18   1.598  0.2719
## 
## Results are averaged over the levels of: diam2, gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_curva <- emmeans(res.aov.error, pairwise ~ gen | curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_curva
## $emmeans
## curva = T3:
##  gen   emmean    SE df lower.CL upper.CL
##  CCN51  1.523 0.166 18   1.1734    1.872
##  ICS95  1.215 0.166 18   0.8652    1.564
##  TCS01  1.340 0.166 18   0.9905    1.689
## 
## curva = T1:
##  gen   emmean    SE df lower.CL upper.CL
##  CCN51  1.183 0.166 18   0.8333    1.532
##  ICS95  0.389 0.166 18   0.0395    0.738
##  TCS01  0.686 0.166 18   0.3361    1.035
## 
## curva = T2:
##  gen   emmean    SE df lower.CL upper.CL
##  CCN51  0.553 0.166 18   0.2032    0.902
##  ICS95  0.320 0.166 18  -0.0294    0.669
##  TCS01  0.733 0.166 18   0.3839    1.083
## 
## Results are averaged over the levels of: diam2 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast      estimate    SE df t.ratio p.value
##  CCN51 - ICS95    0.308 0.235 18   1.310  0.4079
##  CCN51 - TCS01    0.183 0.235 18   0.777  0.7213
##  ICS95 - TCS01   -0.125 0.235 18  -0.533  0.8564
## 
## curva = T1:
##  contrast      estimate    SE df t.ratio p.value
##  CCN51 - ICS95    0.794 0.235 18   3.375  0.0090
##  CCN51 - TCS01    0.497 0.235 18   2.114  0.1150
##  ICS95 - TCS01   -0.297 0.235 18  -1.261  0.4344
## 
## curva = T2:
##  contrast      estimate    SE df t.ratio p.value
##  CCN51 - ICS95    0.233 0.235 18   0.989  0.5930
##  CCN51 - TCS01   -0.181 0.235 18  -0.768  0.7266
##  ICS95 - TCS01   -0.413 0.235 18  -1.757  0.2120
## 
## Results are averaged over the levels of: diam2 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_gen_diam2 <- emmeans(res.aov.error, pairwise ~ curva*gen)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_diam2
## $emmeans
##  curva gen   emmean    SE df lower.CL upper.CL
##  T3    CCN51  1.523 0.166 18   1.1734    1.872
##  T1    CCN51  1.183 0.166 18   0.8333    1.532
##  T2    CCN51  0.553 0.166 18   0.2032    0.902
##  T3    ICS95  1.215 0.166 18   0.8652    1.564
##  T1    ICS95  0.389 0.166 18   0.0395    0.738
##  T2    ICS95  0.320 0.166 18  -0.0294    0.669
##  T3    TCS01  1.340 0.166 18   0.9905    1.689
##  T1    TCS01  0.686 0.166 18   0.3361    1.035
##  T2    TCS01  0.733 0.166 18   0.3839    1.083
## 
## Results are averaged over the levels of: diam2 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast            estimate    SE df t.ratio p.value
##  T3 CCN51 - T1 CCN51   0.3401 0.235 18   1.446  0.8654
##  T3 CCN51 - T2 CCN51   0.9702 0.235 18   4.125  0.0143
##  T3 CCN51 - T3 ICS95   0.3082 0.235 18   1.310  0.9156
##  T3 CCN51 - T1 ICS95   1.1339 0.235 18   4.821  0.0034
##  T3 CCN51 - T2 ICS95   1.2028 0.235 18   5.114  0.0019
##  T3 CCN51 - T3 TCS01   0.1829 0.235 18   0.777  0.9962
##  T3 CCN51 - T1 TCS01   0.8373 0.235 18   3.560  0.0448
##  T3 CCN51 - T2 TCS01   0.7894 0.235 18   3.356  0.0665
##  T1 CCN51 - T2 CCN51   0.6301 0.235 18   2.679  0.2224
##  T1 CCN51 - T3 ICS95  -0.0319 0.235 18  -0.136  1.0000
##  T1 CCN51 - T1 ICS95   0.7938 0.235 18   3.375  0.0642
##  T1 CCN51 - T2 ICS95   0.8627 0.235 18   3.668  0.0362
##  T1 CCN51 - T3 TCS01  -0.1572 0.235 18  -0.668  0.9987
##  T1 CCN51 - T1 TCS01   0.4972 0.235 18   2.114  0.4941
##  T1 CCN51 - T2 TCS01   0.4494 0.235 18   1.910  0.6158
##  T2 CCN51 - T3 ICS95  -0.6620 0.235 18  -2.814  0.1777
##  T2 CCN51 - T1 ICS95   0.1637 0.235 18   0.696  0.9982
##  T2 CCN51 - T2 ICS95   0.2326 0.235 18   0.989  0.9822
##  T2 CCN51 - T3 TCS01  -0.7873 0.235 18  -3.347  0.0677
##  T2 CCN51 - T1 TCS01  -0.1329 0.235 18  -0.565  0.9996
##  T2 CCN51 - T2 TCS01  -0.1807 0.235 18  -0.768  0.9965
##  T3 ICS95 - T1 ICS95   0.8257 0.235 18   3.510  0.0494
##  T3 ICS95 - T2 ICS95   0.8946 0.235 18   3.803  0.0276
##  T3 ICS95 - T3 TCS01  -0.1253 0.235 18  -0.533  0.9997
##  T3 ICS95 - T1 TCS01   0.5291 0.235 18   2.249  0.4175
##  T3 ICS95 - T2 TCS01   0.4813 0.235 18   2.046  0.5342
##  T1 ICS95 - T2 ICS95   0.0689 0.235 18   0.293  1.0000
##  T1 ICS95 - T3 TCS01  -0.9510 0.235 18  -4.043  0.0169
##  T1 ICS95 - T1 TCS01  -0.2966 0.235 18  -1.261  0.9304
##  T1 ICS95 - T2 TCS01  -0.3445 0.235 18  -1.464  0.8575
##  T2 ICS95 - T3 TCS01  -1.0199 0.235 18  -4.336  0.0093
##  T2 ICS95 - T1 TCS01  -0.3655 0.235 18  -1.554  0.8163
##  T2 ICS95 - T2 TCS01  -0.4134 0.235 18  -1.757  0.7067
##  T3 TCS01 - T1 TCS01   0.6544 0.235 18   2.782  0.1876
##  T3 TCS01 - T2 TCS01   0.6066 0.235 18   2.579  0.2606
##  T1 TCS01 - T2 TCS01  -0.0479 0.235 18  -0.203  1.0000
## 
## Results are averaged over the levels of: diam2 
## P value adjustment: tukey method for comparing a family of 9 estimates
emm_gen_diam2_trend <- emmeans(res.aov.error, pairwise ~ gen)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_gen_diam2_trend
## $emmeans
##  gen   emmean    SE df lower.CL upper.CL
##  CCN51  1.086 0.096 18    0.884    1.288
##  ICS95  0.641 0.096 18    0.439    0.843
##  TCS01  0.920 0.096 18    0.718    1.121
## 
## Results are averaged over the levels of: diam2, curva 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast      estimate    SE df t.ratio p.value
##  CCN51 - ICS95    0.445 0.136 18   3.276  0.0111
##  CCN51 - TCS01    0.166 0.136 18   1.226  0.4539
##  ICS95 - TCS01   -0.278 0.136 18  -2.050  0.1290
## 
## Results are averaged over the levels of: diam2, curva 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_diam2 <- emmeans(res.aov.error, pairwise ~ diam2)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_diam2
## $emmeans
##  diam2 emmean     SE   df lower.CL upper.CL
##  2      0.399 0.0678 35.9    0.262    0.537
##  5      1.024 0.0678 35.9    0.887    1.162
##  6      1.223 0.0678 35.9    1.086    1.361
## 
## Results are averaged over the levels of: curva, gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate     SE df t.ratio p.value
##  2 - 5      -0.625 0.0677 36  -9.223  <.0001
##  2 - 6      -0.824 0.0677 36 -12.161  <.0001
##  5 - 6      -0.199 0.0677 36  -2.937  0.0155
## 
## Results are averaged over the levels of: curva, gen 
## P value adjustment: tukey method for comparing a family of 3 estimates
emm_diam2_curva <- emmeans(res.aov.error, pairwise ~ diam2 | curva)
## Note: re-fitting model with sum-to-zero contrasts
## NOTE: Results may be misleading due to involvement in interactions
emm_diam2_curva
## $emmeans
## curva = T3:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.612 0.118 35.9   0.3735    0.850
##  5      1.536 0.118 35.9   1.2981    1.775
##  6      1.929 0.118 35.9   1.6908    2.167
## 
## curva = T1:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.383 0.118 35.9   0.1448    0.621
##  5      0.883 0.118 35.9   0.6446    1.121
##  6      0.991 0.118 35.9   0.7528    1.229
## 
## curva = T2:
##  diam2 emmean    SE   df lower.CL upper.CL
##  2      0.203 0.118 35.9  -0.0349    0.442
##  5      0.653 0.118 35.9   0.4149    0.892
##  6      0.749 0.118 35.9   0.5109    0.988
## 
## Results are averaged over the levels of: gen 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95 
## 
## $contrasts
## curva = T3:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5      -0.925 0.117 36  -7.881  <.0001
##  2 - 6      -1.317 0.117 36 -11.228  <.0001
##  5 - 6      -0.393 0.117 36  -3.347  0.0053
## 
## curva = T1:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5      -0.500 0.117 36  -4.260  0.0004
##  2 - 6      -0.608 0.117 36  -5.182  <.0001
##  5 - 6      -0.108 0.117 36  -0.922  0.6300
## 
## curva = T2:
##  contrast estimate    SE df t.ratio p.value
##  2 - 5      -0.450 0.117 36  -3.834  0.0014
##  2 - 6      -0.546 0.117 36  -4.652  0.0001
##  5 - 6      -0.096 0.117 36  -0.818  0.6943
## 
## Results are averaged over the levels of: gen 
## P value adjustment: tukey method for comparing a family of 3 estimates