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

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.51 0.22 2.64 237.84 240.75 242.64 244.25 246.82 149 1 #> #> Samples were drawn using at Sat Dec 21 02:04:29 2019. #> 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.53 0.07 2.74 237.2 240.79 242.56 244.35 247.82 1569 1 #> #> Samples were drawn using at Sat Dec 21 02:04:29 2019. #> 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.51 0.22 2.64 237.84 240.75 242.64 244.25 246.82 149 1 #> #> Samples were drawn using at Sat Dec 21 02:04:29 2019. #> 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).