matrixpwr: Powers of a Square Matrix

View source: R/matrixpwr.R

matrixpwrR Documentation

Powers of a Square Matrix

Description

matrixpwr computes powers of a square matrix including negative powers for nonsingular matrices.

%^% is a more intuitive interface as an operator.

Usage

matrixpwr(A, power)

A %^% power

Arguments

A

a square matrix

power

single numeric

Details

Raises matrix to the specified power. The matrix must be square and if power < 0, the matrix must be nonsingular.

Note that %^% is defined as "%^%" <- function(A, power) matrixpwr(A, power)

If power = 0, the identity matrix is returned.

Value

Returns matrix raised to the given power.

Author(s)

D.S. Stoffer

References

You can find demonstrations of astsa capabilities at FUN WITH ASTSA.

The most recent version of the package can be found at https://github.com/nickpoison/astsa/.

In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.

The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/.

Examples

# 2-state Markov transition matrix to steady state
( P = matrix(c(.7,.4,.3,.6), 2) )
P %^% 50

# surround with parentheses if used in an expression
c(.2, .8) %*% (P %^% 50)

# Inverse square root
var(econ5) %^% -.5

astsa documentation built on May 29, 2024, 10:29 a.m.