dinterval function in Stan?

149 views
Skip to first unread message

KK Sasa

unread,
Nov 29, 2013, 8:04:10 PM11/29/13
to
Hellow, everyone
I am curious if Stan has the same sampling function like 'dinterval' in JAGS?
or any method acts the same like dinterval?

Thanks in advance.

Bob Carpenter

unread,
Nov 29, 2013, 11:49:17 PM11/29/13
to stan-...@googlegroups.com
We don't have a distribution like dinterval. I briefly
looked at the JAGS manual and didn't understand exactly
what it was doing.

You can code both truncation and censoring directly
in Stan, though. There's a chapter in the manual
explaining how.

- Bob
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
Message has been deleted

Bob Carpenter

unread,
Nov 30, 2013, 11:51:40 AM11/30/13
to stan-...@googlegroups.com
What's with the funky fonts

On 11/30/13, 3:06 AM, KK Sasa wrote:

...
> And I found the definition of dinterval at the webpage
> <http://jags.sourcearchive.com/documentation/3.1.0/classbugs_1_1DInterval.html>:
>
> |
>
> i ~ dinterval(t, cutpoints[])
> f(i|t) = 1 if t < cutpoints[i] and t >= cutpoints[i-1]
> = 0 otherwise
>
> |
>
> So, I think I can use custom probability function 'increment_log_prob' in Stan.
> p. 151 in Stan manual reads it can use increment_log_prob(log(0.0)) to calculate the log(probability=0).
> However, I gave it a try, but Stan failed to do this.

If you use increment_log_prob(log(0)), it's equivalent to hard-coding
a sample rejection. If you initialize at such a state, you'll never
be able to move.

> Any suggestion for this kind deterministic function?

No. You shouldn't try to implement dinterval() in Stan. It's
a hack in JAGS, whereas Stan can just implement the truncation
and censoring models directly.

I'd again urge you to check out the manual chapter on truncation
and censoring. What you're going to need is a constraint, because
Stan assumes that variables have support (non-zero probability or finite
log probability) on their (possibly constrained) ranges.

- Bob

Reply all
Reply to author
Forward
0 new messages