Skip to contents

Create a model using the monty DSL; this function will likely change name in future, as will its interface.

Usage

monty_dsl(x, type = NULL, gradient = NULL)

Arguments

x

The model as an expression. This may be given as an expression, as a string, or as a path to a filename. Typically, we'll do a reasonable job of working out what you've provided but use the type argument to disambiguate or force a particular interpretation. The argument uses rlang's quosures to allow you to work with expressions directly; see examples for details.

type

Force interpretation of the type of expression given as x. If given, valid options are expression, text or file.

gradient

Control gradient derivation. If NULL (the default) we try and generate a gradient function for your model and warn if this is not possible. If FALSE, then we do not attempt to construct a gradient function, which prevents a warning being generated if this is not possible. If TRUE, then we will error if it is not possible to create a gradient function.

Value

A monty_model object derived from the expressions you provide.

Examples


# Expressions that correspond to models can be passed in with no
# quoting
monty_dsl(a ~ Normal(0, 1))
#> 
#> ── <monty_model> ───────────────────────────────────────────────────────────────
#>  Model has 1 parameter: 'a'
#>  This model:
#>  can compute gradients
#>  can be directly sampled from
#>  See `?monty_model()` for more information
monty_dsl({
  a ~ Normal(0, 1)
  b ~ Exponential(1)
})
#> 
#> ── <monty_model> ───────────────────────────────────────────────────────────────
#>  Model has 2 parameters: 'a' and 'b'
#>  This model:
#>  can compute gradients
#>  can be directly sampled from
#>  See `?monty_model()` for more information

# You can also pass strings
monty_dsl("a ~ Normal(0, 1)")
#> 
#> ── <monty_model> ───────────────────────────────────────────────────────────────
#>  Model has 1 parameter: 'a'
#>  This model:
#>  can compute gradients
#>  can be directly sampled from
#>  See `?monty_model()` for more information