| basecor | R Documentation |
The basecor class contain a correlation matrix base,
the parameter vector theta, that generates
or is generated by base, the dimention p,
the index iLtheta for theta in the (lower) Cholesky,
and the Hessian around it I0, see details.
basecor(base, p, parametrization = "cpc", iparams, iLtheta)
## S3 method for class 'numeric'
basecor(base, p, parametrization = "cpc", iparams, iLtheta)
## S3 method for class 'matrix'
basecor(base, p, parametrization = "cpc", iparams, iLtheta)
## S3 method for class 'basecor'
print(x, ...)
base |
numeric vector/matrix used to define the base correlation matrix. If numeric vector with length 'm', 'm' should be 'p(p-1)/2' in the dense model case and 'length(iLtheta)' in the sparse model case. |
p |
integer with the dimension, the number of rows/columns of the correlation matrix. |
parametrization |
character to specify the parametrization used. The available ones are "cpc" (or "CPC") or "sap" (or "SAP"). See Details. The default is "cpc". |
iparams |
integer ordered vector with length equal
the number of parameters used to specify common parameter values.
If missing, assumed to be |
iLtheta |
integer vector to specify the (vectorized) position
where 'theta' will be placed in the (lower triangle) Cholesky
factorization of the correlation matrix. Default
(missing, or if NULL) and assumes |
x |
a basecor object. |
... |
further arguments passed on. |
For 'parametrization' = "CPC" or 'parametrization' = "cpc":
The Canonical Partial Correlation - CPC parametrization,
Lewandowski, Kurowicka, and Joe (2009), compute
r[k] = tanh(\theta[k]), for k=1,...,m,
and the two p\times p matrices
A = \left[
\begin{array}{ccccc}
1 & & & & \\
r_1 & 1 & & & \\
r_2 & r_p & 1 & & \\
\vdots & \vdots & \ddots & \ddots & \\
r_{p-1} & r_{2p-3} & \ldots & r_m & 1
\end{array} \right]
\textrm{ and } B = \left[
\begin{array}{ccccc}
1 & & & & \\
\sqrt{1-r_1^2} & 1 & & & \\
\sqrt{1-r_2^2} & \sqrt{1-r_p^2} & 1 & & \\
\vdots & \vdots & \ddots & \ddots & \\
\sqrt{1-r_{p-1}^2} & \sqrt{r_{2p-3}^2} & \ldots & \sqrt{1-r_m^2} & 1
\end{array} \right]
The matrices A and B are then used
to build the Cholesky factor of the correlation matrix,
given as
L = \left[
\begin{array}{ccccc}
1 & 0 & 0 & \ldots & 0\\
A_{2,1} & B_{2,1} & 0 & \ldots & 0\\
A_{3,1} & A_{3,2}B_{3,1} & B_{3,1}B_{3,2} & & \vdots \\
\vdots & \vdots & \ddots & \ddots & 0\\
A_{p,1} & A_{p,2}B_{p,1} & \ldots &
A_{p,p-1}\prod_{k=1}^{p-1}B_{p,k} & \prod_{k=1}^{p-1}B_{p,k}
\end{array} \right]
Note: The determinant of the correlation matriz is
\prod_{i=2}^p\prod_{j=1}^{i-1}B_{i,j} = \prod_{i=2}^pL_{i,i}
For 'parametrization' = "SAP" or 'parametrization' = "sap":
The Standard Angles Parametrization - SAP, as described in
Rapisarda, Brigo and Mercurio (2007), compute
x[k] = \pi/(1+\exp(-\theta[k])), for k=1,...,m,
and the two p\times p matrices
A = \left[
\begin{array}{ccccc}
1 & & & & \\
\cos(x_1) & 1 & & & \\
\cos(x_2) & \cos(x_p) & 1 & & \\
\vdots & \vdots & \ddots & \ddots & \\
\cos(x_{p-1}) & \cos(x_{2p-3}) & \ldots & \cos(x_m) & 1
\end{array} \right] \textrm{ and } B = \left[
\begin{array}{ccccc}
1 & & & & \\
\sin(x_1) & 1 & & & \\
\sin(x_2) & \sin(x_p) & 1 & & \\
\vdots & \vdots & \ddots & \ddots & \\
\sin(x_{p-1}) & \sin(x_{2p-3}) & \ldots & \sin(x_m) & 1
\end{array} \right]
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).
a basecor object
basecor(numeric): Build a basecor from the parameter vector.
basecor(matrix): Build a basecor from a correlation matrix.
print(basecor): Print method for 'basecor'
basecor(): Build a basecor object.
Rapisarda, Brigo and Mercurio (2007). Parameterizing correlations: a geometric interpretation. IMA Journal of Management Mathematics (2007) 18, 55-73. <doi 10.1093/imaman/dpl010>
Lewandowski, Kurowicka and Joe (2009) Generating Random Correlation Matrices Based on Vines and Extended Onion Method. Journal of Multivariate Analysis 100: 1989–2001. <doi: 10.1016/j.jmva.2009.04.008>
## 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)
## build the 'basecor'
b3 <- basecor(c0) ## base as matrix
b3
## elements
b3$base
b3$theta
## from 'theta'
th3 <- b3$theta
bth3 <- basecor(th3, p = 3) ## base as vector
bth3
## numerically the same
all.equal(c0, bth3$base, tol = 1e-4)
## from a numeric vector (theta)
th2 <- c(-1, -0.5)
b2 <- basecor(th2, p = 3, iLtheta = c(2,3))
b2
## from the correlation matrix
b2c <- basecor(b2$base, iLtheta = c(2,3))
all.equal(th2, b2c$theta, tol = 1e-4)
## Hessian around the base
hessian(b3)
hessian(b3, ifixed = 3)
hessian(b2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.