I think this is the same question, but you need to do
the transform and apply the Jacobian adjustment.
parameters {
vector[N] tau_raw;
transformed parameters {
vector[N] tau = inv_logit(tau_raw) .* y; // this could also be a local variable
The Jacobian is just
inv_logit(tau_raw[n]) * (1 - inv_logit(tau_raw[n]) * y[n];
and you want it on the log scale, so that's
log_inv_logit(tau_raw[n]) + log1m_inv_logit(tau_raw[n]) + log(y[n])
putting it all together, that should just be:
model {
target += log_inv_logit(tau_raw);
target += log1m_inv_logit(tau_raw);
target += log(y);
It's more efficient to increment in three pieces, but you can put it
all together if you want --- it's not that much less efficient.
And you can drop the y if that's a constant obviously.
I need to put this in the manual, too:
https://github.com/stan-dev/stan/issues/2265#issuecomment-297120950
- Bob
> On Apr 24, 2017, at 1:25 PM, Tiago Cabaço <
tiago.jo...@gmail.com> wrote:
>
>
> Hello everyone,
>
> I am currently working on a hierarchical version of the wiener diffusion model and I am having some issues with the non-decision time parameter. Since I am trying to estimate one parameter per trial, the estimated non-decision time parameter can't be higher then the actual response time for that trial. If bounds are not specified in the model, rstan won't start sampling.
>
> However, since different trials have different response times, I would like to know if there is a way in which I could parameterize the model so that the upper bound for trial "n" is either given by a function
>
> data{
> int N; // number of trials
> y[N]; //Reaction times
> ...
> }
>
> parameters{
> for (i in 1:N){
> vector<lower=0.0001, upper = y[n] - .01>[N] tau; //non-decision time for trial n
> }
> ...
> }
>
> or by a value from a vector?
>
> data{
> int N; // number of trials
> real y[N]; //Reaction times
> int upper_limit; //upper_limit = y[n] - 0.01
> ...
> }
>
> parameters{
> for (i in 1:N){
> vector<lower=0.0001, upper = upper_lim[n]>[N] tau; //non-decision time for trial n
> }
> ...
> }
>
> Thank you,
>
> Tiago
>
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.
> To post to this group, send email to
stan-...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.