stan4bart
stan4bart copied to clipboard
Specifying Stan priors
Vince,
Would you mind providing an example of how one would specify a Stan-related prior, say for prior.aux or prior.covariance, in the stan_args list? I have tried specifying them as rstanarm would allow it and am having trouble getting entries like "exponential(1)" recognized. It's probably something simple but I can't seem to find the right combination.
Thanks very much.
Great question, I'm not sure I ever really tested that much since I didn't write that part of the interface. Here's an example setting the prior scale for aux.
library(stan4bart)
source(system.file("common", "friedmanData.R", package = "stan4bart"), local = TRUE)
testData <- generateFriedmanData(100, TRUE, TRUE, FALSE)
rm(generateFriedmanData)
df <- with(testData, data.frame(x, g.1, g.2, y, z))
fit <- stan4bart(
y ~ bart(. - g.1 - g.2 - X4 - z) + X4 + z + (1 + X4 | g.1) + (1 | g.2), df,
cores = 1, verbose = 1L, chains = 3, warmup = 7, iter = 13,
seed = 0,
bart_args = list(n.trees = 11),
stan_args = list(
prior_aux = list(
dist = "exponential",
scale = 1.5
)
),
treatment = z
)
In general, the structure is something like:
stan_args = list(
prior = list(
dist = "normal" / "t" / etc,
location = ...,
scale = ...,
df = ...
),
prior_intercept = list(...),
prior_aux = list(...),
QR = TRUE / FALSE
)
The available distributions are found are here and how they are parsed is around here.