# NOT RUN {
# Test data
V = matrix(nrow=5, ncol=5, c( # matrix to be bent
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 (2014)
bend(inmat=V, method="lrs")
# Example 6: Bending a correlation matrix using the method of Schaeffer (2014)
bend(V2, method="lrs")
# Example 7: Bending the same correlation matrix using a weighted development of Schaeffer (2014)
bend(V2, W, reciprocal=TRUE, method="lrs")
# Example 8: Bending a covariance matrix using a weighted development of Schaeffer (2014)
bend(V, W, reciprocal=TRUE, method="lrs")
# }
Run the code above in your browser using DataLab