summary.ggum: Summarize Posterior Draws for GGUM Parameters

Description Usage Arguments Details Value References See Also Examples

View source: R/summary.R

Description

Summarize the results of ggumMCMC or ggumMC3.

Usage

1
2
3
4
5
## S3 method for class 'ggum'
summary(object, ...)

## S3 method for class 'list'
summary(object, ..., combine = TRUE)

Arguments

object

A numeric matrix of posterior draws as returned by ggumMCMC or ggumMC3, or a list of such matrices.

...

Arguments to be passed to or from other methods

combine

A logical vector of length one; if TRUE and object is a list of ggum result objects, the matrices are combined and a summary of the combined sample is given; if FALSE and object is a list of ggum result objects, each matrix will be summarized individually; and if object is not a list, it has no effect. The default is TRUE.

Details

This function provides the posterior mean, median, standard deviation, and 0.025 and 0.975 quantiles for GGUM parameters from posterior samples drawn using ggumMCMC or ggumMC3. Please note that the quantiles are calculated using the type 8 algorithm from Hyndman and Fan (1996), as suggested by Hyndman and Fan (1996), rather than the type 7 algorithm that would be the default from R's quantile()). Before calling this function, care should be taken to ensure that post-processing has been done if necessary to identify the correct reflective posterior mode, as discussed in the vignette and Duck-Mayr and Montgomery (2019).

Please see the vignette (via vignette("bggum")) for a full in-depth practical guide to Bayesian estimation of GGUM parameters.

Value

A list with three elements: estimates (a list of length four; a numeric vector giving the means of the theta draws, a numeric vector giving the means of the alpha draws, a numeric vector giving the means of the delta draws, and a list where the means of the tau draws are collated into a tau estimate vector for each item), sds (a list of length four giving the posterior standard deviations for the theta, alpha, delta, and tau draws), and statistics (a matrix with five columns and one row for each parameter giving the 0.025 quantile, the 0.5 quantile, the mean, the 0.975 quantile, and the standard deviation of the posterior draws for each parameter; please note the quantiles are calculated using the type 8 algorithm from Hyndman and Fan 1996, as suggested by Hyndman and Fan 1996, rather than the type 7 algorithm that would be the default from R's quantile()).

If object is a list and combine is FALSE, a list of such lists will be returned.

References

Duck-Mayr, JBrandon, and Jacob Montgomery. 2019. “Ends Against the Middle: Scaling Votes When Ideological Opposites Behave the Same for Antithetical Reasons.” http://jbduckmayr.com/papers/ggum.pdf.

Hyndman, R. J. and Fan, Y. 1996. “Sample Quantiles in Packages.” American Statistician 50, 361–365.

See Also

ggumMCMC, ggumMC3

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
## NOTE: This is a toy example just to demonstrate the function, which uses
## a small dataset and an unreasonably low number of sampling interations.
## For a longer practical guide on Bayesian estimation of GGUM parameters,
## please see the vignette ( via vignette("bggum") ).
## We'll simulate data to use for this example:
set.seed(123)
sim_data <- ggum_simulation(100, 10, 2)
## Now we can generate posterior draws
## (for the purposes of example, we use 100 iterations,
## though in practice you would use much more)
draws <- ggumMC3(data = sim_data$response_matrix, n_temps = 2,
                 sd_tune_iterations = 100, temp_tune_iterations = 100,
                 temp_n_draws = 50,
                 burn_iterations = 100, sample_iterations = 100)
## Then post-process the output
processed_draws <- post_process(sample = draws,
                                constraint = which.min(sim_data$theta),
                                expected_sign = "-")
## And now we can obtain a summary of the posterior
posterior_summary <- summary(processed_draws)
## It contains all the parameter estimates
str(posterior_summary$estimates)
## As well as the posterior standard deviations
str(posterior_summary$sds)
## And a matrix of the mean (estimates), median, standard deviations,
## and 0.025 and 0.975 quantiles
head(posterior_summary$statistics)

duckmayr/bggum documentation built on Jan. 20, 2020, 5:23 a.m.