R/rags2ridges.R
evaluateSfit.Rd
Function aiding the visual inspection of the fit of an estimated (possibly regularized) precision matrix vis-a-vis the sample covariance matrix.
evaluateSfit(
Phat,
S,
diag = FALSE,
fileType = "pdf",
nameExt = "",
dir = getwd()
)
(Regularized) estimate of the precision matrix
.
Sample covariance matrix
A logical
determining if the diagonal elements should be
retained for plotting.
A character
determining the output file type. Must be
one of: "pdf", "eps".
A character
determining the extension of default
output names generated by the function.
A character
specifying the directory in which the visual
output is stored.
The function outputs various visualizations to aid the visual inspection of
an estimated and possibly regularized precision matrix vis-a-vis the sample
covariance matrix. The inverse of the estimated precision matrix P
is
taken to represent the estimated covariance matrix. The function then
outputs a QQ-plot and a heatmap of the observed covariances against the
estimated ones. The heatmap has the estimated covariances as
lower-triangular elements and the observed covariances as the
upper-triangular elements. The function outputs analogous plots for the
estimated and observed correlations. In case the observed covariance matrix
S
is non-singular also a QQ-plot an a heatmap are generated for the
estimated and observed partial correlations.
The function generates files with extension fileType
under default
output names. These files are stored in the directory dir
(default is
the working directory). To avoid overwriting of files when working in a
single directory one may employ the argument nameExt
. By using
nameExt
the default output names are extended with a character of
choice.
if (FALSE) {
## Obtain some (high-dimensional) data
p = 25
n = 10
set.seed(333)
X = matrix(rnorm(n*p), nrow = n, ncol = p)
colnames(X)[1:25] = letters[1:25]
Cx <- covML(X)
## Obtain regularized precision matrix
P <- ridgeP(Cx, lambda = 10, type = 'Alt')
## Evaluate visually fit of regularized precision matrix vis-a-vis sample covariance
evaluateSfit(P, Cx, diag = FALSE, fileType = "pdf", nameExt = "test")}