knitr::opts_chunk$set(comment = "#", collapse = TRUE) load("cvali.RData")
In this section, we will use the data in data_ge
. For more information, please, see ?data_ge
. Other data sets can be used provided that the following columns are in the dataset: environment, genotype, block/replicate and response variable(s). See the section Rendering engine to know how HTML tables were generated.
library(metan) library(DT) # Used to make the tables # Function to make HTML tables print_table <- function(table, rownames = FALSE, digits = 3, ...){ df <- datatable(table, rownames = rownames, extensions = 'Buttons', options = list(scrollX = TRUE, dom = '<<t>Bp>', buttons = c('copy', 'excel', 'pdf', 'print')), ...) num_cols <- c(as.numeric(which(sapply(table, class) == "numeric"))) if(length(num_cols) > 0){ formatSignif(df, columns = num_cols, digits = digits) } else{ df } }
The following code computes the cross-validation of the oat data using the AMMI model. There are two options for doing that. The first is to perform the cross-validation for a specific member of the AMMI-family model. The second (and more realistic) is to perform the cross-validation for all AMMI-family models in the same procedure.
The function cv_ammi()
is used to compute a cross-validation procedure for the AMMI0, AMMI2 and AMMIF (9 axes) models.
library(metan)
library(metan) AMMI0 <- cv_ammi(data_ge, ENV, GEN, REP, GY, naxis = 0) # AMMI0 AMMI2 <- cv_ammi(data_ge, ENV, GEN, REP, GY, naxis = 2) # AMMI2 AMMI9 <- cv_ammi(data_ge, ENV, GEN, REP, GY, naxis = 9) # AMMIF
The function cv_ammif()
is used to compute a cross-validation procedure for all members of the AMMI-family model. In this case, AMMI0-AMMI9.
AMMIF <- cv_ammif(data_ge, ENV, GEN, REP, GY)
The function cv_blup()
provides a cross-validation of replicate-based data using mixed models. By default, complete blocks are randomly selected for each environment. Using the argument random
it is possible to chose the random effects of the model, as shown bellow.
BLUP_g <- cv_blup(data_ge, ENV, GEN, REP, GY, random = "gen")
BLUP_e <- cv_blup(data_ge, ENV, GEN, REP, GY, random = "env")
BLUP_ge <- cv_blup(data_ge, ENV, GEN, REP, GY, random = "all")
bind_mod <- bind_cv(AMMIF, BLUP_g, bind = "means") print_table(bind_mod$RMSPD)
The table above showns the descriptive statistics (mean, standard deviation, standar error of the mean, and quantiles 2.5% and 97.5%) of the 100 RMSPD estimates for each model, and are presented from the most accurate model (smallest RMSPD mean) to the least accurate model (highest RMSPD mean).
The values of the RMSPD estimates obtained in the cross-validation process may be plotted using the functionplot()
.
bind1 <- bind_cv(AMMI0, AMMI2, AMMI9) bind2 <- bind_cv(AMMIF, BLUP_g, BLUP_e, BLUP_ge) a <- plot(bind1, violin = TRUE) b <- plot(bind2, width.boxplot = 0.6, order_box = TRUE, plot_theme = theme_metan_minimal()) arrange_ggplot(a, b, tag_levels = "a")
Six statistics are shown in this boxplot. The mean (black rhombus), the median (black line), the lower and upper hinges that correspond sto the first and third quartiles (the 25th and 75th percentiles, respectively). The upper whisker extends from the hinge to the largest value no further than $1.5\times{IQR}$ from the hinge (where IQR is the inter-quartile range). The lower whisker extends from the hinge to the smallest value at most $1.5\times{IQR}$ of the hinge. Data beyond the end of the whiskers are considered outlying points. If the condition violin = TRUE
, a violin plot is added along with the boxplot. A violin plot is a compact display of a continuous distribution displayed in the same way as a boxplot.
This vignette was built with pkgdown. All tables were produced with the package DT
using the following function.
library(DT) # Used to make the tables # Function to make HTML tables print_table <- function(table, rownames = FALSE, digits = 3, ...){ df <- datatable(table, rownames = rownames, extensions = 'Buttons', options = list(scrollX = TRUE, dom = '<<t>Bp>', buttons = c('copy', 'excel', 'pdf', 'print')), ...) num_cols <- c(as.numeric(which(sapply(table, class) == "numeric"))) if(length(num_cols) > 0){ formatSignif(df, columns = num_cols, digits = digits) } else{ df } }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.