View source: R/pairsRosenblatt.R
| pairsRosenblatt | R Documentation |
pairsColList() creates a list containing
information about colors for a given matrix of (approximate aka
“pseudo”) p-values. These colors are used in
pairsRosenblatt() for visualizing a graphical
goodness-of-fit test based on pairwise Rosenblatt transformed data.
pairsRosenblatt(cu.u, pvalueMat=pviTest(pairwiseIndepTest(cu.u)),
method = c("scatter", "QQchisq", "QQgamma",
"PPchisq", "PPgamma", "none"),
g1, g2, col = "B&W.contrast",
colList = pairsColList(pvalueMat, col=col),
main=NULL,
sub = gpviString(pvalueMat, name = "pp-values"),
panel = NULL, do.qqline = TRUE,
keyOpt = list(title="pp-value", rug.at=pvalueMat), ...)
pairsColList(P, pdiv = c(1e-04, 0.001, 0.01, 0.05, 0.1, 0.5),
signif.P = 0.05, pmin0 = 1e-05, bucketCols = NULL,
fgColMat = NULL, bgColMat = NULL, col = "B&W.contrast",
BWcutoff = 170,
bg.col = c("ETHCL", "zurich", "zurich.by.fog", "baby",
"heat", "greenish"),
bg.ncol.gap = floor(length(pdiv)/3),
bg.col.bottom = NULL, bg.col.top = NULL, ...)
cu.u |
|
pvalueMat |
|
method |
Note: These methods merely just set |
g1 |
|
g2 |
|
colList |
|
main |
title. |
sub |
sub-title with a smart default containing a global (p)p-value. |
panel |
a |
do.qqline |
if |
keyOpt |
argument passed to |
... |
additional arguments passed to |
P |
|
pdiv |
numeric vector of strictly increasing p-values in
(0,1) that determine the “buckets” for the background
colors of |
signif.P |
significance level (must be an element of |
pmin0 |
a Note that |
bucketCols |
|
fgColMat |
|
bgColMat |
|
col |
foreground color (defaults to "B&W.contrast" which switches
black/white according to |
BWcutoff |
number in (0, 255) for switching
foreground color if |
bg.col |
color scheme for the background colors. |
bg.ncol.gap |
number of colors left out as "gap" for
color buckets below/above |
bg.col.bottom |
|
bg.col.top |
|
Extra arguments of pairsRosenblatt() are passed to
.pairsCond(), these notably may include key, true
by default, which draws a color key for the colors used as panel
background encoding (pseudo) p-values.
pairsColList() is basically an auxiliary function to specify
the colors used in the graphical goodness-of-fit test as
conducted by pairsRosenblatt(). The latter is described in
detail in Hofert and Mächler (2013).
See also demo(gof_graph).
pairsRosenblatt: invisibly, the result of .pairsCond().
pairsColList: a named list with components
fgColMatmatrix of foreground colors.
bgColMatmatrix of background colors
(corresponding to P).
bucketColsvector containing the colors
corresponding to pvalueBuckets as described above.
pvalueBucketsvector containing the
endpoints of the p-value buckets.
Hofert, M. and Mächler, M. (2014) A graphical goodness-of-fit test for dependence models in higher dimensions; Journal of Computational and Graphical Statistics, 23(3), 700–716. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10618600.2013.812518")}
pairwiseCcop() for the tools behind the scenes.
demo(gof_graph) for examples.
## 2-dim example {d = 2} ===============
##
## "t" Copula with 22. degrees of freedom; and (pairwise) tau = 0.5
nu <- 2.2 # degrees of freedom
## Define the multivariate distribution
tCop <- ellipCopula("t", param=iTau(ellipCopula("t", df=nu), tau = 0.5),
dim=2, df=nu)
set.seed(19)
X <- qexp(rCopula(n = 400, tCop))
## H0 (wrongly): a Normal copula, with correct tau
copH0 <- ellipCopula("normal", param=iTau(ellipCopula("normal"), tau = 0.5))
## create array of pairwise copH0-transformed data columns
cu.u <- pairwiseCcop(pobs(X), copula = copH0)
## compute pairwise matrix of p-values and corresponding colors
pwIT <- pairwiseIndepTest(cu.u, N=200) # (d,d)-matrix of test results
round(pmat <- pviTest(pwIT), 3) # pick out p-values
## .286 and .077
pairsRosenblatt(cu.u, pvalueMat= pmat)
### A shortened version of demo(gof_graph) -------------------------------
N <- 32 ## too small, for "testing"; realistically, use a larger one:
if(FALSE)
N <- 100
## 5d Gumbel copula ##########
n <- 250 # sample size
d <- 5 # dimension
family <- "Gumbel" # copula family
tau <- 0.5
set.seed(17)
## define and sample the copula (= H0 copula), build pseudo-observations
cop <- getAcop(family)
th <- cop@iTau(tau) # correct parameter value
copH0 <- onacopulaL(family, list(th, 1:d)) # define H0 copula
U. <- pobs(rCopula(n, cop=copH0))
## create array of pairwise copH0-transformed data columns
cu.u <- pairwiseCcop(U., copula = copH0)
## compute pairwise matrix of p-values and corresponding colors
pwIT <- pairwiseIndepTest(cu.u, N=N, verbose=interactive()) # (d,d)-matrix of test results
round(pmat <- pviTest(pwIT), 3) # pick out p-values
## Here (with seed=1): no significant ones, smallest = 0.0603
## Plots ---------------------
## plain (too large plot symbols here)
pairsRosenblatt(cu.u, pvalueMat=pmat, pch=".")
## with title, no subtitle
pwRoto <- "Pairwise Rosenblatt transformed observations"
pairsRosenblatt(cu.u, pvalueMat=pmat, pch=".", main=pwRoto, sub=NULL)
## two-line title including expressions, and centered
title <- list(paste(pwRoto, "to test"),
substitute(italic(H[0]:C~~bold("is Gumbel with"~~tau==tau.)),
list(tau.=tau)))
line.main <- c(4, 1.4)
pairsRosenblatt(cu.u, pvalueMat=pmat, pch=".",
main=title, line.main=line.main, main.centered=TRUE)
## Q-Q plots -- can, in general, better detect outliers
pairsRosenblatt(cu.u, pvalueMat=pmat, method="QQchisq", cex=0.2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.