effective_sample: Effective Sample Size (ESS)

Description Usage Arguments Details Value References Examples

View source: R/effective_sample.R

Description

This function returns the effective sample size (ESS).

Usage

 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
effective_sample(model, ...)

## S3 method for class 'brmsfit'
effective_sample(
  model,
  effects = c("fixed", "random", "all"),
  component = c("conditional", "zi", "zero_inflated", "all"),
  parameters = NULL,
  ...
)

## S3 method for class 'stanreg'
effective_sample(
  model,
  effects = c("fixed", "random", "all"),
  component = c("location", "all", "conditional", "smooth_terms", "sigma",
    "distributional", "auxiliary"),
  parameters = NULL,
  ...
)

## S3 method for class 'blavaan'
effective_sample(model, parameters = NULL, ...)

## S3 method for class 'MCMCglmm'
effective_sample(
  model,
  effects = c("fixed", "random", "all"),
  parameters = NULL,
  ...
)

Arguments

model

A stanreg, stanfit, or brmsfit object.

...

Currently not used.

effects

Should results for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated.

component

Should results for all parameters, parameters for the conditional model or the zero-inflated part of the model be returned? May be abbreviated. Only applies to brms-models.

parameters

Regular expression pattern that describes the parameters that should be returned. Meta-parameters (like lp__ or prior_) are filtered by default, so only parameters that typically appear in the summary() are returned. Use parameters to select specific parameters for the output.

Details

Effective Sample (ESS) should be as large as possible, altough for most applications, an effective sample size greater than 1,000 is sufficient for stable estimates (Bürkner, 2017). The ESS corresponds to the number of independent samples with the same estimation power as the N autocorrelated samples. It is is a measure of “how much independent information there is in autocorrelated chains” (Kruschke 2015, p182-3).

Value

A data frame with two columns: Parameter name and effective sample size (ESS).

References

Examples

1
2
3
4
5
6
## Not run: 
library(rstanarm)
model <- stan_glm(mpg ~ wt + gear, data = mtcars, chains = 2, iter = 200, refresh = 0)
effective_sample(model)

## End(Not run)

DominiqueMakowski/bayestestR documentation built on July 27, 2021, 4:12 p.m.