Create a model using the monty DSL; this function will likely change name in future, as will its interface.
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 areexpression
,text
orfile
.- 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. IfFALSE
, then we do not attempt to construct a gradient function, which prevents a warning being generated if this is not possible. IfTRUE
, 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