Description Usage Arguments Details Value References See Also Examples
Computes confidence bands for functions defined by a model.
There is a method for objects inheriting from class
"ks.test"
.
1 |
object |
a fitted model object. |
level |
the confidence level required. |
... |
additional argument(s) for methods. |
confband
is a generic function.
For objects of class "ks.test"
a confidence band for the treatment
function in two-sample parallel designs is computed following Switzer
(1976). This function is also known as quantile-quantile plot.
A matrix with columns giving the estimated function ("Estimate"
) as
well as lower ("lwr"
) and upper ("upr"
) confidence limits
for each function argument ("x"
). Confidence bands control
the coverage probability ("level"
) for all intervals
simultaneously.
Paul Switzer (1976). Confidence Procedures for Two-sample Problems. Biometrika 63(1), 13–25. doi: 10.1093/biomet/63.1.13.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # data from Switzer (1976)
angle <- c(-31, -30, -25, -25, -23, -23, -22, -20, -20, -18,
-18, -18, -16, -15, -15, -14, -13, -11, -10, - 9,
- 8, - 7, - 7, - 7, - 6, - 6, - 4, - 4, - 3, - 2,
- 2, - 1, 1, 1, 4, 5, 11, 12, 16, 34,
-31, -20, -18, -16, -16, -16, -15, -14, -14, -14,
-14, -13, -13, -11, -11, -10, - 9, - 9, - 8, - 7,
- 7, - 6, - 6, -5, - 5, - 5, - 4, - 2, - 2, - 2,
0, 0, 1, 1, 2, 4, 5, 5, 6, 17)
sex <- gl(2, 40, labels = c("Female", "Male"))
(sk <- ks.test(angle ~ sex))
cb <- confband(sk, level = .945)
plot(cb) # => no indication of deviation from the null because
# diagonal is covered by the confidence band
set.seed(29)
# artificial example
grp <- rep(gl(2, 1, labels = c("Group A", "Group B")), c(40, 60))
# shift model
x1 <- rnorm(length(grp), mean = c(1, 2)[grp], sd = 1)
# shift/scale model
x2 <- rnorm(length(grp), mean = c(1, 2)[grp], sd = c(1, .5)[grp])
layout(matrix(1:4, nrow = 2))
# treatment function is parallel to diagonal, `significant'
# deviation from the null of both distributions being equal
# because diagonal not covered by confidence band
plot(confband(ks.test(x1 ~ grp)), main = "Shift model")
# true treatment function in blue
lines(-3:3, -3:3 + 1, col = "blue")
boxplot(x1 ~ grp)
# shift model not appropriate because treatment function
# is nonlinear, also `significant' deviation from null
plot(confband(ks.test(x2 ~ grp)), main = "Shift/scale model")
# true treatment function
lines(-3:3, qnorm(pnorm(-3:3, mean = 1, sd = 1), mean = 2, sd = .5),
col = "blue")
boxplot(x2 ~ grp)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.