# an unconstrained and prior-free parameter (e.g. for a frequentist model)
alpha = free()
# positive prior-free parameter (could also do: sigma = exp(free()) )
sigma = free(lower = 0)
# a prior-free parameter constrained to be less that -1
neg_alpha = free(upper = -1)
# a prior-free parameter constrained to be between 0 and 1
psi = free(lower = 0, upper = 1)
# a uniform parameter constrained to be between 0 and 1
phi = uniform(min = 0, max = 1)
# create a hierarchical uniform, constrained between alpha and alpha + sigma,
eta = alpha + uniform(0, 1) * sigma
# an unconstrained parameter with standard normal prior
mu = normal(0, 1)
# a hierarchical distribution
theta = normal(mu, lognormal(0, 1))
# a vector of 3 variables drawn from the same hierarchical distribution
thetas = normal(mu, sigma, dim = 3)
# a matrix of 12 variables drawn from the same hierarchical distribution
thetas = normal(mu, sigma, dim = c(3, 4))
# a multivariate normal variable, with correlation between two elements
Sig <- diag(4)
Sig[3, 4] <- Sig[4, 3] <- 0.6
theta = multivariate_normal(rep(mu, 4), Sig)
# 10 independent replicates of that
theta = multivariate_normal(rep(mu, 4), Sig, dim = 10)
# a Wishart variable with the same covariance parameter
theta = wishart(df = 5, Sigma = Sig)
Run the code above in your browser using DataLab