Skip to content

Multiple matches with family argument in ggs() #73

Description

@mdodrill-usgs

Hi,

When using the family argument to pull only a set of named parameters from a fitted model object, the function ggs() returns multiple matches when the parameter names are similar (see example below). This isn't the behavior I expected when looking at the documentation for ggs() (i.e., A family of parameters is considered to be any group of parameters with the same name but different numerical value between square brackets (as beta[1], beta[2], etc).)

library(rstan)
library(ggmcmc)

# toy model
ex_model_code <- '
  parameters {
    real alpha[2,3];
    real alpha_2[2]; 
  } 
  model {
    for (i in 1:2) for (j in 1:3) 
      alpha[i, j] ~ normal(0, 1); 
    for (i in 1:2) 
      alpha_2 ~ normal(0, 2); 
  } '
fit <- stan(model_code = ex_model_code, chains = 4) 

f1 <- ggs(fit, family = "alpha")

# both alpha & alpha_2 are returned
unique(f1$Parameter)

Maybe this is the desired behavior, but a nice feature would be to only return the parameters that match the string before the square brackets (provided as the family argument). not multiple parameters (multiple matches, "alpha" and "alpha_2" in the example).

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions