# asreml-r, model equations

In the most basic situation asreml-r uses identical notation to `lm`

(the
default linear modeling function in R) when defining covariates, factors,
crossed factors, nesting, etc. For example:

```
y ~ 1 # Only the mean
y ~ x # A covariate (where x is a numeric variable)
y ~ f # A factor (where F is defined as factor(F))
y ~ f1/f2 # A factor f2 nested in f1
y ~ x + f # Analysis of covariance
y ~ f1 + f2 + f1:f2 # Two factors with interaction
y ~ f1*f2 # Expands to f1 + f2 + f1:f2
```

The first difference is the use of `random = ~`

(which is also used by `nlme`

and `lme4`

, two popular mixed model packages in R) to define random effects.
Differences become more apparent when using multivariate analyses and variance
structures that differ from an identity matrix multiplied by an scalar. See
covariance structures for more details.