Learn R Programming

astsa (version 2.1)

ESS: Effective Sample Size (ESS)

Description

Estimates the ESS of a given vector of samples.

Usage

ESS(trace, tol = 1e-08, BIC = TRUE)

Value

Returns the estimated ESS of the input.

Arguments

trace

vector of sampled values from an MCMC run (univariate only)

tol

ESS is returned as zero if the estimated spectrum at frequency zero is less than this value

BIC

if TRUE (default), spec0 is obtained using BIC; otherwise, AIC is used. See the details.

Author

D.S. Stoffer

Details

Uses spec.ic to estimate the spectrum of the input at frequency zero (spec0). Then, ESS is estimated as ESS = length(trace)*var(trace)/spec0.

References

You can find demonstrations of astsa capabilities at FUN WITH ASTSA.

The most recent version of the package can be found at https://github.com/nickpoison/astsa/.

In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.

The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/.

Examples

Run this code
# Fit an AR(2) to the Recruitment series
u = ar.mcmc(rec, porder=2, n.iter=1000, plot=FALSE) 
# then calculate the ESSs 
apply(u, 2, ESS)

Run the code above in your browser using DataLab