-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Allowing _lp
in the transformed parameters block and jacobian
in the model block
#1482
Comments
I think walking back the deprecation is fine. I'd like to allow I think your function is interesting, because ideally it would contain both So, it might also be worth considering if we should have some way of writing a function that allows both. |
Having the option to do both is ideal. If users also want to inspect the |
Relatively easy. I've also wondered if |
So is the idea to just allow both |
Maybe? It still seems useful from some perspective to have lesser-powered versions of these things floating around. I think they also end up code-genned differently than each other due to the extra |
We need @spinkney: In your example, why are you incrementing |
The above is the same as putting a uniform prior on a correlation matrix, that is an LKJ(1). All the math in the LKJ paper shows that these simplify to powers of the diagonal of the Cholesky factor. However, I've put the correlation constraint in this form because I may have knowledge about some of the correlations that deviates from the uniform! In this case, the form does not simplify thus I need |
I'm not following the details, but the question to ask is what the MLE would be. In the other cases, it's clear we want to drop all the stuff that leads to the distribution being uniform on the unconstrained scale as that monkeys with the underlying density being optimized and pulls it away from the pure likelihood. |
The pr #979 added the
jacobian +=
and_jacobian
function keyword to indicate adding the change of variables correction for a transformed parameter. Thejacobian
functionality can only be used in the transformed parameters block. That same pr also introduced a warning that_lp
type functions will no longer be allowed in the transformed parameters block and will only be supported in the model block. I think the introduction of thejacobian
functionality is useful but I believe restricting the_lp
to only the model block is a step backwards for Stan.In merging #979, which users will first see in cmdstan 2.36, any user defined function ending with
_lp
that is used in the transformed parameters block will receive a warning that this functionality will not be allowed in future releases. The initial reasoning in the discussion for #979 is that allowing functions to access thetarget
was a bug in stanc2 that we continued to support in stanc3. The merged pr is indicating the "fix". However, there are times where it is useful to both add the jacobian correction and to add a log density. I don't believe this is widespread but in matrix parameters I encounter it. For example, below I show the c-vine parameterization of a correlation matrix. I use both thejacobian
and thetarget
keywords here. I'm not sure this will compile because I believe it would need to end in_jacobian
. I have been usingtarget
everywhere wherejacobian
now is which does compile in previous versions.The first thing to note is that I often nest
_lp
functions, here I havelb_ub_lp
called within thecorr_constrain_cvine_lp
function. The next thing is that I'm traversing the lower triangular part of the matrix and I'm adding abeta
prior to a transformed parameter created in this function. However, it is an intermediate parameter used to calculate the final correlation matrix,C
.If the deprecation goes through then I will have to have two functions, one for the jacobian that constructs
C
while also returning atuple
of matrices for bothP
andC
. Then in the model block I'll have to loop throughP
to increment the log density by thebeta_lpdf
. I don't even needP
and I definitely don't want to do the double loop again!The current ability of having
_lp
works great. Let's keep it and, while we're at it, let's make the language a bit more flexible and add the ability for users to use thejacobian
keyword in the model block.The text was updated successfully, but these errors were encountered: