# NOT RUN {
library(metan)
#===============================================================#
# Example 1: Analyzing all numeric variables assuming genotypes #
# as random effects with equal weights for mean performance and #
# stability #
#===============================================================#
model <- waasb(data_ge,
env = ENV,
gen = GEN,
rep = REP,
resp = everything())
# Distribution of random effects (first variable)
plot(model, type = "re")
# Genetic parameters
get_model_data(model, "genpar")
#===============================================================#
# Example 2: Analyzing variables that starts with "N" #
# assuming environment as random effects with higher weight for #
# response variable (65) for the three traits. #
#===============================================================#
model2 <- waasb(data_ge2,
env = ENV,
gen = GEN,
rep = REP,
random = "env",
resp = starts_with("N"),
wresp = 65)
# Get the index WAASBY
get_model_data(model2, what = "WAASBY")
# Plot the scores (response x WAASB)
plot_scores(model2, type = 3)
#===============================================================#
# Example 3: Analyzing GY and HM assuming a random-effect model.#
# Smaller values for HM and higher values for GY are better. #
# To estimate WAASBY, higher weight for the GY (60%) and lower #
# weight for HM (40%) are considered for mean performance. #
#===============================================================#
model3 <- waasb(data_ge,
env = ENV,
gen = GEN,
rep = REP,
resp = c(GY, HM),
random = "all",
mresp = c("h, l"),
wresp = c(60, 40))
# Get Likelihood-ratio test
get_model_data(model3, "lrt")
# Get the random effects
get_model_data(model3, what = "ranef")
#===============================================================#
# Example 4: Analyzing GY and HM assuming a mixed-effect model #
# within mega-environments and extract variance components
#===============================================================#
data_mega <- data_ge %>%
add_cols(MEGA = ifelse(ENV %in% c("E1", "E2", "E3", "E4"), "ME1", "ME2"))
mega <- waasb(data_mega,
env = ENV,
gen = GEN,
rep = REP,
resp = everything(),
by = MEGA,
verbose = FALSE)
get_model_data(mega, "vcomp")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab