Description Usage Arguments Details Examples
Calculates the heritability (on an entry-mean basis) of a trait given a fitted model object
1 2 3 4 5 6 7 |
object |
A model object. See Details for accepted classes. |
exp |
A quoted expression used to calculate the heritability. For instance,
|
... |
Other arguments to pass. This is generally a list of other objects
that are in |
ms.exp |
A named list of expressions used to calculate the variance components.
The names of the list should be names of the variance components used in the heritability
expression ( |
Accepted classes for object
are:
lm
lmerMod
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # Use the gauch.soy dataset
data("gauch.soy")
# Filter
gauch_soy1 <- gauch.soy %>%
group_by(env) %>%
filter(n_distinct(gen, rep) == 28)
# Set the number of reps and number of environments
n_r <- 4
n_e <- 36
# Fit a linear model using lm
lm_mod <- lm(yield ~ gen + env + gen:env + rep:env, data = gauch_soy1)
# Variance components from a fixed effects model are derived from the ANOVA table.
# The function also required expressions to calculate the variance components
ms.exp <- list("gen:env" = "(gen:env - Residuals) / n_r",
"gen" = "(gen - gen:env) / (n_r * n_e)")
exp = "gen / (gen + (gen:env / n_e) + (Residuals / n_r))"
herit(object = lm_mod, exp = exp, ms.exp = ms.exp, n_r = n_r, n_e = n_e)
# Fit a linear model using lmer
lmer_mod <- lmer(yield ~ (1|gen) + (1|env) + (1|gen:env) + (1|env:rep), data = gauch_soy1)
# Calculate heritability
herit(object = lmer_mod, exp = "gen / (gen + (gen:env / n_e) + (Residual / n_r))",
n_r = n_r, n_e = n_e)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.