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

Is pD ever computed in the same way as BUGS, using R2jags? #19

Open
giabaio opened this issue Jun 7, 2024 · 11 comments
Open

Is pD ever computed in the same way as BUGS, using R2jags? #19

giabaio opened this issue Jun 7, 2024 · 11 comments

Comments

@giabaio
Copy link
Contributor

giabaio commented Jun 7, 2024

Hi there,
This may be a silly question -- but I know in the R2jags code, the print method has a line

msgDICRule <- ifelse(x$DICbyR, "(using the rule, pD = var(deviance)/2)", "(using the rule, pD = Dbar-Dhat)")

which seems to indicate that, sometimes, x$DICbyR may be FALSE and therefore pD would be computed in the same way as BUGS would. All the times I've used JAGS/R2jags, though, I don't think this has ever happened and R2jags/JAGS, I think, always compute pD as var(deviance)/2.

I know you can estimate the value that BUGS would calculate using rjags::dic.samples(), but I wanted to make sure that the ifelse statement was actually activated, at least in theory?

Thanks!
Gianluca

@giabaio
Copy link
Contributor Author

giabaio commented Jun 19, 2024

Related to this, would you consider a PR to modify the naming of the pD object to avoid confusion? I have a fork of your package and have made some changes (which I don't think break anything, as far as I've tested) to rename the resulting value (pV instead of pD), which then propagates to the print method too. In fact, I have added an option to compute pD using rjags::dic.samples(), which may be helpful too... Happy to send a PR if it helps.

@suyusung
Copy link
Owner

I merged your fix. Can you provide short description on these: Argument names in code not in docs:
pD n.iter.pd n.adapt?

@giabaio
Copy link
Contributor Author

giabaio commented Jun 23, 2024 via email

@giabaio
Copy link
Contributor Author

giabaio commented Jun 23, 2024

Yes, I have checked and the new options are described in the man file jags.Rd.

G

@giabaio
Copy link
Contributor Author

giabaio commented Jun 23, 2024

Thanks for merging the PR --- this is very helpful! I may fiddle with the package a bit more, as I'm using it extensively to complement a book --- hope OK?

@suyusung
Copy link
Owner

Sure. Your contribution can lively update this package.

@suyusung
Copy link
Owner

I have made some changes to ensure the package to pass the R CMD check. Please let me know when you are done with the patch. I will upload the new package on to the CRAN.

@giabaio
Copy link
Contributor Author

giabaio commented Jun 24, 2024

Perfect. So:

  1. There's a small change --- I set the adapt step to be silent (so force progress.bar="none" and quiet=TRUE). I also have a few tidyverse functions for post-processing, like traceplots, acfplots, posterior plots etc. They are currently under my non-CRAN package bmhe --- they do NOT need to be ported into R2jags and they would also rely on tidyverse, which is a negative, as it would add a dependency. If you want them though, I am happy to add the code.
  2. I am toying with the ideal of allowing the user to set a global set of options (like options(r2j.progress.bar="text") or options(r2j.quiet=FALSE)) and then let the main functions read the preferred behaviour from there. Nothing would change with respect to what happens now, in terms of default, but the advantage is that you would be able to modify the default globally, if you need to. So, for instance, if I use R2jags inside a quarto project to compile R code into a document, I could shut all the messages and text output (which I don't want to appear in the resulting document), while not having to specify in the call to jags the options progress.bar="none", quiet=TRUE all the time... This is minor, too, I guess --- I find it helpful in my own specific project (for which I have a separate branch of my fork to R2jags). Again, if you think that's worth it, I can look into this.

I think bottom line, I can either very quickly implement 1. so you can submit to CRAN and avoid the potential bug (which didn't impact the results all the time, in my experience, but occasionally it would very badly) or if you want all, give me a couple days and then I'll send another PR...

Let me know what you think!

@suyusung
Copy link
Owner

I think I would prefer option 2 for now.

@giabaio
Copy link
Contributor Author

giabaio commented Jun 26, 2024 via email

@giabaio
Copy link
Contributor Author

giabaio commented Jun 27, 2024

So just to make sure, are you happy with the current patched version, or would you like the options argument too?

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

No branches or pull requests

2 participants