Partial match functions used in stan_select

stan_contains(match, ignore.case = TRUE, pars = peek_pars())

stan_starts_with(match, ignore.case = TRUE, pars = peek_pars())

stan_ends_with(match, ignore.case = TRUE, pars = peek_pars())

Arguments

match

character, pattern to search for

ignore.case

logical to ignore the case, Default: TRUE

pars

list of pars to search in, Default: peek_pars()

Value

character

See also

Other subsetting: stan_select()

Examples

# \donttest{ rats <- rats_example() rats%>% stan_names()
#> [1] "alpha" "beta" "mu_alpha" "mu_beta" #> [5] "sigmasq_y" "sigmasq_alpha" "sigmasq_beta" "sigma_y" #> [9] "sigma_alpha" "sigma_beta" "alpha0" "lp__"
rats%>% stan_select(stan_contains('sq'))
#> 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 #> sigmasq_y 37.16 0.12 5.69 27.74 33.14 36.56 40.58 50.12 2366 #> sigmasq_alpha 218.39 1.06 63.89 126.08 173.31 208.62 251.30 372.24 3615 #> sigmasq_beta 0.27 0.00 0.10 0.13 0.21 0.26 0.32 0.52 3028 #> Rhat #> sigmasq_y 1 #> sigmasq_alpha 1 #> sigmasq_beta 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_contains('sq'))
#> 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 #> mu_alpha 242.47 0.05 2.76 236.95 240.61 242.50 244.38 247.70 3585 #> sigmasq_y 37.16 0.12 5.69 27.74 33.14 36.56 40.58 50.12 2366 #> sigmasq_alpha 218.39 1.06 63.89 126.08 173.31 208.62 251.30 372.24 3615 #> sigmasq_beta 0.27 0.00 0.10 0.13 0.21 0.26 0.32 0.52 3028 #> Rhat #> mu_alpha 1 #> sigmasq_y 1 #> sigmasq_alpha 1 #> sigmasq_beta 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(stan_starts_with('mu'))
#> 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).
rats%>% stan_select(stan_starts_with('mu'),stan_contains('sq'))
#> 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 #> mu_alpha 242.47 0.05 2.76 236.95 240.61 242.50 244.38 247.70 3585 #> mu_beta 6.19 0.00 0.11 5.98 6.12 6.19 6.25 6.40 4462 #> sigmasq_y 37.16 0.12 5.69 27.74 33.14 36.56 40.58 50.12 2366 #> sigmasq_alpha 218.39 1.06 63.89 126.08 173.31 208.62 251.30 372.24 3615 #> sigmasq_beta 0.27 0.00 0.10 0.13 0.21 0.26 0.32 0.52 3028 #> Rhat #> mu_alpha 1 #> mu_beta 1 #> sigmasq_y 1 #> sigmasq_alpha 1 #> sigmasq_beta 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(stan_ends_with('0'))
#> 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 #> alpha0 106.39 0.06 3.6 99.23 104 106.44 108.76 113.55 4122 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).
# free form regex in contains rats%>% stan_select(stan_contains('sq|mu'))
#> 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 #> mu_alpha 242.47 0.05 2.76 236.95 240.61 242.50 244.38 247.70 3585 #> mu_beta 6.19 0.00 0.11 5.98 6.12 6.19 6.25 6.40 4462 #> sigmasq_y 37.16 0.12 5.69 27.74 33.14 36.56 40.58 50.12 2366 #> sigmasq_alpha 218.39 1.06 63.89 126.08 173.31 208.62 251.30 372.24 3615 #> sigmasq_beta 0.27 0.00 0.10 0.13 0.21 0.26 0.32 0.52 3028 #> Rhat #> mu_alpha 1 #> mu_beta 1 #> sigmasq_y 1 #> sigmasq_alpha 1 #> sigmasq_beta 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).
# }