Learn R Programming

pmwg (version 0.2.7)

as_mcmc: Return a CODA mcmc object with the required samples

Description

Given a sampler object and a specification of the samples required, return either an individual coda mcmc object, or a list of mcmc objects.

Usage

as_mcmc(sampler, selection = "theta_mu", filter = stages)

Value

An mcmc object or list containing the selected samples.

Arguments

sampler

The pmwgs object containing samples to extract.

selection

The selection of sample types to return.

filter

A filter that defines which stage to draw samples from.

Selecting sample types

The values that can be chosen for the selection argument can be one of the following list:

"theta_mu"

the model parameter estimate samples

"theta_sig"

the covariance matrix estimates, returns a list of mcmc objects, one for each model parameter.

"alpha"

the random effect estimates, returns a list of mcmc objects, one for each subject.

The default value for selection is "theta_mu"

Filtering samples

The filter argument can take one of two forms:

  • An integer vector, usually a sequence of integers, that must fall within the range 1:end.

  • A character vector, where each element corresponds to a stage of the sampling process, i.e. one or more of "init", "burn", "adapt" or "sample".

The default value for filter is all stages.

Examples

Run this code
par_estimates <- as_mcmc(sampled_forstmann)
par_estimates_sample_stage <- as_mcmc(sampled_forstmann, filter = "sample")
rand_eff <- as_mcmc(
  sampled_forstmann,
  selection = "alpha",
  filter = "sample"
)

Run the code above in your browser using DataLab