add_binom_gest: Add binomial G-Estimate

Description Usage Arguments Value Examples

View source: R/add_binom_gest.R

Description

adds an estimated shinkage value obtained by G-Modeling

Usage

1
2
3
4
5
6
7
8
9
add_binom_gest(
  tbl,
  x,
  n,
  cred_level = 0.8,
  theta_from = 0.01,
  theta_to = 0.99,
  theta_by = 0.01
)

Arguments

tbl

a table which *requires* two columns. A column with the number of successes (x) and a column with totals (n).

x

column with number of successes

n

column with totals

cred_level

level of credible interval to compute. For example and interval of .80 will return a 20th percentile lower interval and a 80th percentile upper interval

theta_from

start of parameter space

theta_to

end of parameter space

theta_by

increment of parameter space

Value

The original table with the following columns

.gest_dist

Full posterior distribution. Grain may be increased with the theta_* parameters

.raw

Estimate (success / total)

.gest

Posterior EB g-estimate

.lo

Lower bound of credible interval for EB estimate

.hi

Upper bound of credible interval for EB estimate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(tibble)
set.seed(2017)

# simulate 200 random examples from a beta-binomial
obs <- 200
dat <- tibble(prob = rbeta(obs, 10, 50),
                  n = round(rlnorm(obs, 4, 2)) + 1,
                  x = rbinom(obs, n, prob))

result <- add_binom_gest(dat, x, n)
result

alexhallam/gest documentation built on March 24, 2020, 1:22 a.m.