49
49
# ' both, depending on the `y_draw` argument.
50
50
# ' }
51
51
# ' \item{`ppc_pit_ecdf()`, `ppc_pit_ecdf_grouped()`}{
52
- # ' The ECDF of the empirical PIT values of `y` computed with respect to the
53
- # ' corresponding `yrep` values. `100 * prob`% central simultaneous confidence
54
- # ' intervals are provided to asses if `y` and `yrep` originate from the same
55
- # ' distribution. The PIT values can also be provided directly as `pit`.
52
+ # ' The PIT-ECDF of the empirical PIT values of `y` computed with respect to
53
+ # ' the corresponding `yrep` values. `100 * prob`% central simultaneous
54
+ # ' confidence intervals are provided to asses if `y` and `yrep` originate
55
+ # ' from the same distribution. The PIT values can also be provided directly
56
+ # ' as `pit`.
56
57
# ' See Säilynoja et al. (2021) for more details.}
57
58
# ' }
58
59
# '
73
74
# ' # ppc_ecdf_overlay with continuous data (set discrete=TRUE if discrete data)
74
75
# ' ppc_ecdf_overlay(y, yrep[sample(nrow(yrep), 25), ])
75
76
# '
76
- # ' # ECDF and ECDF difference plot of the PIT values of y compared to yrep
77
- # ' # with 99% simultaneous confidence bands.
77
+ # ' # PIT- ECDF and PIT- ECDF difference plot of the PIT values of y compared to
78
+ # ' # yrep with 99% simultaneous confidence bands.
78
79
# ' ppc_pit_ecdf(y, yrep, prob = 0.99, plot_diff = FALSE)
79
80
# ' ppc_pit_ecdf(y, yrep, prob = 0.99, plot_diff = TRUE)
80
81
# ' }
107
108
# ' ppc_ecdf_overlay_grouped(y, yrep[1:25, ], group = group)
108
109
# '
109
110
# ' \donttest{
110
- # ' # ECDF difference plots of the PIT values by group
111
+ # ' # PIT- ECDF plots of the PIT values by group
111
112
# ' # with 99% simultaneous confidence bands.
112
- # ' ppc_pit_ecdf_grouped(y, yrep, group=group, prob=0.99, plot_diff = TRUE )
113
+ # ' ppc_pit_ecdf_grouped(y, yrep, group=group, prob=0.99)
113
114
# ' }
114
115
# '
115
116
# ' \donttest{
@@ -612,7 +613,7 @@ ppc_pit_ecdf <- function(y,
612
613
) %> %
613
614
unlist()
614
615
if (is.null(K )) {
615
- K <- nrow(yrep ) + 1
616
+ K <- min( nrow(yrep ) + 1 , 1000 )
616
617
}
617
618
} else {
618
619
inform(" 'pit' specified so ignoring 'y', and 'yrep' if specified." )
@@ -631,7 +632,7 @@ ppc_pit_ecdf <- function(y,
631
632
lims <- ecdf_intervals(gamma = gamma , N = N , K = K )
632
633
ggplot() +
633
634
aes(
634
- x = 1 : K / K ,
635
+ x = seq( 0 , 1 , length.out = K ) ,
635
636
y = ecdf(pit )(seq(0 , 1 , length.out = K )) -
636
637
(plot_diff == TRUE ) * seq(0 , 1 , length.out = K ),
637
638
color = " y"
@@ -679,7 +680,7 @@ ppc_pit_ecdf_grouped <-
679
680
) %> %
680
681
unlist()
681
682
if (is.null(K )) {
682
- K <- nrow(yrep ) + 1
683
+ K <- min( nrow(yrep ) + 1 , 1000 )
683
684
}
684
685
} else {
685
686
inform(" 'pit' specified so ignoring 'y' and 'yrep' if specified." )
@@ -691,7 +692,7 @@ ppc_pit_ecdf_grouped <-
691
692
N_g <- sum(group == g )
692
693
adjust_gamma(
693
694
N = N_g ,
694
- K = min( N_g , K ),
695
+ K = ifelse(is.null( K ), N_g , K ),
695
696
prob = prob ,
696
697
interpolate_adj = interpolate_adj
697
698
)
@@ -700,21 +701,23 @@ ppc_pit_ecdf_grouped <-
700
701
701
702
data <- data.frame (pit = pit , group = group ) %> %
702
703
group_by(group ) %> %
703
- dplyr :: group_map(~ data.frame (
704
- ecdf_value = ecdf(.x $ pit )(seq(0 , 1 , length.out = min(nrow(.x ), K ))),
705
- group = .y [1 ],
706
- lims_upper = ecdf_intervals(
707
- gamma = gammas [[unlist(.y [1 ])]],
708
- N = nrow(.x ),
709
- K = min(nrow(.x ), K )
710
- )$ upper [- 1 ] / nrow(.x ),
711
- lims_lower = ecdf_intervals(
712
- gamma = gammas [[unlist(.y [1 ])]],
713
- N = nrow(.x ),
714
- K = min(nrow(.x ), K )
715
- )$ lower [- 1 ] / nrow(.x ),
716
- x = seq(0 , 1 , length.out = min(nrow(.x ), K ))
717
- )) %> %
704
+ dplyr :: group_map(
705
+ ~ data.frame (
706
+ ecdf_value = ecdf(.x $ pit )(seq(0 , 1 , length.out = ifelse(is.null(K ), nrow(.x ), K ))),
707
+ group = .y [1 ],
708
+ lims_upper = ecdf_intervals(
709
+ gamma = gammas [[unlist(.y [1 ])]],
710
+ N = nrow(.x ),
711
+ K = ifelse(is.null(K ), nrow(.x ), K )
712
+ )$ upper [- 1 ] / nrow(.x ),
713
+ lims_lower = ecdf_intervals(
714
+ gamma = gammas [[unlist(.y [1 ])]],
715
+ N = nrow(.x ),
716
+ K = ifelse(is.null(K ), nrow(.x ), K )
717
+ )$ lower [- 1 ] / nrow(.x ),
718
+ x = seq(0 , 1 , length.out = ifelse(is.null(K ), nrow(.x ), K ))
719
+ )
720
+ ) %> %
718
721
dplyr :: bind_rows()
719
722
720
723
ggplot(data ) +
0 commit comments