12
12
# ' @template args-hist
13
13
# ' @template args-hist-freq
14
14
# ' @template args-dens
15
+ # ' @template args-pit-ecdf
15
16
# ' @param size,alpha Passed to the appropriate geom to control the appearance of
16
17
# ' the `yrep` distributions.
17
18
# ' @param ... Currently unused.
48
49
# ' both, depending on the `y_draw` argument.
49
50
# ' }
50
51
# ' \item{`ppc_pit_ecdf()`}{
51
- # ' The `100 * prob`% central simultaneous confidence intervals for the ECDF
52
- # ' of the empirical PIT values of `y` computed with respect to the
53
- # ' corresponding `yrep` values. If 'y' and ' yrep'. Th PIT values can also be
54
- # ' provided directly as `pit`.
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`.
55
56
# ' See Säilynoja et al. for more details.}
56
57
# ' }
57
58
# '
71
72
# ' # ppc_ecdf_overlay with continuous data (set discrete=TRUE if discrete data)
72
73
# ' ppc_ecdf_overlay(y, yrep[sample(nrow(yrep), 25), ])
73
74
# ' }
75
+ # ' # ECDF and ECDF difference plot of the PIT values of ´y´ compared to ´yrep
76
+ # ' # with 99% simultaneous confidence bands.
77
+ # ' ppc_pit_ecdf(y, yrep, prob=0.99, plot_diff=FALSE)
78
+ # ' ppc_pit_ecdf(y, yrep, prob=0.99)
79
+ # '
74
80
# '
75
81
# ' # for ppc_hist,dens,freqpoly,boxplot definitely use a subset yrep rows so
76
82
# ' # only a few (instead of nrow(yrep)) histograms are plotted
99
105
# '
100
106
# ' ppc_ecdf_overlay_grouped(y, yrep[1:25, ], group = group)
101
107
# '
108
+ # ' # ECDF difference plots of the PIT values by group
109
+ # ' # with 99% simultaneous confidence bands.
110
+ # ' ppc_pit_ecdf_grouped(y, yrep, group=group, prob=0.99)
111
+ # '
102
112
# ' # don't need to only use small number of rows for ppc_violin_grouped
103
113
# ' # (as it pools yrep draws within groups)
104
114
# ' color_scheme_set("gray")
@@ -536,15 +546,18 @@ ppc_violin_grouped <- function(y, yrep, group, ..., probs = c(0.1, 0.5, 0.9),
536
546
}
537
547
538
548
# ' @export
549
+ # ' @param pit An optional vector of probability integral transformed values for
550
+ # ' which the ECDF is to be drawn. If NULL, PIT values are computed to ´y´ with
551
+ # ' respect to the corresponding values in ´yrep´.
539
552
# ' @rdname PPC-distributions
540
553
# '
541
554
ppc_pit_ecdf <- function (y ,
542
555
yrep ,
543
556
... ,
544
557
pit = NULL ,
545
558
K = NULL ,
546
- confidence_level = .99 ,
547
- difference = TRUE ,
559
+ prob = .99 ,
560
+ plot_diff = TRUE ,
548
561
adj_method = " interpolate" ) {
549
562
check_ignored_arguments(... )
550
563
@@ -566,23 +579,23 @@ ppc_pit_ecdf <- function(y,
566
579
N <- length(pit )
567
580
gamma <- adjust_gamma(N ,
568
581
K = K ,
569
- conf_level = confidence_level ,
582
+ conf_level = prob ,
570
583
adj_method = adj_method
571
584
)
572
585
lims <- ecdf_intervals(N , K = K , gamma = gamma )
573
586
ggplot() +
574
587
aes_(
575
588
x = 0 : K / K ,
576
- y = ecdf(pit )(0 : K / K ) - (difference == TRUE ) * 0 : K / K ,
589
+ y = ecdf(pit )(0 : K / K ) - (plot_diff == TRUE ) * 0 : K / K ,
577
590
color = " y"
578
591
) +
579
592
geom_step(show.legend = FALSE ) +
580
593
geom_step(aes(
581
- y = lims $ upper / N - (difference == TRUE ) * 0 : K / K ,
594
+ y = lims $ upper / N - (plot_diff == TRUE ) * 0 : K / K ,
582
595
color = " yrep"
583
596
), show.legend = FALSE ) +
584
597
geom_step(aes(
585
- y = lims $ lower / N - (difference == TRUE ) * 0 : K / K ,
598
+ y = lims $ lower / N - (plot_diff == TRUE ) * 0 : K / K ,
586
599
color = " yrep"
587
600
), show.legend = FALSE ) +
588
601
yaxis_title(FALSE ) +
@@ -602,9 +615,9 @@ ppc_pit_ecdf_grouped <-
602
615
... ,
603
616
K ,
604
617
pit ,
605
- confidence_level = .99 ,
606
- difference = TRUE ,
607
- adj_method ) {
618
+ prob = .99 ,
619
+ plot_diff = TRUE ,
620
+ adj_method = " interpolate " ) {
608
621
check_ignored_arguments(... )
609
622
610
623
if (missing(pit )) {
@@ -626,7 +639,7 @@ ppc_pit_ecdf_grouped <-
626
639
adjust_gamma(
627
640
N_g ,
628
641
K = min(N_g , K0 ),
629
- conf_level = confidence_level ,
642
+ conf_level = prob ,
630
643
adj_method = adj_method
631
644
)
632
645
})
@@ -654,17 +667,17 @@ ppc_pit_ecdf_grouped <-
654
667
ggplot(data ) +
655
668
aes_(
656
669
x = ~ x ,
657
- y = ~ ecdf_value - (difference == TRUE ) * x ,
670
+ y = ~ ecdf_value - (plot_diff == TRUE ) * x ,
658
671
group = ~ group ,
659
672
color = " y"
660
673
) +
661
674
geom_step(show.legend = FALSE ) +
662
675
geom_step(aes_(
663
- y = ~ lims_upper - (difference == TRUE ) * x ,
676
+ y = ~ lims_upper - (plot_diff == TRUE ) * x ,
664
677
color = " yrep"
665
678
), show.legend = FALSE ) +
666
679
geom_step(aes_(
667
- y = ~ lims_lower - (difference == TRUE ) * x ,
680
+ y = ~ lims_lower - (plot_diff == TRUE ) * x ,
668
681
color = " yrep"
669
682
), show.legend = FALSE ) +
670
683
xaxis_title(FALSE ) +
0 commit comments