Skip to content

Commit 5dfd4b5

Browse files
committed
improve CDF$conf_int
1 parent f6abcf5 commit 5dfd4b5

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

R/CDF.R

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ CDF <- R6Class(
5151
private = list(
5252
.name = "Inference on Cumulative Distribution Function",
5353

54-
.lims_for_plot = NULL,
55-
5654
.preprocess = function() {
5755
super$.preprocess()
5856

@@ -83,18 +81,13 @@ CDF <- R6Class(
8381
dkw = sqrt(log(2 / alpha) / (2 * n))
8482
)
8583

86-
lower <- F_n - delta_n
87-
upper <- F_n + delta_n
84+
lower <- pmax(F_n - delta_n, 0)
85+
upper <- pmin(F_n + delta_n, 1)
8886

8987
private$.conf_int <- list(
9088
lower = stepfun(private$.data, lower),
9189
upper = stepfun(private$.data, upper)
9290
)
93-
94-
private$.lims_for_plot <- list(
95-
x = c(private$.data[1], private$.data[n]),
96-
y = c(min(lower), max(upper))
97-
)
9891
},
9992

10093
.print = function() {
@@ -105,13 +98,15 @@ CDF <- R6Class(
10598
plot.stepfun(
10699
private$.estimate,
107100
lty = "solid", do.points = FALSE,
108-
xlim = private$.lims_for_plot$x,
109-
ylim = private$.lims_for_plot$y,
101+
xlim = private$.data[c(1, length(private$.data))],
102+
xlab = expression(x),
103+
ylim = c(0, 1),
104+
ylab = expression(F[n](x)),
110105
main = paste(
111106
"Empirical CDF with",
112107
paste0(private$.conf_level * 100, "%"),
113108
"Confidence Bounds"
114-
), xlab = expression(x), ylab = expression(F[n](x))
109+
)
115110
)
116111
plot.stepfun(
117112
private$.conf_int$lower,
@@ -149,14 +144,16 @@ CDF <- R6Class(
149144
) +
150145
ggplot2::geom_hline(yintercept = c(0, 1), linetype = "dashed") +
151146
ggplot2::lims(
152-
x = private$.lims_for_plot$x, y = private$.lims_for_plot$y
147+
x = private$.data[c(1, length(private$.data))], y = c(0, 1)
153148
) +
154149
ggplot2::labs(
150+
x = expression(x),
151+
y = expression(F[n](x)),
155152
title = paste(
156153
"Empirical CDF with",
157154
paste0(private$.conf_level * 100, "%"),
158155
"Confidence Bounds"
159-
), x = expression(x), y = expression(F[n](x))
156+
)
160157
) +
161158
ggplot2::theme(
162159
plot.title = ggplot2::element_text(

R/MultipleComparison.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ MultipleComparison <- R6Class(
201201
}
202202
) +
203203
ggplot2::labs(
204-
title = "Permutation Distribution",
205-
x = "Statistic", y = "Frequency"
204+
x = "Statistic", y = "Frequency",
205+
title = "Permutation Distribution"
206206
) +
207207
ggplot2::theme(
208208
plot.title = ggplot2::element_text(

R/PermuTest.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ PermuTest <- R6Class(
300300
xintercept = private$.statistic, linetype = "dashed"
301301
) +
302302
ggplot2::labs(
303-
title = "Permutation Distribution",
304-
x = "Statistic", y = "Frequency"
303+
x = "Statistic", y = "Frequency",
304+
title = "Permutation Distribution"
305305
) +
306306
ggplot2::theme(
307307
plot.title = ggplot2::element_text(

0 commit comments

Comments
 (0)