R: User-defined variance models or structures

user_vs {asreml} | R Documentation

## User-defined variance models or structures

### Description

Specify an external function that provides a variance-covariance matrix, or its inverse.

### Usage

    own(obj, fun = "myowng", is.variance = TRUE)

### Arguments

`obj` | A factor in `data`.
`fun` | The name (as a character string) of an `R` function to compute the variance matrix and its derivative(s). This function must accept a single argument: `order`: a scalar giving the dimension of the structure being defined, and return a list containing the matrix (the variance matrix or its inverse) and the corresponding derivative matrices. The variance matrix may be a dense `matrix` class object, a vector being the lower triangle in row-major order, or a three-column matrix in coordinate form in row-major order. This object may have an attribute `INVERSE`, a logical scalar identifying the structure as a variance matrices or its inverse. If `INVERSE` attribute is absent the default is `FALSE`.
`is.variance` | If `TRUE`, then `own` assumes the resulting structure is a variance matrix, otherwise a correlation matrix is assumed. This only affects the default scaling factor (default = `TRUE`).

### Details

The `own` variance model allows users to specify external variance structures. This requires the user to provide an `R` function that accepts a single argument, the leading dimension of the structure, and forms the variance matrix (or its inverse). The `R` function may invoke compiled code if necessary.

### Examples

    ## Not run:
    ## An own ar1 function
    ar1.asr <- asreml(yield ~ Variety,
                      residual = ~ar1(Row):own(Column, "ar1", 0.1, "R"),
                      data = shf)

    ## where the function "ar1" is defined as:

    ## ar1 <- function(order, kappa) {
    ##   t <- 1:order
    ##   H <- abs(outer(t, t, "-"))
    ##   V <- kappa^H
    ##   ## derivative
    ##   dV <- H*(kappa^(H-1))
    ##   return(list(V, dV))
    ## }

    ## End(Not run)

[Package asreml version 4.2.0.480 Index]