florianhartig / BayesianTools

General-Purpose MCMC and SMC Samplers and Tools for Bayesian Statistics
https://cran.r-project.org/web/packages/BayesianTools/index.html
115 stars 29 forks source link

runMCMC can't handle generic target functions #178

Closed lukasheiland closed 5 years ago

lukasheiland commented 5 years ago

When attempting to start runMCMC() with a generic target function (e.g., log posterior),

library(BayesianTools)
f <-  function(x) dnorm(x, log = T)
runMCMC(f)

throws an error, because runMCMC() will first try to index the provided function with $parallel. Circumventing this error, the function will be passed on to checkBayesianSetup(), which will turn the function over to createBayesianSetup(), which will throw an error because of lacking prior specification:

Fehler in createBayesianSetup(f, parallel = parallel) : 
  Either boundaries or prior density and prior sampler must be provided.

Furthermore, it is unclear, how the number of parameters for the log posterior should be provided in the call to runMCMC().

florianhartig commented 5 years ago

thanks! This used to be an option, but since then we have made a number of changes that require min/max values for the prior, so in fact the help is not correct any more - runMCMC always requires a BayesianSetup.