Question about implementing probability of equality

30 views
Skip to first unread message

Stephen Martin

unread,
Apr 10, 2017, 2:23:40 PM4/10/17
to Stan users mailing list
Hey all,

I have posted several times about a funky model of mine, but I'm looking into all the various ways of examining the same question using variations on the model itself.

In one part of the model, there's a probability, delta, that two parameters are actually the same thing. I don't mean "the parameter for this group is essentially the same value as the parameter for another group", but rather they are literally the same thing; one should assume theta_1 = theta_2. This matters for the model because if they are the same, then the two groups inform the estimation of the single parameter rather than the two groups informing separate parameters.

Conceptually, what I would /like/ to do, is something like this. Say D=0 means they are the same, and D=1 means they are not. Delta is the probability of D.
y ~ p(parameter[group])
D ~ bernoulli(Delta)
if (D == 0) { parameter[2] = parameter[1] }
if (D == 1)}{ parameter[2] ~ normal(0,1)}
I know one needs to marginalize this for it to work in stan, but I'm at a loss for how one could do it in this case.

Conceptually, this is a bit like a mixture prior, where if D=0, then parameter[2] ~ normal(parameter[1], .0000001) [no real difference between parameter[2] and parameter[1]) and if D=1, then parameter[2] ~ normal(0,1) [it is permitted various values]. This is easy enough to code, but normal(parameter[1],.0000001) is very slow to sample due to the crazy curvature introduced by the prior.
Ideally, it would be a mixture between "we know the value is equal to parameter[1]" and "we know the value is independent of parameter[1]".
The inference is /not/ about whether parameter[2] - parameter[1], but this is a simple example of a much more complex model assessing measurement invariance.

Any ideas come to mind?

Sebastian Weber

unread,
Apr 10, 2017, 2:48:29 PM4/10/17
to Stan users mailing list
I don't quite get the idea, but what I certainly miss here is: scale!

No continuous random quantity is ever exactly equal to some value, the density of a point is zero. I think you need to rephrase your question...but I could fully misunderstand you intentions.

Sebastian

Ben B

unread,
Apr 10, 2017, 2:56:35 PM4/10/17
to Stan users mailing list
Check out the Change point model example (section 14.2).

This example tries to find the year at which the rate of mining disasters switches from parameter to another. Similarly, you could switch models entirely, or switch between a two parameter/one parameter thing.

You aren't looking for a change point, but coding up the model you describe is probably pretty similar. Read the section and look at the code in Figure 14.1.

It seems like you'd want to use 3 parameters though. I don't think you want your 2 parameter model affecting your 1 parameter model. It's two different models for the data, and the parameters could look quite a bit different.

Ben

Stephen Martin

unread,
Apr 10, 2017, 2:56:45 PM4/10/17
to Stan users mailing list
The idea is that, say, two groups are measured using the same measurement technique. The goal is to see whether the some of the measurement model parameters are equal or sufficiently different between groups to justify saying that the measurement operates differently on the two groups.
Therefore, the parameter[2] could equal parameter[1] (groups' observations are driven by the same process) or parameter[2] may be independent of parameter[1] (groups' observations driven by different processes).

One way of expressing this is to put a mixture prior on the parameter[2]: parameter[2] ~ (1-Delta)N(parameter[1],.00001) + Delta*N(0,1), but sampling from N(anything,.00001) is difficult due to curvature.
It's not the end of the world if I have to do something similar to that (or less extreme: (1-Delta)N(parameter[1],.05)), but I was curious what other options there may be for expressing this in a way that can more easily explore.
Like I said, conceptually, it's parameter[2] = parameter[1] if D=0, or is an independent variable if D=1.

Ben B

unread,
Apr 10, 2017, 2:58:08 PM4/10/17
to Stan users mailing list
"section 14.2" being "section 14.2 of the Stan Manual"

I don't really have expertise with the type of thing you're doing. Just sounded similar to a problem I had once and Bob fwd'd me to that.

Ben

Bob Carpenter

unread,
Apr 10, 2017, 3:44:32 PM4/10/17
to stan-...@googlegroups.com
Use a hierchical model. That's what they're there for!

If you insist on what you're doing, just marginalize out the
indicator. But if you have a bunch of those that interact,
it'll be intractable.

- 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.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages