extract_sampler_params: Extract sampler parameters from a fit.

Description Usage Arguments Details Value See Also Examples

View source: R/helper.R

Description

Extract information about NUTS trajectories, such as acceptance ratio and treedepth, from a fitted object.

Usage

1
extract_sampler_params(fit, inc_warmup = FALSE)

Arguments

fit

A list returned by sample_admb or sample_tmb.

inc_warmup

Whether to extract the warmup samples or not (default). Warmup samples should never be used for inference, but may be useful for diagnostics.

Details

Each trajectory (iteration) in NUTS has associated information about the trajectory: stepsize, acceptance ratio, treedepth, and number of leapfrog steps. This function extracts these into a data.frame, which may be useful for diagnosing issues in certain cases. In general, the user should not need to examine them, or preferably should via launch_shinytmb or launch_shinyadmb.

Value

An invisible data.frame containing samples (rows) of each parameter (columns). If multiple chains exist they will be rbinded together.

See Also

launch_shinytmb and launch_shinyadmb.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
fit <- readRDS(system.file('examples', 'fit_tmb.RDS', package='adnuts'))
## Examine how step size and treedepth changes as the mass matrix updates
## during warmup
sp <- extract_sampler_params(fit, inc_warmup=TRUE)
plot(0,0, type='n', xlim=c(0,510), ylim=c(0,3), xlab='Iteration',
     ylab='Step size (eps)')
for(i in 1:3) lines(1:1000, sp[sp$chain==i,4], col=i)
legend('topright', cex=.7, legend=paste("chain1", 1:3), lty=1, col=1:3)
plot(0,0, type='n', xlim=c(0,1000), ylim=c(0,10), xlab='Iteration',
     ylab='Treedepth')
for(i in 1:3) lines(1:1000, sp[sp$chain==i,5], col=i)
legend('topright', cex=.7, legend=paste("chain1", 1:3), lty=1, col=1:3)

colemonnahan/adnuts documentation built on Dec. 4, 2018, 1:03 p.m.