asreml-r, basic usage

fm <- asreml(response ~ fixed.factors, random = ~ more.factors,
             data = mydata)

The R system is modular, so when it loads only core functionality is available. Mixed models are made available by additional ‘packages’, which are loaded using the library function. The most common mixed model packages in R are nlme (which is part of the default R installation) and the newer lme4. Both of them are free and open source, and have some pros and cons compared to asreml-r, which is a commercial and closed source package.

The first line of the example loads the asreml-r package and makes available all its functionality to the R environment. The second line calls asreml with a model equation using fixed and random factors, taking all the variable names from a data frame called mydata. We need to load the package only once during our session.

Let us say that we have a data frame containing the following variables (columns): Replicate, Family and height, which refer to a randomized complete block design with, say 30 replicates, 100 families, plots with 5 plants per family in each replicate and plants assessed for total height. In addition, all these variables are stored in a data frame called trial1. Please note that the notation convention in these pages is to use capitalized names for factors and lowercase names for covariates. We could fit this example using:

fm <- asreml(height ~ 1, random = ~ Replicate*Family,
             data = trial1)

# or, equivalently,

fm <- asreml(height ~ 1, random = ~ Replicate + Family + Replicate:Family,
             data = trial1)

The call to asreml uses height as the response variable (to the left of the tilde symbol ~) and fits the overall mean (the 1 used to the right of the ~) as a fixed effect. Additionally, the call fits Replicate, Family and their interaction as random effects. All the variables are contained in trial1. Both calls are equivalent because in R Replicate*Family expands to Replicate + Family + Replicate:Family.

The whole asreml-r run is assigned to variable fm (meaning fitted model in our example) using the <- operator. It can then further manipulated and interrogated. If you come from nlme or lme4, you could be tempted to use summary(fm) to get summary results for the model fit. This would not be a good idea when using asreml-r, because it would print all parts of the model. Thus, instead of getting a nice summary of the results, you will get the whole shebang; that is, predicted values, residuals, variance components, etc. This means that if you ran a large analysis you will get several screens of output. This is in my list of pet-peeves about asreml-r.

Instead, one usually accesses different parts of the output using the typical R notation object$name applied to summary(), which in this case would look like:

# or you could assign it to a variable for further
# manipulation as:
luis <- summary(fm)$varcomp