subset.dc: Select a subset of chains, samples and parameters from a...

View source: R/MCMCsim.R

subset.dcR Documentation

Select a subset of chains, samples and parameters from a draws component (dc) object

Description

Select a subset of chains, samples and parameters from a draws component (dc) object

Usage

## S3 method for class 'dc'
subset(
  x,
  chains = seq_len(nchains(x)),
  draws = seq_len(ndraws(x)),
  vars = seq_len(nvars(x)),
  ...
)

Arguments

x

a draws component (dc) object.

chains

an integer vector indicating which chains to select.

draws

an integer vector indicating which samples to select.

vars

an integer vector indicating which parameters to select.

...

not used.

Value

The selected part of the draws component as an object of class dc.

Examples

n <- 300
dat <- data.frame(x=runif(n), f=as.factor(sample(1:7, n, replace=TRUE)))
gd <- generate_data(~ reg(~ x + f, prior=pr_normal(precision=1), name="beta"), data=dat)
dat$y <- gd$y
sampler <- create_sampler(y ~ reg(~ x + f, name="beta"), data=dat)
sim <- MCMCsim(sampler)
(summary(sim$beta))
(summary(subset(sim$beta, chains=1)))
(summary(subset(sim$beta, chains=1, draws=sample(1:ndraws(sim), 100))))
(summary(subset(sim$beta, vars=1:2)))


mcmcsae documentation built on Oct. 11, 2023, 1:06 a.m.