Learn R Programming

hypr (version 0.2.2)

ginv2: Enhanced generalized inverse function

Description

This function is a wrapper for MASS::ginv and calculates the generalized inverse of x.

Usage

ginv2(x, as_fractions = TRUE)

Value

Generalized inverse of x

Arguments

x

The original matrix

as_fractions

Whether to format the matrix as fractions (MASS package)

Details

In addition to MASS::ginv, this function rounds values, formats the matrix as fractions and copies dimension names from the original matrix.

See Also

Examples

Run this code

h <- hypr(mu1~0, mu2~mu1)
hmat(h)

ginv2(hmat(h))
cmat(h)

# cmat is effectively the generalized inverse of hmat
stopifnot(all.equal(
`class<-`(ginv2(hmat(h)), "matrix"),
`class<-`(cmat(h), "matrix"), check.attributes = FALSE))

Run the code above in your browser using DataLab