1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
\name{mroot}
\alias{mroot}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{Smallest square root of matrix}
\description{ Find a square root of a positive semi-definite matrix,
having as few columns as possible. Uses either pivoted Cholesky
decomposition or singular value decomposition to do this.
}
\usage{
mroot(A,rank=NULL,method="chol")
}
%- maybe also `usage' for other objects documented here.
\arguments{
\item{A}{ The positive semi-definite matrix, a square root of which is
to be found.}
\item{rank}{if the rank of the matrix \code{A} is known then it should
be supplied. \code{NULL} or <1 imply that it should be estimated.}
\item{method}{ \code{"chol"} to use pivoted Cholesky decompositon,
which is fast but tends to over-estimate rank. \code{"svd"} to use
singular value decomposition, which is slower, but is the most accurate way
to estimate rank.}
}
\details{ The function is primarily of use for turning penalized regression problems into ordinary regression problems. Given that \code{A} is positive semi-definite the SVD option actually uses a symmetric eigen routine, which gives the same result more efficiently.
}
\value{ A matrix, \eqn{ {\bf B}}{B} with as many columns as the rank of
\eqn{ {\bf A}}{A}, and such that \eqn{ {\bf A} = {\bf BB}^\prime}{A=BB'}.}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
\examples{
require(mgcv)
set.seed(0)
a <- matrix(runif(24),6,4)
A <- a\%*\%t(a) ## A is +ve semi-definite, rank 4
B <- mroot(A) ## default pivoted choleski method
tol <- 100*.Machine$double.eps
chol.err <- max(abs(A-B\%*\%t(B)));chol.err
if (chol.err>tol) warning("mroot (chol) suspect")
B <- mroot(A,method="svd") ## svd method
svd.err <- max(abs(A-B\%*\%t(B)));svd.err
if (svd.err>tol) warning("mroot (svd) suspect")
}
\keyword{models} \keyword{smooth} \keyword{regression}%-- one or more ..
|