Get a character vector of the names of the variables in a variety of fitted Bayesian model types. All models supported by tidy_draws() are supported.

get_variables(model)

# Default S3 method
get_variables(model)

# S3 method for class 'mcmc'
get_variables(model)

# S3 method for class 'mcmc.list'
get_variables(model)

Arguments

model

A supported Bayesian model fit. Tidybayes supports a variety of model objects; for a full list of supported models, see tidybayes-models.

Value

A character vector of variable names in the fitted model.

Details

This function is often useful for inspecting a model interactively in order to construct calls to spread_draws() or gather_draws() in order to extract draws from models in a tidy format.

Author

Matthew Kay

Examples


data(line, package = "coda")
get_variables(line)
#> [1] "alpha" "beta"  "sigma"

data(RankCorr, package = "ggdist")
get_variables(RankCorr)
#>  [1] "b[1,1]"    "b[2,1]"    "b[3,1]"    "b[1,2]"    "b[2,2]"    "b[3,2]"   
#>  [7] "b[1,3]"    "b[2,3]"    "b[3,3]"    "b[1,4]"    "b[2,4]"    "b[3,4]"   
#> [13] "tau[1]"    "tau[2]"    "tau[3]"    "u_tau[1]"  "u_tau[2]"  "u_tau[3]" 
#> [19] "typical_r"