-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createPrior - bug in the help file and confusing behavior of the truncation option #98
Comments
@MaximilianPi can you do point 1,3 |
added missing checks in DEzs and DREAMzs samplers (they were only missing in the parallel part) |
I checked it again and the fix should solve at least the problem with parallel error.
This statement was only missing in the parallel part of the DEzs and DREAMzs sampler (It's done this way in the DE, DEzs, DREAM and DREAMzs samplers). If both, the new proposed priors' and the start priors' likelihoods are -Inf this check is required otherwise there occurs an error in the ll comparison(only if both lls are -Inf):
This occurs only if the start values are bad and outside of the density. Maybe we should sample the priors at the start until they are inside? Another small issue/question. Why is the ll set to NA (if the prior is outside) in case of is.matrix(x):
|
suggested solution - remove upper / lower from create prior, and accept upper / lower in setup only if there is no prior provided |
Is there any reason to keep the "best" parameter when reworking createPrior? |
the motivation for this was to be able to provide a reference parameter set, even for flat priors ... yes, I would keep it, for various functions (e.g. sensitivity analysis), it's useful to have a "center point" is there a technical problem with that parameter? |
The problem is that without lower and upper we can't calculate "best" the way we are doing now ((upper + lower) / 2). But this should not be too bad if we just keep it optional. |
9b3fa68 b5ce8be Please let me know if this is the desired behaviour. |
As discussed with @florianhartig the createPrior function will be changed:
This leads to changes in createBayesianSetup:
And global changes in the package:
Another issue we should address while working on createBayesianSetup: |
Hi Tankred, I would deprecate the sampler option in the createBayesianSetup, so that the createBayesianSetup has only 3 options to create a prior
About the deprecation of lower / upper / best / name in the setup - I remember we discussed this and decided for this in the end. I'm not 100% sure if that's the best option, but let's go for it and see how this works. |
So latest state is:
|
There is a bug in createBayesianSetup when a function is passed for prior: if(inherits(prior,"bayesianOutput")){
# priorClass = createPriorDensity(prior, lower = lower, upper = upper, best = best)
priorClass = createPriorDensity(prior)
} else if(! "prior" %in% class(prior)){
if(is.null(prior) & !is.null(lower) & !is.null(upper)){
priorClass = createUniformPrior(lower = lower,upper = upper, best = best)
}else if(is.null(prior) || class(prior) == "function"){
# priorClass = createPriorDensity(prior, lower = lower, upper = upper, best = best)
priorClass = createPriorDensity(prior) # <===== HERE IS THE BUG
}else{
stop("wrong input in prior")
}
} else{
priorClass = prior
if("function" != class(prior)){
if( !is.null(lower)) warning("Prior and lower values provided to createBayesiansetup, the latter will be ignored")
if( !is.null(upper)) warning("Prior and upper values provided to createBayesiansetup, the latter will be ignored")
}
} We can not create a prior object from a density alone. This probably never worked, since createPriorDensity expects a bayesianOutput or a matrix (of sampled parameters). |
Functions for prior density and sampler in bayesian setups seem to work:
But yes if we give a function for density and no sampler he can not create a sampler.. We could do inverse transform sampling? |
The question is more if we should do that |
|
2 and 3 should be discussed regarding the boundaries and we discussed about 4, if we provide only a density but no sampler what should happen? |
I think we should keep the option to provide a density without a sampler. It's perfectly reasonable for the user not to provide a sampler, and just choose starting values by hand. What one could discuss is if the prior optimization that Tankred is implementing should access the info parameters, as they might provide some initial guesses of the user about boundaries, best values etc., even if no sampler is provided. |
The alternative would be that we force certain info parameters, e.g. user has to provide an initial best guess / variance if no sampler is provided. |
Since we want to keep createBayesianSetup the way that it is, we could do something like this:
Regarding creating a prior from a density alone: I know the sampler is "optional" in createPrior. However, if it is not provided we will get errors in createBayesianSetup and multiple samplers (e.g. DE). So it is not really optional. |
Another issue is how to get the number of parameters if only a density is passed. |
solved with #124 |
So, there is still this stale branch https://github.com/florianhartig/BayesianTools/tree/issue98 which seems to have code that was not merged into the master |
Arising from github.com//issues/72
If we try to parallelize the help of createPrior(), we got an error.
The reason is that there is an error in the prior specification in the help, and/or, depending on how you see it, in the logic of the createPrior.
In the example, we specify a density and a sampler, both identical. So far so good.
but then, when we create the prior, we use lower and upper. The idea of this option was to be able to add truncation to a arbitrary density, which is nice.
However, I just realized that the truncation it is not applied to the sampling function, which causes the sampler function to sample initial proposal in the MCMC that are outside the prior range.
Consequences from this
Clearly, the help needs to be changed - remove the truncation!
Secondly, we need to decide how we handle the truncation option in the future, should this be removed?
Thirdly, I don't understand why the MCMC is throwing an error only when run in parallel. Moreover, should we add additional checks in the MCMC to make sure that the initial values are sensible? For this, it would be nice to understand what's actually going on internally and why the error is only in the parallel mode.
The text was updated successfully, but these errors were encountered: