Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dlmSvd2var

Compute a nonnegative definite matrix from its Singular Value Decomposition


Description

The function computes a nonnegative definite matrix from its Singular Value Decomposition.

Usage

dlmSvd2var(u, d)

Arguments

u

a square matrix, or a list of square matrices for a vectorized usage.

d

a vector, or a matrix for a vectorized usage.

Details

The SVD of a nonnegative definite n by n square matrix x can be written as u d^2 u', where u is an n by n orthogonal matrix and d is a diagonal matrix. For a single matrix, the function returns just u d^2 u'. Note that the argument d is a vector containing the diagonal elements of d. For a vectorized usage, u is a list of square matrices, and d is a matrix. The returned value in this case is a list of matrices, with the element i being u[[i]] %*% diag(d[i,]^2) %*% t(u[[i]]).

Value

The function returns a nonnegative definite matrix, reconstructed from its SVD, or a list of such matrices (see details above).

Author(s)

Giovanni Petris GPetris@uark.edu

References

Horn and Johnson, Matrix analysis, Cambridge University Press (1985)

Examples

x <- matrix(rnorm(16),4,4)
x <- crossprod(x)
tmp <- La.svd(x)
all.equal(dlmSvd2var(tmp$u, sqrt(tmp$d)), x)
## Vectorized usage
x <- dlmFilter(Nile, dlmModPoly(1, dV=15099, dW=1469))
x$se <- sqrt(unlist(dlmSvd2var(x$U.C, x$D.C)))
## Level with 50% probability interval
plot(Nile, lty=2)
lines(dropFirst(x$m), col="blue")
lines(dropFirst(x$m - .67*x$se), lty=3, col="blue")
lines(dropFirst(x$m + .67*x$se), lty=3, col="blue")

dlm

Bayesian and Likelihood Analysis of Dynamic Linear Models

v1.1-5
GPL (>= 2)
Authors
Giovanni Petris [aut, cre], Wally Gilks [ctb] (Author of original C code for ARMS)
Initial release
2018-05-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.