Learn R Programming

astsa (version 2.1)

matrixpwr: 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

Value

Returns matrix raised to the given power.

Arguments

A

a square matrix

power

single numeric

Author

D.S. Stoffer

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.

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

Run this code
# 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

Run the code above in your browser using DataLab