# Create a general prior distribution by specifying an arbitrary density function and a
# corresponding sampling function
density = function(par){
d1 = dunif(par[1], -2,6, log =TRUE)
d2 = dnorm(par[2], mean= 2, sd = 3, log =TRUE)
return(d1 + d2)
}
# The sampling is optional but recommended because the MCMCs can generate automatic starting
# conditions if this is provided
sampler = function(n=1){
d1 = runif(n, -2,6)
d2 = rnorm(n, mean= 2, sd = 3)
return(cbind(d1,d2))
}
prior <- createPrior(density = density, sampler = sampler,
lower = NULL, upper = NULL, best = NULL)
# Use this prior in an MCMC
ll <- function(x) sum(dnorm(x, log = T)) # multivariate normal ll
bayesianSetup <- createBayesianSetup(likelihood = ll, prior = prior)
out <- runMCMC(bayesianSetup = bayesianSetup)
prior <- createPrior(density = density, sampler = sampler,
lower = c(-3,-3), upper = c(3,3), best = NULL)
Seems to me this is a bug, because a sampling function is provided, so there should be no need for boundaries.
If fixing this, can you have a look to fix this as early as possible? Probably the DEzs wants to access some length or names from the BayesianSetup that depend on the boundaries that are absent in this case. We should take care to fix the problem there, not in the DEzs