Use stan_filter() to choose indicies of samples across parameters where conditions are true.
stan_filter(object, ..., permuted = TRUE)
object | stanfit object |
---|---|
... | Logical predicates defined in terms of the parameters in object |
permuted | A logical scalar indicating whether the draws after the warmup period in each chain should be permuted and merged, Default: TRUE |
stanfit object
If no elements are returned for any chain then NULL
is returned with a warning.
If there is a chain that results in no samples then the chain is dropped with a warning.
If permuted is FALSE then uneven chains may be returned depending on the result of the filter.
To comply with extract with permuted=TRUE
chains in which chaines are
assumed to be of equal size.
Chain size returned is the length of the shortest filtered chain.
Other filtering:
stan_slice()
,
stan_thin_n()
#> Inference for Stan model: rats. #> 4 chains, each with iter=2000; warmup=1000; thin=1; #> post-warmup draws per chain=1000, total post-warmup draws=4000. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat #> mu_alpha 242.47 0.05 2.76 236.95 240.61 242.50 244.38 247.7 3585 1 #> mu_beta 6.19 0.00 0.11 5.98 6.12 6.19 6.25 6.4 4462 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).#> Inference for Stan model: rats. #> 4 chains, each with iter=1028; warmup=1000; thin=1; #> post-warmup draws per chain=28, total post-warmup draws=112. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat #> mu_alpha 242.32 0.34 2.81 236.93 240.39 242.33 244.21 247.74 68 1.05 #> mu_beta 5.95 0.00 0.05 5.83 5.94 5.96 5.98 6.00 120 0.99 #> #> 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).#> Inference for Stan model: rats. #> 4 chains, each with iter=1039; warmup=1000; thin=1; #> post-warmup draws per chain=33, total post-warmup draws=156. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat #> mu_alpha 242.41 0.3 2.78 237.12 240.41 242.37 244.44 247.72 84 1.02 #> mu_beta 5.95 0.0 0.05 5.83 5.94 5.96 5.98 6.00 120 1.00 #> #> 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(`alpha[1]`,`alpha[2]`,mu_alpha,mu_beta)%>% stan_filter(mu_beta < 6 & `alpha[1]` > 240)#> Inference for Stan model: rats. #> 4 chains, each with iter=1014; warmup=1000; thin=1; #> post-warmup draws per chain=14, total post-warmup draws=56. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat #> alpha[1] 242.24 0.32 1.74 240.11 240.84 241.70 243.38 246.04 30 1.07 #> alpha[2] 248.30 0.59 3.17 242.88 245.81 248.57 250.85 253.38 29 1.05 #> mu_alpha 242.23 0.38 2.31 237.53 240.41 242.39 243.47 246.67 37 1.10 #> mu_beta 5.95 0.01 0.05 5.82 5.94 5.96 5.99 6.00 98 0.99 #> #> 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).# }