Closed jojal5 closed 4 years ago
Cool implementation.
An initial value for ϕ
is needed in this case since it appears in logfgrad1, which NUTSVariate()
calls to get an initial value for one of the tuning parameters (step size). Something like the following should do.
ϕ = [.1]
β = NUTSVariate([0.0, 0.0], logfgrad1)
ϕ = NUTSVariate([.1], logfgrad2)
You'll probably also want to use an inverse-Gamma prior for the variance in the log-posterior.
logpdf(InverseGamma(.001, .001), exp(ϕ))
Now, I'm noticing that the NUTS sampler output for the variance is lower than that from the Gibbs sampler in the package tutorial (posterior mean 0.55 vs 1.22). The beta output is comparable. If the prior variance is dropped from your log-posterior, then the NUTS variance output is more comparable, which makes me think the prior is having a different effect in the two implementations.
Thank you for the answer. It resolves the issue.
And yes, I meant the Inverse-gamma distribution :)
Hi,
I rewrote the Line: Block-Specific Sampling with AMWG and Slice () for illustrating the problem.
In this example, if the
AMWGVariate
command is replaced with theNUTSVariate
, an error is thrown stating that the variable of another block is not defined. To work around the problem, it is possible to first define the sampler with AMWGVariate and after, redefine it with NUTSVariate as in the code below. Is it normal? Thank you for the excellent package.