Returns all the node names stored in a mcmc.list
object that match a provided string.
match_params(post, params, type = "base_index", auto_escape = TRUE)
post | A |
---|---|
params | A vector of regular expressions specifying the nodes to match.
Accepts multi-element vectors to match more than one node at a time.
See examples and |
type | Format of returned matches; only two options are accepted:
|
auto_escape | Automatically escape |
A character vector with all node names in post
that match params
, formatted as requested by type
..
If no matches are found, an error will be returned with
the base node names found in post
to help the next try.
This function is called as one of the first steps in many of the more downstream functions in this package. It is thus fairly important to get used to how the regular expressions work. This function can be used directly to hone in on the correct regular expression. See the examples below.
# load example mcmc.list data(cjs) # these produce same output b/c of regex pattern matching match_params(cjs, params = c("b0", "b1"))#> [1] "b0[1]" "b0[2]" "b0[3]" "b0[4]" "b0[5]" "b1[1]" "b1[2]" "b1[3]" "b1[4]" #> [10] "b1[5]"#> [1] "b0[1]" "b0[2]" "b0[3]" "b0[4]" "b0[5]" "b1[1]" "b1[2]" "b1[3]" "b1[4]" #> [10] "b1[5]"# return only base names, not indices as well match_params(cjs, params = "b", type = "base_only")#> [1] "b0" "b1"# force a match to start with B match_params(cjs, "^B")#> [1] "B0" "B1"# force a match to end with 0 match_params(cjs, "0$")#> [1] "B0" "sig_B0"# use a wild card to get b0[3] and b1[3] match_params(cjs, "b.[3]")#> [1] "b0[3]" "b1[3]"# repeat a wild card match_params(cjs, "s.+0")#> [1] "sig_B0"# turn off auto escape to use [] in regex syntax rather than matching them as text match_params(cjs, params = "[:digit:]$", auto_escape = FALSE)#> [1] "B0" "sig_B0" "B1" "sig_B1"# pass a dot to match all (same as get_params) match_params(cjs, ".")#> [1] "B0" "sig_B0" "B1" "sig_B1" "b0[1]" "b0[2]" #> [7] "b0[3]" "b0[4]" "b0[5]" "b1[1]" "b1[2]" "b1[3]" #> [13] "b1[4]" "b1[5]" "SIG[1,1]" "SIG[2,1]" "SIG[1,2]" "SIG[2,2]" #> [19] "p[2]" "p[3]" "p[4]"