mbend (version 1.2.3)

bend: Matrix bending to positive-definite

Description

Bending a non-positive-definite matrix to positive-definite, using weighted or unweighted methods.

Usage

bend(inmat, wtmat, reciprocal = FALSE, max.iter = 10000,
  small.positive = 1e-04, method = "hj")

Arguments

inmat

: The matrix to be bended.

wtmat

: The weight matrix for weighted bending. If no input is provided, the unweighted method (default) is used.

reciprocal

: If TRUE, reciprocal of the weighting factors are used. If no input is provided, default = FALSE.

max.iter

: Maximum number of iterations. If no input is provided, default = 10000.

small.positive

: A small positive value replacing smaller eigenvalues. If no input is provided, default = 0.0001.

method

: "hj" (Jorjani et al., 2003) or "lrs" (Schaeffer, 2010), default = "hj"

Value

bended : The output bended matrix.

Examples

Run this code
# NOT RUN {
# Test data
V = matrix(nrow=5, ncol=5, c( # matrix to be bended
100,  95,  80,  40,  40,
 95, 100,  95,  80,  40,
 80,  95, 100,  95,  80,
 40,  80,  95, 100,  95,
 40,  40,  80,  95, 100))
W = matrix(nrow=5, ncol=5, c( # matrix of weights
1000,  500,   20,   50,  200,
 500, 1000,  500,    5,   50,
  20,  500, 1000,   20,   20,
  50,    5,   20, 1000,  200,
 200,   50,   20,  200, 1000))

# Example 1: Unweighted bending
bend(V)
## The default method (Jojani et al. 2003) is used.

# Example 2: Weighted bending using reciprocal of the weighting factors
bend(inmat=V, wtmat=W, reciprocal=TRUE)

# Example 3: Bending with fixed elements
## Assume we want to keep V[1:2, 1:2] constant.
W2 = W; W2[1:2, 1:2] = 0
bend(inmat=V, wtmat=W2, reciprocal=TRUE)

# Example 4: Bending a correlation matrix
V2 = cov2cor(V)
bend(V2, W, reciprocal=TRUE)

# Example 5: Bending using the method of Schaeffer (2010)
bend(inmat=V, method="lrs")

# Example 6: Bending a correlation matrix using the method of Schaeffer (2010)
bend(V2, method="lrs")

# Example 7: Bending the same correlation matrix using a weighted development of Schaeffer (2010)
bend(V2, W, reciprocal=TRUE, method="lrs")

# Example 8: Bending a covariance matrix using a weighted development of Schaeffer (2010)
bend(V, W, reciprocal=TRUE, method="lrs")

# }

Run the code above in your browser using DataLab