Learn R Programming

lavaSearch2 (version 1.0.0)

matrixPower: Power of a Matrix

Description

Compute the power of a matrix.

Usage

matrixPower(x, power, symmetric, tol = 1e-12)

Arguments

x

a matrix.

power

power to be applied to the matrix.

symmetric

is the matrix symmetric? Argument passed to the function eigen.

tol

the threshold under which the eigenvalues are set to 0.

Value

a matrix.

Examples

Run this code
# NOT RUN {
M <- matrix(rnorm(2e2),20,10)
Sigma <- var(M)
Sigma.half <- matrixPower(Sigma, power = 1/2, symmetric = FALSE)
round(crossprod(Sigma.half)-Sigma,5)

Sigma.m1 <- matrixPower(Sigma, power = -1, symmetric = FALSE)
round(Sigma.m1 %*% Sigma,5)

# }

Run the code above in your browser using DataLab