Regex in rstanarm::posterior_interval
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 401
- Forks
- 136
- PR merge metrics
- No merged PRs in 30d
Description
Summary:
Functions using regex_pars argument seems not compatible with perl or certain 'classic' regular expression.
Description:
Some functions such as posterior_interval use an argument called pars_regex (or whatever name related to regular expressions). It seems that most of the time, the function grep_for_pars (line 412 in misc.R) is used to deal with regular expressions. However, this function is not compatible with perl. Therefore, some expressions are considered invalid by rstanarm while they are valid for other packages (see reproducible steps).
For instance, to get rid of the random effects on the intercept in the posterior interval, it would be useful to select the names that does not contain a certain regex (here it would be b[(Intercept)]).
Reproducible Steps:
# Regex accepted by stringi package
str_example = c("(Intercept)", "b_(Intercept)", "b[(inter cept) herd:1", "b[(Intercept) herd:1]", "size", "b[(Intercept) herd:11]")
stringi::stri_detect(str = str_example, regex = "^(?!b\\[\\(Intercept\\))")
# Let us assume I want to get rid of all the parameters starting by "b(Intercept)"
myRun = example(example_model)$value
posterior_interval(myRun, regex_pars = "^(?!b\\[\\(Intercept\\))")
RStanARM Version:
‘2.18.2’
R Version:
3.6.0
Operating System:
Ubuntu 18.04
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in misc.R around line 412, where grep_for_pars is used by posterior_interval to process regex_pars. Reproduce the issue with the provided stringi and posterior_interval examples, then verify that the shown expression is accepted and selects the intended parameters without breaking existing regular-expression behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100