# NOT RUN {
library(metan)
# simulate a data set
# 10 genotypes
# 5 replications
# 4 traits
df <-
g_simula(ngen = 10,
nrep = 5,
nvars = 4,
gen_eff = 35,
seed = c(1, 2, 3, 4))
# run a mixed-effect model (genotype as random effect)
mod <-
gamem(df,
gen = GEN,
rep = REP,
resp = everything())
# BLUPs for genotypes
gmd(mod, "blupg")
# Compute the MGIDI index
# Default options (all traits with positive desired gains)
# Equal weights for all traits
mgidi <- mgidi(mod)
gmd(mgidi, "MGIDI")
# Higher weight for traits V1 and V4
# This will increase the probability of selecting H7 and H9
# 30% selection pressure
mgidi2 <-
mgidi(mod,
weights = c(1, .2, .2, 1),
SI = 30)
gmd(mgidi2, "MGIDI")
# plot the contribution of each factor on the MGIDI index
p1 <- plot(mgidi, type = "contribution")
p2 <- plot(mgidi2, type = "contribution")
p1 + p2
# Positive desired gains for V1, V2 and V3
# Negative desired gains for V4
mgidi3 <-
mgidi(mod,
ideotype = c("h, h, h, l"))
# }
Run the code above in your browser using DataLab