basepcor: A base precision's Cholesky model for a correlation matrix

View source: R/basepcor.R

basepcorR Documentation

A base precision's Cholesky model for a correlation matrix

Description

The basepcor class contain a correlation matrix base, the parameter vector theta, that generates or is generated by base, the dimension p, the index iLtheta for theta in the (lower) Cholesky, and the Hessian around it I0, see details.

Usage

basepcor(base, p, iLtheta, d0, iparams)

## S3 method for class 'numeric'
basepcor(base, p, iLtheta, d0, iparams)

## S3 method for class 'matrix'
basepcor(base, p, iLtheta, d0, iparams)

## S3 method for class 'basepcor'
print(x, ...)

Arguments

base

a correlation matrix, or numeric vector as the parameter(s) to define correlation matrix.

p

integer (needed if base is vector): the dimension.

iLtheta

integer vector or 'graphpcor' to specify the (vectorized) position where 'theta' is placed in the initial (before the fill-in) Cholesky (lower triangle) factor. If missing, default, assumes the dense case as iLtheta = which(lower.tri(...)), giving length(theta)=p(p-1)/2.

d0

numeric vector to specify the diagonal of the Cholesky factor for the initial precision matrix Q0. Default, if not provided, is d0 = p:1.

iparams

integer ordered vector with length equal the number of parameters used to specify common parameter values. Default is 1:m, m=length(theta). Example: By setting iparams = c(1,1,2,3), m=3, the first and second parameters are considered to be the same. NOTE: c(1,2,1) is allowed, but c(2,1,2) is not.

x

a basepcor object.

...

further arguments passed on.

Details

The Inverse Transform Parametrization - ITP, is applied by starting with a

\mathbf{L}^{(0)} = \left[ \begin{array}{ccccc} \textrm{p} & 0 & 0 & \ldots & 0 \\ \theta_1 & \textrm{p-}1 & 0 & \ldots & 0 \\ \theta_2 & \theta_p & \textrm{p-}2 & \ddots & \vdots \\ \vdots & \vdots & \ddots & \ddots & 0 \\ \theta_{p-1} & \theta_{2p-3} & \ldots & \theta_m & 1 \end{array}\right] .

Then compute \mathbf{Q}^{(0)} = \mathbf{L}\mathbf{L}^{T}, \mathbf{V}^{(0)} = (\mathbf{Q}^{(0)})^{-1} and s_{i}^{(0)} = \sqrt{\mathbf{V}_{i,i}^{(0)}}, and define \mathbf{S}^{(0)} = diag(s_1^{(0)},\ldots,s_p^{(0)}) in order to have \mathbf{C}= \mathbf{S}^{-1}\mathbf{V}^{(0)}\mathbf{S}^{-1}.

The decomposition of the Hessian matrix around the base model, I0, formally \mathbf{I}(\theta_0), is numerically computed. This element has the following attributes: 'h.5' as \mathbf{I}^{1/2}(\theta_0), and 'hneg.5' as \mathbf{I}^{-1/2}(\theta_0).

Value

a basepcor object

a basepcor object

Methods (by class)

  • basepcor(numeric): Build a basepcor from the parameter vector.

  • basepcor(matrix): Build a basepcor from a correlation matrix.

Methods (by generic)

  • print(basepcor): Print method for 'basepcor'

Functions

  • basepcor(): Build a basepcor object.

Examples

## A correlation matrix
c0 <- matrix(c( 1.0,  0.8, -0.5,
                0.8,  1.0, -0.4,
               -0.5, -0.4,  1.0), 3)

## p = 3, m = 3
b1 <- basepcor(c0)
b1

## p = 3, m = 2
b2 <- basepcor(c0, iLtheta = c(2,3))
b2

all.equal(b1$base, b2$base)

## Hessian
hessian(b2)
hessian(b1, ifixed = 3)
hessian(b1)

## p = 4, m = 4
th4 <- c(0.5,-1,0.5,-0.3)
ith4 <- c(2,3,8,12)
b44 <- basepcor(th4, p = 4, iLtheta = ith4)
b44

Sparse(round(solve(b44$base), 4), zeros.rm = TRUE)

## p = 4, m = 3 (with some common theta)
th3 <- c(0.5, -1, -0.3)
ip3 <- c(1, 2, 1, 3) ## 1st == 3rd
b43 <- basepcor(th3, p = 4, iLtheta = ith4, iparams = ip3)

all.equal(b44$base, b43$base) ## TRUE

## parameter dimension is now reduced
hessian(b44)
hessian(b43)

## If a subset of the parameters are known (fixed), then the
## Hessian is only computed with respect to the unknown ones
hessian(basepcor(th4, p=4, iLtheta = ith4), ifixed = 2:3)
hessian(basepcor(th4, p=4, iLtheta = ith4), ifixed = 1)
hessian(basepcor(th4, p=4, iLtheta = ith4), ifixed = 3)

hessian(basepcor(th3, p=4, iLtheta = ith4,
                 iparams = ip3), ifixed = 3)
hessian(basepcor(th3, p=4, iLtheta = ith4,
                 iparams = ip3), ifixed = 2:3)
hessian(basepcor(th3, p=4, iLtheta = ith4,
                 iparams = ip3), ifixed = 1:2)

## check
hessian(basepcor(th3, p=4, iLtheta = ith4,
                 iparams = ip3), ifixed = NULL)


graphpcor documentation built on March 23, 2026, 9:07 a.m.