reversible jump, linear model with a quadradic term

27 views
Skip to first unread message

Brian Hatfield

unread,
Jul 8, 2022, 3:05:00 PM7/8/22
to nimble-users
Hello all,

consider the following simple linear model with a quadratic term:

logit(y) = b0 + b1 * x[1] + b2 * x[2] + b3 * x[2]^2

I would like to use reversible jump to evaluate the entire quadratic part of the model with a single indicator something like:

logit(y) = b0 + ind[1] * b1 * x[1] + ind[2] * b2 * x[2] + ind[3] * ( b3 * x[2] + b4 * x[2]^2)

where ind[i] are the reversible jump indicator variables, and i have added another b coefficient in order to evaluate the linear x[2] (b2)  term separately from the quadratic x[2] (b3 and b4) terms. 

I have made a few attempts to run this with some data but the problem that I am running into is that ind[3] can only be connected to one of b3 or b4, so if say I set b3 as the target for ind[3], then b4 uses a standard sampler and is likely to drift when ind[3] is turned off by the model (this seems to be the case when I run such a model with data). 

So I am wondering if anyone has any ideas on how to build this model where both b3 and b4 are tied to ind[3] and will stop sampling when ind[3] is switched off.  Also, I think I understand how the indicators and targets work with nimble's reversible jump sampler.. but I recognize I might be missing/misunderstanding something. 

very grateful for any help,
Brian

Matthijs Hollanders

unread,
Jul 9, 2022, 2:26:34 AM7/9/22
to Brian Hatfield, nimble-users
Hey Brian,

If I’m understanding you correctly, I think having just three indicators (one for each term b1-3), but then using dconstraint to specify that that ind[3] has to be less than or equal to ind[2], will work. This will force the quadratic part to be evaluated separately from but conditional on the linear component. 

Regards,

Matt 

--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/5573423e-bbec-45c0-85b2-90ea6902613dn%40googlegroups.com.

Brian Hatfield

unread,
Jul 12, 2022, 1:07:35 PM7/12/22
to nimble-users
Hi Matt

Thanks for getting back to me.  Hmm.. If I follow your answer correctly I think I would still have the issue of one of b3 or b4 not having a target associated with ind[3], and the one without a target will tend to drift during sampling while ind[3] is switched to 0.  Just to clarify, my goal is to evaluate the entire quadratic portion of the model  (b3 * x[2] + b4 * x[2]^2)  with a reversible jump indicator to independently compare the relative importance of the the x[2] quadratic vs the x[2] linear covariate and the x[1] covariate.

I think this problem is very similar to this post: https://groups.google.com/g/nimble-users/c/O4A9mxW_vhU/m/JQ6Kk94EBAAJ,  where the  goal is to group all of the coefficients for a categorical variable to a single indicator for reversible jump.  Likewise I would like to link the two coefficients (b3 and b4) in the quadratic terms to a single indicator.. When I have a little time I will try the suggested solution.

Thank you again, if you have any input I would love to hear it.  Ill post something if I get this to work.

Brian

Matthijs Hollanders

unread,
Jul 12, 2022, 7:58:37 PM7/12/22
to Brian Hatfield, nimble-users
Hey Brian,

I suppose I'm a bit confused about the "entire quadratic" part. In the way I suggested, you're first using RJMCMC to test whether the linear part should be included, and conditional on that, whether or not the quadratic part should be included. I think this is achieving what you're trying to do. Otherwise, you could try something like this:

logit(y) = b0 + ind[1] * b1 * x[1] + ind[2] * b2 * x[2] + ind[3] * ind[4] * ( b3 * x[2] + b4 * x[2]^2)

and make ind[3] the indicator for the target ind[4]. However, this will first evaluate the linear part and then evaluate the entire addition of the linear part with the quadratic part on top of the linear part already included. I'm not sure that's what you want... if you want to include only the linear part or the whole quadratic part, you could once again add a constraint that sum(ind[2:3]) is less than or equal to 1, but I think that'll be equivalent to my initial formulation.

I hope that I'm understanding a bit, and then this helps.

Regards,

Matt

Brian Hatfield

unread,
Jul 13, 2022, 12:37:39 PM7/13/22
to nimble-users
Hi Matt,

Thanks for getting back to me again, I suspect that the confusion is on my part.  Ill try your suggestion to constrain the indicators.

Brian
Reply all
Reply to author
Forward
0 new messages