| 89473 |
hornik |
1 |
% File src/library/stats/man/ppplot.Rd
|
|
|
2 |
% Part of the R package, https://www.R-project.org
|
|
|
3 |
% Copyright 2026 R Core Team
|
|
|
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
|
|
6 |
\name{ppplot}
|
|
|
7 |
\alias{ppplot}
|
|
|
8 |
\title{
|
|
|
9 |
Probability-probability Plots
|
|
|
10 |
}
|
|
|
11 |
\description{
|
| 89480 |
hornik |
12 |
\code{ppplot} produces a probability-probability (P-P) plot of two numerical
|
| 89473 |
hornik |
13 |
variables. If \code{conf.level} is given, an estimate and corresponding
|
|
|
14 |
confidence band for the P-P curve under a
|
|
|
15 |
distribution-free semiparametric model is plotted.
|
|
|
16 |
}
|
|
|
17 |
\usage{
|
|
|
18 |
ppplot(x, y, plot.it = TRUE,
|
|
|
19 |
xlab = paste("Cumulative probabilities for", deparse1(substitute(x))),
|
|
|
20 |
ylab = paste("Cumulative probabilities for", deparse1(substitute(y))),
|
|
|
21 |
main = "P-P plot", ..., conf.level = NULL,
|
|
|
22 |
conf.args = list(link = "logit", type = "Wald", col = NA, border = NULL))
|
|
|
23 |
}
|
|
|
24 |
\arguments{
|
|
|
25 |
\item{x}{the first sample for \code{ppplot}, a numerical variable.
|
|
|
26 |
}
|
|
|
27 |
\item{y}{the second sample for \code{ppplot}, a numerical variable.
|
|
|
28 |
}
|
|
|
29 |
\item{plot.it}{logical. Should the result be plotted?
|
|
|
30 |
}
|
|
|
31 |
\item{xlab, ylab}{the \code{xlab} and \code{ylab} refer to the y
|
|
|
32 |
and x axes respectively.
|
|
|
33 |
}
|
|
|
34 |
\item{main}{a main title for the plot.}
|
|
|
35 |
\item{\dots}{graphical parameters.
|
|
|
36 |
}
|
|
|
37 |
\item{conf.level}{confidence level of the band. The default, \code{NULL}, does not
|
|
|
38 |
lead to the computation of a confidence band.
|
|
|
39 |
}
|
|
|
40 |
\item{conf.args}{list of arguments defining confidence band computation and
|
|
|
41 |
visualisation: \code{link} defines the link function of a
|
| 89480 |
hornik |
42 |
distribution-free semiparametric model, \code{type} specifies the
|
| 89473 |
hornik |
43 |
statistical concept the confidence band is derived from; see
|
|
|
44 |
\code{\link[stats]{free1way}} for other options. The remaining
|
|
|
45 |
elements govern how the band is plotted.
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
\details{
|
|
|
49 |
|
|
|
50 |
For independent two samples, denoted \eqn{x} and \eqn{y},
|
|
|
51 |
the function produces a probability-probability plot \bibcitep{R:Wilk+Gnanadesikan:1968} of pairs
|
|
|
52 |
\eqn{(\hat{F}_{x}(z), \hat{F}_{y}(z))} for observed data \eqn{z = (x, y)}.
|
|
|
53 |
|
|
|
54 |
If the data generating process follows a model where the two distribution
|
|
|
55 |
functions, after appropriate transformation, are horizontally shifted
|
|
|
56 |
versions of each other, the probability-probability curve is a simple function of this shift and
|
|
|
57 |
confidence bands can be obtained from a confidence interval for this shift
|
|
|
58 |
parameter, see \code{\link[stats]{free1way}} for the model and
|
|
|
59 |
\bibcitet{R:Sewak+Hothorn:2023} for the connection to ROC curves.
|
|
|
60 |
|
|
|
61 |
Substantial deviations of the empirical (step function) from the theoretical
|
|
|
62 |
(smooth) curve indicates lack of fit of the semiparametric model.
|
|
|
63 |
|
|
|
64 |
}
|
|
|
65 |
\value{
|
|
|
66 |
An object of class \code{stepfun}.
|
|
|
67 |
}
|
|
|
68 |
\references{
|
|
|
69 |
\bibshow{*}
|
|
|
70 |
}
|
| 89556 |
smeyer |
71 |
\examples{\donttest{% needs Matrix, so tested in reg-examples3
|
| 89473 |
hornik |
72 |
|
|
|
73 |
## make example reproducible
|
|
|
74 |
set.seed(29)
|
|
|
75 |
|
|
|
76 |
## well-fitting logistic model
|
|
|
77 |
nd <- data.frame(groups = gl(2, 50, labels = paste0("G", 1:2)))
|
|
|
78 |
nd$y <- rlogis(nrow(nd), location = c(0, 2)[nd$groups])
|
|
|
79 |
with(with(nd, split(y, groups)),
|
|
|
80 |
ppplot(G1, G2, conf.level = .95,
|
|
|
81 |
conf.args = list(link = "logit", type = "Wald", col = 2)))
|
|
|
82 |
# with appropriate Wilcoxon test and log-odds ratio
|
|
|
83 |
coef(ft <- free1way(y ~ groups, data = nd))
|
|
|
84 |
# the model-based probability-probability curve
|
|
|
85 |
prb <- 1:99 / 100
|
|
|
86 |
points(prb, plogis(qlogis(prb) - coef(ft)), pch = 3)
|
|
|
87 |
|
|
|
88 |
## the corresponding model-based receiver operating characteristic (ROC)
|
|
|
89 |
## curve, see Sewak and Hothorn (2023)
|
|
|
90 |
plot(prb, plogis(qlogis(1 - prb) - coef(ft), lower.tail = FALSE),
|
|
|
91 |
xlab = "1 - Specificity", ylab = "Sensitivity", type = "l",
|
|
|
92 |
main = "ROC Curve")
|
|
|
93 |
abline(a = 0, b = 1, col = "lightgrey")
|
|
|
94 |
# with confidence band
|
|
|
95 |
lines(prb, plogis(qlogis(1 - prb) - confint(ft, test = "Rao")[1],
|
|
|
96 |
lower.tail = FALSE), lty = 3)
|
|
|
97 |
lines(prb, plogis(qlogis(1 - prb) - confint(ft, test = "Rao")[2],
|
|
|
98 |
lower.tail = FALSE), lty = 3)
|
|
|
99 |
# and corresponding area under the ROC curve (AUC)
|
|
|
100 |
# with score confidence interval
|
|
|
101 |
coef(ft, what = "AUC")
|
|
|
102 |
confint(ft, test = "Rao", what = "AUC")
|
|
|
103 |
|
|
|
104 |
## ill-fitting normal model
|
|
|
105 |
nd$y <- rnorm(nrow(nd), mean = c(0, .5)[nd$groups], sd = c(1, 1.5)[nd$groups])
|
|
|
106 |
with(with(nd, split(y, groups)),
|
|
|
107 |
ppplot(G1, G2, conf.level = .95,
|
|
|
108 |
conf.args = list(link = "probit", type = "Wald", col = 2)))
|
|
|
109 |
# inappropriate probit model
|
|
|
110 |
coef(free1way(y ~ groups, data = nd, link = "probit"))
|
|
|
111 |
|
| 89556 |
smeyer |
112 |
}}
|
| 89473 |
hornik |
113 |
\keyword{hplot}
|
|
|
114 |
\keyword{distribution}
|