make_prior {makemyprior} | R Documentation |
Making a prior object
Description
Make a prior object with all necessary information about the prior and model. The object can either be sent to makemyprior_gui or used directly for inference with Stan (inference_stan) or INLA (inference_inla). eval_joint_prior can be used to evaluate the prior.
Usage
make_prior(
formula,
data,
family = "gaussian",
prior = list(),
intercept_prior = c(),
covariate_prior = list()
)
Arguments
formula |
A formula object, using the function mc. |
data |
The data used in the model, as a |
family |
A string indicating the likelihood family. |
prior |
Prior on residuals can be defined using |
intercept_prior |
Parameters for Gaussian prior on intercept, specified as a vector with mean and standard deviation. Default is (0, 1000). |
covariate_prior |
Parameters for Gaussian prior on coefficients of covariates, specified as named list, each element is a vector with mean and standard deviation. Default is (0, 1000). |
Details
See makemyprior_models for details on available priors and likelihoods.
Value
Prior object.
Examples
## Not run:
vignette("make_prior", package = "makemyprior")
## End(Not run)
p <- 10
m <- 10
n <- m*p
set.seed(1)
data <- list(a = rep(1:p, each = m),
b = rep(1:m, times = p),
x = runif(n))
data$y <- data$x + rnorm(p, 0, 0.5)[data$a] +
rnorm(m, 0, 0.3)[data$b] + rnorm(n, 0, 1)
formula <- y ~ x + mc(a) + mc(b)
prior <- make_prior(formula, data, family = "gaussian",
intercept_prior = c(0, 1000),
covariate_prior = list(x = c(0, 100)))
prior
plot(prior)