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

Change example in documentation? #67

Closed
larryshamalama opened this issue Jun 19, 2024 · 1 comment
Closed

Change example in documentation? #67

larryshamalama opened this issue Jun 19, 2024 · 1 comment

Comments

@larryshamalama
Copy link

larryshamalama commented Jun 19, 2024

## #' @examples
## #' code <- nimbleCode({
## #' b0 ~ dnorm(0, 0.001)
## #' b1 ~ dnorm(0, 0.001)
## #' sigma ~ dunif(0, 10000)
## #' for(i in 1:N) {
## #' mu[i] <- b0 + b1 * x[i]
## #' y[i] ~ dnorm(mu[i], sd = sigma)
## #' }
## #' })
## #'
## #' N <- 10
## #' constants <- list(N = N, x = 1:N)
## #' data <- list(y = 1:N)
## #' inits <- list(b0 = 1, b1 = 0.1, sigma = 1)
## #'
## #' Rmodel <- nimbleModel(code, constants, data, inits, buildDerivs = TRUE)
## #'
## #' conf <- configureMCMC(Rmodel, nodes = NULL)
## #'
## #' conf$addSampler(target = c('b0', 'b1', 'sigma'), type = 'HMC')
## #'
## #' Rmcmc <- buildMCMC(conf)

(same example as in the reference manual)

I tried this example at first and, while it runs well, I was a bit confused as to what it is estimating. While the posterior plots seem confusing at first, the posterior draws have little stochasticity, since the data does not have any randomness as well. Would it be better to use a more "illustrative" generated data? E.g.

N <- 1000
x <- rnorm(N)
y <- 1 + 2 * x + rnorm(N)

# nimble model

constants <- list(N = N, x = x)
data <- list(y = y)

# etc.

CC openjournals/joss-reviews#6745

@danielturek
Copy link
Member

@larryshamalama Agreed, the example in the roxygen was not ideal. I've just changed the HMC example to something similar to your suggestion, the relevant code:

set.seed(0)
N <- 100
x <- rnorm(N)
y <- 1 + 0.3*x + rnorm(N)
constants <- list(N = N, x = x)
data <- list(y = y)

This change is made on the master branch of the nimbleHMC repository, and also merged into the joss branch for this review.

Thanks for the helpful suggestion. I'm going ahead and closing this issue.

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