R2adj.asreml {asremlPlus}R Documentation

Calculates the adjusted coefficient of determination for a specified combination of fixed and random terms.

Description

Calculates the adjusted coefficient of determination (R2) that measures the contributions to the total variance exhibited by the observations of a specified combination of fixed and random terms in a fitted linear mixed model.

Note that the adjusted R2 can be negative, which indicates that the contribution of the terms to the total variance is very small relative to the sum of the degrees of freedom of the terms.

Piepho's (2023) method for GLMMs has not been implemented. This function is not available for ASReml-R version 3.

Usage

## S3 method for class 'asreml'
R2adj(asreml.obj, 
      include.which.fixed = ~ ., orthogonalize = "hybrid", 
      include.which.random = NULL, 
      bound.exclusions = c("F","B","S","C"), ...)

Arguments

asreml.obj

An asreml object returned from a call to asreml.

include.which.fixed

A formula specifying the fixed terms whose joint contribution to the total variance is to be measured. If it is NULL, no fixed term is to be included in the terms whose joint contribution is to be assessed. The formula ~ . indicates that the joint contribution of all fixed terms are to be measured. Otherwise, the joint contribution of the set of terms specified by the formula will be assessed. The formula can include a ".", which means all fixed terms currently fitted, and is most likely followed by a "-" with a bracketed set of terms to be removed that can be specified using formula operators. The names of the resulting terms must be the same as those in either the terms attribute of the fixed component of the coefficient component of the supplied asreml.obj, or the Wald table produced by wald.asreml.

Note that the contribution of a subset of the fixed terms is only unique if the effects for the fixed terms are orthogonal; if the effects are not orthogonal then the contributions will depend on the order of the terms in the formula. Also, determining the joint contribution of a subset of the fixed terms in the model may be computationally demanding because the projection matrices have to be formed for all fixed terms and these projections matrices have to be orthogonalized. A heavy computational burden is most likely when the effects for the fixed terms are not orthogonal, for example, when numeric covariates are included amongst the terms.

orthogonalize

A character vector indicating the method for orthogonalizing a projector to those for terms that occurred previously in the formula for include.which.fixed. Orthogonalizing the projectors of fixed terms is not performed for the default setting of . ~. WHen required, two options are available for orthogonalizing: hybrid and eigenmethods. The hybrid option is the most general and uses the relationships between the projection operators for the terms in the formula to decide which projectors to subtract and which to orthogonalize using eigenmethods. The eigenmethods option recursively orthogonalizes the projectors using an eigenanalysis of each projector with previously orthogonalized projectors. See the documentation for porthogonalize.list from the R package dae for more information.

include.which.random

A formula specifying the random terms whose joint contribution to the total variance is to be measured. If it is NULL, no random term is to be included in the terms whose joint contribution is to be assessed. The formula ~ . indicates that the joint contribution of all random terms is to be measured. Otherwise, the joint contribution of the set of terms specified by the formula will be assessed. The formula can include a ".", which means all random terms currently fitted, and is most likely followed by a "-" with a bracketed set of terms to be removed that can be specified using formula operators. The resulting terms must be one of those occurring in either the vparameters component of the supplied asreml.obj, or in the terms attribute of the random component of the coefficient component of the supplied asreml.obj.

bound.exclusions

A character specifying one or more bound codes that will result in a variance parameter in the random model being excluded from contributing to the variance. If set to NULL then none will be excluded.

...

Provision for passing arguments to functions called internally - not used at present.

Details

The method used to compute the adjusted R2 under a linear mixes model (LMM) is that described by Piepho (2023). Here, the method has been extended to allow computation of the adjusted R2 for a subset of the fixed terms. A set of orthogonalized projectors for all of the fixed terms in the model (a set of \mathbf{Q}_i\mathrm{s}) is obtained and the combined contribution of the fixed terms nominated in include.which.fixed is obtained by computing the average semisquared bias, ASSB, for the nominated fixed terms as:

\Sigma_i \{(\mathbf{Q}_i \mathbf{X}\boldsymbol{\beta})^\mathrm{T}\mathbf{Q}_i \mathbf{X}\boldsymbol{\beta} + \textnormal{trace}(\mathbf{X}^\mathrm{T} \mathbf{Q}_i \mathbf{X} \mathrm{var}(\boldsymbol{\beta})) \} / (n - 1)

Of the two methods, eigenmethods is least likely to fail, but it does not establish the marginality between the terms. It is often needed when there is nonorthogonality between terms, such as when there are several linear covariates. It can also be more efficient in these circumstances.

The process can be computationally expensive, particularly for a large data set (500 or more observations) and/or when many terms are to be orthogonalized, particularly if they are not orthogonal.

If the error "Matrix is not idempotent" should occur then, especially if there are many terms, one might try using set.daeTolerance from the dae package to reduce the tolerance used in determining if values are either the same or are zero; it may be necessary to lower the tolerance to as low as 0.001. Also, setting orthogonalize to eigenmethods is worth a try.

In doing the computations, no changes are made to the fitted model, nor is the formula stored in asreml.obj referred to. Instead, the names of the terms referred to are those stored in the coefficients component of the asreml.obj. Use attr(asreml.obj$coefficients$fixed, which = "terms") to access the attribute for fixed terms; substitute random for fixed to see the names of the random terms. For fixed terms. the term names are the same as those in the Wald table produced by wald.asreml, and, for random terms, the same as those in the vparameters component of the asreml.obj. Two asreml formula functions whose terms can differ from their formulation in a model formula are at and str.)

The function estimateV.asreml is used to calculate the variance matrices required in calculating the adjusted R2.

Value

A numeric that is the adjusted R2, expressed as a percentage. It has attributes include.which.fixed, include.which.random and missing.termmatrix (use attr(x, which = "name") to access the attribute name). The missing.termmatrix attribute will be NULL, unless the design matrix could not be obtained for one or more model terms. If is is not NULL, it will be a list of terms whose design matices could not be produced and so are not included in the variance matrix estimate. An NA will be returned for the adjusted R2 if missing.termmatrix is not NULL or a generalized inverse could not be computed for the variance matrix estimate.

Author(s)

Chris Brien

References

Piepho, H.-P. (2023). An adjusted coefficient of determination (R2) for generalized linear mixed models in one go. Biometrical Journal, 65(7), 2200290. doi:10.1002/bimj.202200290.

See Also

asreml, estimateV.asreml.

Examples

## Not run: 
  data(Oats.dat)
  
  current.asr <- asreml(Yield ~ Nitrogen*Variety, 
                        random=~Blocks/Wplots,
                        data=Oats.dat)
  R2.adj.fix <- R2adj.asreml(current.asr)
  R2.adj.ran <- R2adj.asreml(current.asr, 
                             include.which.fixed = NULL, include.which.random = ~ .)
  R2.adj.tot <- R2adj.asreml(current.asr, include.which.random = ~ .)
  R2.adj.tot <- R2adj.asreml(current.asr, include.which.random = ~ Blocks)
  R2.adj.add <- R2adj.asreml(current.asr, include.which.fixed = ~ Nitrogen + Variety)
  R2.adj.int <- R2adj.asreml(current.asr, 
                             include.which.fixed = ~ . - (Nitrogen + Variety))
  R2.adj.int <- R2adj.asreml(current.asr, include.which.fixed = ~ Nitrogen:Variety)

## End(Not run)

[Package asremlPlus version 4.4.35 Index]