Open
Description
Some target distributions and so proposals can be defined in a dimension independent way, for example
target_distribution <- list(
log_density = function(x) -sum(x^2) / 2,
gradient_log_density = function(x) -x
)
proposal <- barker_proposal(target_distribution)
As the proposal object stores a shape parameter which is dimension dependent however, once the proposal is used to sample a chain with shape adaptation for a certain dimension, a subsequent attempt to use the same proposal with a different dimension gives a cryptic error -
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'drop': non-conformable arguments
which arises when attempting to evaluate product of vector with shape parameter from previous run (which is of incompatible dimension).
We may not want to support this use case of reusing the same proposal objects for different dimension, but ideally we should give a more informative error message in these situations.