Learn R Programming

emmeans (version 1.3.2)

as.mcmc.emmGrid: Support for MCMC-based estimation

Description

When a model is fitted using Markov chain Monte Carlo (MCMC) methods, its reference grid contains a post.beta slot. These functions transform those posterior samples to posterior samples of EMMs or related contrasts. They can then be summarized or plotted using, e.g., functions in the coda package.

Usage

# S3 method for emmGrid
as.mcmc(x, names = TRUE, sep.chains = TRUE, ...)

# S3 method for emmGrid as.mcmc.list(x, names = TRUE, ...)

Arguments

x

An object of class emmGrid

names

Logical scalar or vector specifying whether variable names are appended to levels in the column labels for the as.mcmc or as.mcmc.list result -- e.g., column names of treat A and treat B versus just A and B. When there is more than one variable involved, the elements of names are used cyclically.

sep.chains

Logical value. If TRUE, and there is more than one MCMC chain available, an mcmc.list object is returned by as.mcmc, with separate EMMs posteriors in each chain.

...

arguments passed to mcmc

Value

An object of class mcmc or mcmc.list.

Details

When the object's post.beta slot is non-trivial, as.mcmc will return an mcmc or mcmc.list object that can be summarized or plotted using methods in the coda package. In these functions, post.beta is transformed by post-multiplying it by t(linfct), creating a sample from the posterior distribution of LS means. In as.mcmc, if sep.chains is TRUE and there is in fact more than one chain, an mcmc.list is returned with each chain's results. The as.mcmc.list method is guaranteed to return an mcmc.list, even if it comprises just one chain.