model {greta} | R Documentation |
greta model objects
Description
Create a greta_model
object representing a statistical
model (using model
), and plot a graphical representation of the
model. Statistical inference can be performed on greta_model
objects
with mcmc()
Usage
model(..., precision = c("double", "single"), compile = TRUE)
## S3 method for class 'greta_model'
print(x, ...)
## S3 method for class 'greta_model'
plot(x, y, colour = "#996bc7", ...)
Arguments
... |
for |
precision |
the floating point precision to use when evaluating this
model. Switching from |
compile |
whether to apply XLA JIT compilation to the TensorFlow graph representing the model. This may slow down model definition, and speed up model evaluation. |
x |
a |
y |
unused default argument |
colour |
base colour used for plotting. Defaults to |
Details
model()
takes greta arrays as arguments, and defines a
statistical model by finding all of the other greta arrays on which they
depend, or which depend on them. Further arguments to model
can be
used to configure the TensorFlow graph representing the model, to tweak
performance.
The plot method produces a visual representation of the defined
model. It uses the DiagrammeR
package, which must be installed
first. Here's a key to the plots:
Value
model
- a greta_model
object.
plot
- a DiagrammeR::grViz()
object, with the
DiagrammeR::dgr_graph()
object used to
create it as an attribute "dgr_graph"
.
Examples
## Not run:
# define a simple model
mu <- variable()
sigma <- normal(0, 3, truncation = c(0, Inf))
x <- rnorm(10)
distribution(x) <- normal(mu, sigma)
m <- model(mu, sigma)
plot(m)
## End(Not run)