DiffBetweenEstimates: Difference between estimated parameters

Description Usage Arguments Value Examples

View source: R/DiffBetweenEstimates.R

Description

Vectorized difference between chains of two objects of class mcmc.list.

Usage

1

Arguments

estimates

list with two objects of class mcmc.list. These objects must have the same number of chains and the chains must have the same length.

Value

A list of class mcmc.list.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Priors.
priors <- c(true_prev_a = 1, true_prev_b = 1,
            se_a = 6.28, se_b = 13.32, sp_a = 212.12, sp_b = 3.13)

# First estimate.
dataset1 <- list(pop_size = 100, positives = 5)
prev_est1 <- OneTestOnePopBM(dataset = as.list(dataset1), n_iter = 3e3,
                                  priors = priors, pars = "true_prev",
                                  burn_in = 5e2)

# Second estimate.
dataset2 <- list(pop_size = 91, positives = 1)
prev_est2 <- OneTestOnePopBM(dataset = as.list(dataset2), n_iter = 3e3,
                                   priors = priors, pars = "true_prev",
                                   burn_in = 5e2)

# Estimated difference.
diffs <- DiffBetweenEstimates(list(prev_est1, prev_est2))
summary(diffs)

# Diagnostic plots.
library(coda); library(ggmcmc)
gelman.diag(diffs)
gelman.plot(diffs)
gg_res <- ggs(diffs)
ggs_traceplot(gg_res)
ggs_density(gg_res)
ggs_histogram(gg_res, bins = 100)
ggs_compare_partial(gg_res)
ggs_running(gg_res)
ggs_autocorrelation(gg_res)

oswaldosantos/ptb documentation built on May 24, 2019, 5:13 p.m.