reversible jump mcmc

10 views
Skip to first unread message

Qing Zhao

unread,
Jul 10, 2024, 10:44:35 AM (12 days ago) Jul 10
to nimble-users
Hi everyone,

I'm looking into the rjmcmc model selection method implemented in Nimble. Here, I want to consider a model that includes a quadratic form of a covariates, and I want the quadratic form to be included only when the main effect is in. I have the following line to achieve that (the full code is attached in case anyone is interested): 

    y_pred[i] <- beta0 + z[1] * beta1 * x1[i] + z[2] * beta2 * x2[i] + z[2] * z[3] * beta3 * x2[i] * x2[i]

which seems to work fine. However, meanwhile I figured there is this requirement that the length of beta's has to be the same as the length of z's. Say I want the main effect and the quadratic form to be in or out at the same time, what should I do? I cannot have the following:

    y_pred[i] <- beta0 + z[1] * beta1 * x1[i] + z[2] * beta2 * x2[i] + z[2] * beta3 * x2[i] * x2[i]

Is there a way to overcome this?

Best,
Qing


Qing Zhao

unread,
Jul 10, 2024, 10:45:22 AM (12 days ago) Jul 10
to nimble-users
Sorry I forgot the attachment.
nimble rjmcmc_temp 1.R

Qing Zhao

unread,
Jul 10, 2024, 11:28:10 AM (12 days ago) Jul 10
to Benjamin R Goldstein, nimble-users
Thank you Ben for sharing the information. It seems to be a cool way to deal with this issue.

Best,
Qing


On Wed, Jul 10, 2024 at 9:04 AM Benjamin R Goldstein <ben.go...@berkeley.edu> wrote:
Hi Qing--

I was working on a similar problem recently (RJMCMC when one indicator variable is associated with multiple variables downstream). I found the answer in this old thread, "Sampling categorical variables with RJMCMC":
The code provided by Daniel Eacker in their final email on the thread worked great for me. Thanks Daniel!

Hope this helps--
Ben

--
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/633a7068-7fdd-4187-9bd6-231e592dba91n%40googlegroups.com.

Benjamin R Goldstein

unread,
Jul 10, 2024, 2:57:41 PM (12 days ago) Jul 10
to Qing Zhao, nimble-users
Hi Qing--

I was working on a similar problem recently (RJMCMC when one indicator variable is associated with multiple variables downstream). I found the answer in this old thread, "Sampling categorical variables with RJMCMC":
The code provided by Daniel Eacker in their final email on the thread worked great for me. Thanks Daniel!

Hope this helps--
Ben

On Wed, Jul 10, 2024 at 10:44 AM Qing Zhao <white...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages