Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new functions for group means and correlations #10

Merged
merged 2 commits into from
Jun 7, 2023

Conversation

Nathaniel-Haines
Copy link
Collaborator

I discovered an issue with how group mean parameters were being calculated (post hoc in the generated quantities block) that traces back to hBayesDM. As described in the issue I opened here, the method where we simply do, e.g., mu_Arew = Phi_approx(mu_p[1]) in Stan actually gives us an estimate of the group median rather than group mean. This is a rather subtle bug, so I don't expect it to change results much (if at all).

I opened this PR with a new custom function in the Stan codes called Phi_approx_group_mean_rng which computes the group mean as intended. It involves a simulation step as described in the issue I linked. I also added a new function termed Phi_approx_corr_rng that will simulate the test-retest correlations on the scale of interest, which avoids the need for us to do the pop_correct_MCMC step post-hoc. Now, we can just do:

pars = rstan::extract(orl_fit)

pars$R_Arew

and the resulting correlation we get from Stan will be of the correlation on the parameters with the correct transformation. So, no more need to do the iterative correlations part outside of Stan!

@hollysully @jeremy-haynes I know this is a strange change—let me know if you have any questions! Going forward, this should be more robust given that we have had some trouble with the pop_correct_MCMC code before.

NOTE: I still need to update the R analysis code that computes the iterative correlations/runs the pop_correct_MCMC step, as it is no longer necessary. That said, I was not sure what all we want to save in that analysis file. If anyone wants to update that before we merge these changes, feel free to! (and push changes to this branch)

Copy link
Collaborator

@jeremy-haynes jeremy-haynes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nathaniel-Haines @hollysully this sounds good to me. I was looking at the new code. I was wondering if these were kind of like a bootstrap-type of approach to calculating the group means and the correlations (but bootstrapped for each MCMC sample)? In any case, I can work on updating the RMDs that have the iterative correlations and whatnot.

@jeremy-haynes jeremy-haynes mentioned this pull request Jun 6, 2023
@Nathaniel-Haines
Copy link
Collaborator Author

@Nathaniel-Haines @hollysully this sounds good to me. I was looking at the new code. I was wondering if these were kind of like a bootstrap-type of approach to calculating the group means and the correlations (but bootstrapped for each MCMC sample)? In any case, I can work on updating the RMDs that have the iterative correlations and whatnot.

It is similar in that simulation is used, but this method is really more like a posterior predictive simulation. Since we have the full posteriors on group-level parameters, we can simulate results forward from them and make inference on the resulting values 🤓

@Nathaniel-Haines Nathaniel-Haines merged commit a3ae291 into main Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants