smoothLG: Smooth NPD to Nearest PSD or PD Matrix

View source: R/smoothLG.R

smoothLGR Documentation

Smooth NPD to Nearest PSD or PD Matrix

Description

Smoothing an indefinite matrix to a PSD matrix via theory described by Lurie and Goldberg

Usage

smoothLG(
  R,
  start.val = NULL,
  Wghts = NULL,
  PD = FALSE,
  Penalty = 50000,
  eps = 1e-07
)

Arguments

R

Indefinite Matrix.

start.val

Optional vector of start values for Cholesky factor of S.

Wghts

An optional matrix of weights such that the objective function minimizes wij(rij - sij)^2, where wij is Wghts[i,j].

PD

Logical (default = FALSE). If PD = TRUE then the objective function will smooth the least squares solution to insure Positive Definitness.

Penalty

A scalar weight to scale the Lagrangian multiplier. Default = 50000.

eps

A small value to add to zero eigenvalues if smoothed matrix must be PD. Default = 1e-07.

Value

RLG

Lurie Goldberg smoothed matrix.

RKB

Knol and Berger smoothed matrix.

convergence

0 = converged solution, 1 = convergence failure.

start.val

Vector of start.values.

gr

Analytic gradient at solution.

Penalty

Scalar used to scale the Lagrange multiplier.

PD

User-supplied value of PD.

Wghts

Weights used to scale the squared euclidean distances.

eps

Value added to zero eigenvalue to produce PD matrix.

Author(s)

Niels Waller

Examples


data(BadRLG)

out<-smoothLG(R = BadRLG, Penalty = 50000)
cat("\nGradient at solution:", out$gr,"\n")
cat("\nNearest Correlation Matrix\n")
print( round(out$RLG,8) )

################################
##  Rousseeuw Molenbergh example
data(BadRRM)

out <- smoothLG(R = BadRRM, PD=TRUE)
cat("\nGradient at solution:", out$gr,"\n")
cat("\nNearest Correlation Matrix\n")
print( round(out$RLG,8) )

## Weights for the weighted solution
W <- matrix(c(1,  1, .5,
              1,  1,  1,
              .5,  1,  1), nrow = 3, ncol = 3)
tmp <- smoothLG(R = BadRRM,  PD = TRUE, eps=.001)
cat("\nGradient at solution:", out$gr,"\n")
cat("\nNearest Correlation Matrix\n")
print( round(out$RLG,8) )
print( eigen(out$RLG)$val )

## Rousseeuw Molenbergh 
## non symmetric matrix
T <- matrix(c(.8, -.9, -.9, 
            -1.2,  1.1, .3, 
             -.8, .4, .9),  nrow = 3, ncol = 3,byrow=TRUE)
out <- smoothLG(R = T,  PD = FALSE, eps=.001)

cat("\nGradient at solution:", out$gr,"\n")
cat("\nNearest Correlation Matrix\n")
print( round(out$RLG,8) )    


fungible documentation built on March 31, 2023, 5:47 p.m.

Related to smoothLG in fungible...