This is a wrapper around stan_slice() to make it easy to thin samples from each parameter in a stanfit object.

stan_thin_n(object, size, inc_warmup = TRUE)

stan_thin_frac(object, size, inc_warmup = TRUE)

Arguments

object

stanfit object

size

numeric, for stan_thin_n size of thin, for stan_thin_frac fraction of samples to sample.

inc_warmup

logical, include warmup in output, Default: TRUE

Value

stanfit

See also

Other filtering: stan_filter(), stan_slice()

Examples

# \donttest{ rats <- rats_example(nCores = 1) rats%>% stan_select(mu_alpha)%>% stan_thin_n(30)
#> Inference for Stan model: rats. #> 4 chains, each with iter=1034; warmup=1000; thin=1; #> post-warmup draws per chain=34, total post-warmup draws=136. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat #> mu_alpha 242.46 0.22 2.84 237.15 240.47 242.58 243.98 247.55 160 1 #> #> Samples were drawn using at Mon Aug 31 11:07:31 2020. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1).
rats%>% stan_select(mu_alpha)%>% stan_thin_frac(0.5)
#> Inference for Stan model: rats. #> 4 chains, each with iter=1500; warmup=1000; thin=1; #> post-warmup draws per chain=500, total post-warmup draws=2000. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat #> mu_alpha 242.49 0.07 2.75 237.12 240.59 242.5 244.4 247.69 1635 1 #> #> Samples were drawn using at Mon Aug 31 11:07:31 2020. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1).
rats%>% stan_select(mu_alpha)%>% stan_thin_n(30,inc_warmup = FALSE)
#> Inference for Stan model: rats. #> 4 chains, each with iter=34; warmup=0; thin=1; #> post-warmup draws per chain=34, total post-warmup draws=136. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat #> mu_alpha 242.46 0.22 2.84 237.15 240.47 242.58 243.98 247.55 160 1 #> #> Samples were drawn using at Mon Aug 31 11:07:31 2020. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1).
# }