asreml-r, extracting results
One of the big differences between the console version and the R version of
asreml is the way output is dealt with. The console version generates several
text files with the same base name of the .as file containing the job, but
different extensions. For example, a job.as
file will generate job.asr
with a summary of the run, job.sln
with the fixed and random effect
solutions, job.yht
with predicted values, etc. In contrast, asreml-r follows
the ‘R way’, creating an object that contains all the output. This object has
to be queried, by using specific functions, to obtain particular parts of the
output.
Let’s assume that we have fitted a simple linear mixed model to explain plant
yield (yield
), based on overall mean (1
), Fertilizer dose (Fert
) and a
genetic effect (ped(Tree)
):
fm <- asreml(yield ~ 1 + Fertil, random =~ ped(Tree),
data = mytrial)
An asreml object for a linear mixed model will contain information on the
model fitted, Log likelihood, predicted values for fixed and random effects,
residuals, variance components, etc. A common way to obtain summary results in
R is to use the function summary on the fitted object as summary(fm)
.
Unfortunately, the summary function in asreml displays the whole contents of
the object, which will be many pages and not a summary at all. So, how do you
get a proper summary in asreml-r?
Part of the default output of running asreml-r is to display the log likelihood of the fitted model. Most likely, the next thing that we would like to know are the variance components, which we can obtain as:
summary(fm)$varcomp
Random and fixed effects are extracted using the coef
& $random
and
coef
& fixed
names for the fitted model. The outputs are matrices with 3
columns: solution, standard error and z ratio. The latter is simply the
solution divided by its standard error, an indication of significance.
# Extracting random effects
coef(fm)$random
# Extracting fixed effects
coef(fm)$fixed
R matrices can have associated row names and column names. The matrices
containing solutions have column names solution
, std error
and z ratio
,
while the row names correspond to the names of the factor, followed by
underscores with the levels of the factor.