Skip to contents

Correlation ordered factor matrix in C (symmetric)

Usage

corr_orderedfactor_matrix_symC(x, theta, xindex, offdiagequal)

Arguments

x

Matrix x

theta

Theta vector

xindex

Index to use

offdiagequal

What to set off-diagonal values with matching values to.

Value

Correlation matrix

Examples

corr_orderedfactor_matrix_symC(matrix(c(1,.5, 2,1.6, 1,0),ncol=2,byrow=TRUE),
                              c(1.5,1.8), 1, 1-1e-6)
#>           [,1]      [,2]      [,3]
#> [1,] 1.0000000 0.1053992 0.9999990
#> [2,] 0.1053992 1.0000000 0.1053992
#> [3,] 0.9999990 0.1053992 1.0000000
corr_orderedfactor_matrix_symC(matrix(c(0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4),
                                     ncol=4, byrow=TRUE),
  c(0.101, -0.714, 0.114, -0.755, 0.117, -0.76, 0.116, -0.752),
  4, 1-1e-6) * 6.85
#>          [,1]     [,2]     [,3]     [,4]
#> [1,] 6.850000 6.780478 4.704313 5.340117
#> [2,] 6.780478 6.850000 4.114234 4.779083
#> [3,] 4.704313 4.114234 6.850000 6.761553
#> [4,] 5.340117 4.779083 6.761553 6.850000