greta (version 0.4.5)

distribution: define a distribution over data

Description

distribution defines probability distributions over observed data, e.g. to set a model likelihood.

Usage

distribution(greta_array) <- value

distribution(greta_array)

Arguments

greta_array

a data greta array. For the assignment method it must not already have a probability distribution assigned

value

a greta array with a distribution (see distributions())

Details

The extract method returns the greta array if it has a distribution, or NULL if it doesn't. It has no real use-case, but is included for completeness

Examples

Run this code
if (FALSE) {

# define a model likelihood

# observed data and mean parameter to be estimated
# (explicitly coerce data to a greta array so we can refer to it later)
y <- as_data(rnorm(5, 0, 3))

mu <- uniform(-3, 3)

# define the distribution over y (the model likelihood)
distribution(y) <- normal(mu, 1)

# get the distribution over y
distribution(y)
}

Run the code above in your browser using DataCamp Workspace