Skip to contents

The comparison is made WITHIN each draw, the same theta on both sides. BDA3 flags values below 0.01 or above 0.99 as major failures.

Usage

Ppcrep(t_obs, t_rep)

Arguments

t_obs

T(y, theta^s) per draw, or a scalar.

t_rep

T(y_rep^s, theta^s), one per draw.

Value

List with p_value, p_two_sided, n_extreme, t_obs_mean, t_rep_mean, S, extreme.

Details

Formula: p_B ~= (1/S) sum_s 1{ T(y_rep^s, theta^s) >= T(y, theta^s) }

References

Gelman, Carlin, Stern, Dunson, Vehtari & Rubin (2013), Bayesian Data Analysis, 3rd edition, Section 6.3.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Ppcrep(V, V)
#> $p_value
#> [1] 1
#> 
#> $p_two_sided
#> [1] 0
#> 
#> $n_extreme
#> [1] 8
#> 
#> $t_obs_mean
#> [1] 4.5
#> 
#> $t_rep_mean
#> [1] 4.5
#> 
#> $S
#> [1] 8
#> 
#> $extreme
#> [1] 1
#> 
#> $method
#> [1] "Posterior predictive p-value, BDA3 Section 6.3"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"