R: Model term constructor functions

asr_dsum {asreml} | R Documentation

## Model term constructor functions

### Description

This class of special functions constructs model terms with specific properties to be used with `asreml` syntax.

### Usage

    dsum(model, levels = NULL, outer = FALSE)

    C(obj, contr)

    con(obj)obj

    lin(obj)

    pow(obj, p = 1, offset = 0)

    pol(obj, t = 1, init = NA)

    leg(obj,t = 1, init = NA)

    spl(obj, k = 50, init = NA)

    dev(obj, init = NA)

    ma(obj)

    at(obj, lvls)

    and(obj, times = 1)

    mbf(obj)

    grp(obj)

### Arguments

`model` | A formula of the form `~A+B+...|Z`, where `A` and `B` define variance matrices for simple or compound model terms, and `Z` is a simple conditioning factor whose levels identify and determine the number of sub-matrices in the direct sum. The `"|"` operator is applied associatively and operates with all terms on its left; that is, `A+B|C` implies `(A+B)|C` and is equivalent to `A|C+B|C`.
`levels` | A list of the length of the number of terms in the left-hand side of `model` that are separated by `"+"`. The components of `levels` are vectors of unique values of `Z`. If there is only one term in the left-hand side of `model` (or if the context allows, see examples) then `levels` may be a vector. If `levels` is numeric, then these are ordinal numbers that refer to the sections defined by Z in `unique(Z)` order. If `NULL` then `unique(Z)` is used (default = `NULL`).
`obj` | An object in the data frame. `mbf`: A component name from the `mbf` list argument. `grp`: A component name from the `group` list argument.
`contr` | An integer vector of contrast coefficients parallel to `levels(obj)`.
`p` | The exponent in a power function term (`pow`) (default = `1`).
`offset` | Constant added to `obj` (default = `0`).
`t` | A value. `pol`: The maximum degree of a set of orthogonal polynomials formed from `obj`. If negative, the intercept in the polynomial is omitted (default = `1`). `leg`: The maximum degree of a set of Legendre polynomials formed from `obj`. If negative, the intercept is omitted (default = `1`).
`k` | The number of equally-spaced knot points for a cubic smoothing spline. If zero or omitted, `k` is set to `asreml.options()$knots` (default 50).
`init` | Optional initial value for the default identity variance model `idv` when used in the `random` formula.
`lvls` | Vector of levels of the conditioning factor (`obj`) that define the conditioning covariates formed by `at`. If numeric, `lvls` indexes the levels vector of `obj`; that is `levels(obj)[lvls]`.
`times` | It multiplies (may be non-integer) of the design matrix for `obj` are added to the preceding design matrix (default = `1`).

### Functions

- `asr_dsum()`: Direct sum structures for residual models.

- `asr_C()`: Defines specific contrasts for a factor.

- `asr_con()`: Sum to zero constraints.

- `asr_lin()`: Create a variate from `obj` (usually factors).

- `asr_pow()`: Create the model term: `(obj+offset)``^p`.

- `asr_pol()`: Orthogonal polynomials.

- `asr_leg()`: Legendre polynomials.

- `asr_spl()`: Cubic smoothing spline (random component).

- `asr_dev()`: Spline deviations; create a factor from the variate `obj`.

- `asr_ma()`: Construct a term with a moving-average of order 1 design matrix from `obj`.

- `asr_at()`: Form a conditioning covariate from `obj` for each level of `obj` specified in the `lvls` argument.

- `asr_and()`: Multiply the design matrix for `obj` by `times` and add it to the preceding design matrix.

- `asr_mbf()`: Create a model term from covariates not stored in `data`.

- `asr_grp()`: Create a model term from covariates held in specific columns of `data`.

### Examples

    ## Not run:

    ## Separable autoregressive residual model at each level of Site
    residual = ~dsum(~ar1(Column):ar1(Row) | Site)

    ## Different residual models at different levels of Site.
    ## The ordinals in the levels list refer to the unique values of
    ## Site in unique(Site) order.
    residual = ~dsum(~ar1(Column):ar1(Row) + id(Column):ar1(Row) | Site,
                    levels = list(c(1, 3), c(2)))

    ## Equivalent
    residual = ~dsum(~ar1(Column):ar1(Row) | Site, levels = c("Site1", "Site3")) +
                dsum(~id(Column):ar1(Row)  | Site, levels = c("Site2"))

    ## "biological" Date (as factor) within Plot
    residual = ~dsum(~ar1(Date) | Plot)

    ## "explicit" times (Date as variate)
    residual = ~dsum(~exp(Date) | Plot)

    ## End(Not run)

[Package asreml version 4.2.0.480 Index]