Skip to content
10 changes: 10 additions & 0 deletions UserManual/src/chapter_InstallingNimble.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ method if you download the package source directly.

NIMBLE can also be obtained from the [NIMBLE website](https://r-nimble.org). To install from our website, please see our [Download page](https://r-nimble.org/download) for the specific invocation of `install.packages`.

To test that the installation worked and can use NIMBLE's compilation system, you can run this small test code, which should run without error and produce a value for `y` in the model.

```{r, eval=FALSE}
code <- nimbleCode({ y ~ dnorm(0,1) })
model <- nimbleModel(code)
comp_model <- compileNimble(model)
comp_model$simulate('y')
comp_model$y
```

## Troubleshooting installation problems

Expand Down Expand Up @@ -125,6 +134,7 @@ For MacOS:

All operating systems:

- To determine if the problem is with the availability of the C++ compiler or with NIMBLE itself, you can try to install the `Rcpp` package. If you can install `Rcpp` and successfully run this command in R: `Rcpp::evalCpp("2 + 2")` and get 4, that suggests the problem is with NIMBLE. If not, then the problem is probably with the C++ compiler or its use from R and not with NIMBLE itself.
- If problems arise from generating and compiling C++ files from the default location in R's `tempdir()`, one can use the `dirName` argument to `compileNimble` to put such files elsewhere, such as in a local working directory.

If those suggestions don't help, please post about installation problems to the [nimble-users Google group](https://groups.google.com/forum/#!forum/nimble-users) or
Expand Down
2 changes: 1 addition & 1 deletion UserManual/src/chapter_MCMC.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ If `fixedValue` is given when using `indicatorNodes` the values provided in `fix



NIMBLE provides a variety of other commonly-used samplers, some for general-purpose use and some for specialized use with particular distributions or situations. Some that are worth particular consideration are:
NIMBLE provides a variety of other commonly-used samplers, some for general-purpose use and some for specialized use with particular distributions or situations. Some that are worth particular consideration as they may perform better than the samplers that NIMBLE assigns by default are:

1. the Hamiltonian Monte Carlo (HMC) sampler in the `nimbleHMC` package,
2. the slice sampler for sampling scalar parameters in place of the default `RW` (Metropolis) sampler,
Expand Down
2 changes: 1 addition & 1 deletion packages/nimble/R/MCMC_samplers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3513,7 +3513,7 @@ sampler_barker <- nimbleFunction(

#' MCMC Sampling Algorithms
#'
#' Details of the MCMC sampling algorithms provided with the NIMBLE MCMC engine; HMC samplers are in the \code{nimbleHMC} package and particle filter samplers are in the \code{nimbleSMC} package.
#' Details of the MCMC sampling algorithms provided with the NIMBLE MCMC engine; HMC samplers are in the \code{nimbleHMC} package and particle filter samplers are in the \code{nimbleSMC} package. Additional details, including some recommendations for samplers that may perform better than the samplers that NIMBLE assigns by default are provided in Section 7.11 of the User Manual.
#'
#'
#' @param model (uncompiled) model on which the MCMC is to be run
Expand Down
17 changes: 9 additions & 8 deletions packages/nimble/R/parameterTransform.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ parameterTransform <- nimbleFunction(
## argument values(model, nodes), return vector on unconstrained scale
transformed <- nimNumeric(tLength)
if(nNodes == 0) return(transformed)
iNode <- 1L; i <- 1L; j <- 1L; dd <- 1L; pp <- 1L ## integer types
for(iNode in 1:nNodes) {
theseValues <- nodeValuesFromModel[transformData[iNode,NIND1]:transformData[iNode,NIND2]]
thisType <- transformType[iNode]
Expand All @@ -263,14 +264,14 @@ parameterTransform <- nimbleFunction(
## DT: there has to be a better way to do this procedure, below,
## creating the vector of the log-Cholesky transformed values.
theseTransformed <- nimNumeric(transformData[iNode,DATA2])
tInd <- 1
tInd <- 1L
for(j in 1:dd) {
for(i in 1:dd) {
if(i==j) { theseTransformed[tInd] <- log(U[i,j]); tInd <- tInd+1 }
if(i< j) { theseTransformed[tInd] <- U[i,j]; tInd <- tInd+1 } } }
if(i==j) { theseTransformed[tInd] <- log(U[i,j]); tInd <- tInd+1L }
if(i< j) { theseTransformed[tInd] <- U[i,j]; tInd <- tInd+1L } } }
},
{ ## 8: multivariate dirichlet
dd <- transformData[iNode,DATA1] - 1
dd <- transformData[iNode,DATA1] - 1L
theseTransformed <- nimNumeric(dd)
theseTransformed[1] <- logit( theseValues[1] )
if(dd > 1) {
Expand All @@ -287,21 +288,21 @@ parameterTransform <- nimbleFunction(
theseTransformed <- nimNumeric(pp)
theseValuesMatrix <- nimArray(theseValues, dim = c(dd, dd)) # U in matrix form
if(dd > 1) {
cnt <- 1
cnt <- 1L
## Length of each column of U is 1.
## We first produce the canonical partial correlations and then apply atanh()
## to make the unconstrained parameters..
for(j in 2:dd) {
theseTransformed[cnt] <- atanh(theseValuesMatrix[1, j])
cnt <- cnt + 1
cnt <- cnt + 1L
if(j > 2) {
partialSum <- 1
for(i in 2:(j-1)) {
partialSum <- partialSum - theseValuesMatrix[i-1, j]^2
## Transformed value is atanh of the proportion of the
## remaining correlation (which is in 'partialSum').
theseTransformed[cnt] <- atanh(theseValuesMatrix[i, j] / sqrt(partialSum))
cnt <- cnt + 1
cnt <- cnt + 1L
}
}
}
Expand Down Expand Up @@ -470,6 +471,6 @@ parameterTransform <- nimbleFunction(
return(lp)
}
),
buildDerivs = list(inverseTransform = list(),
buildDerivs = list(inverseTransform = list(), transform = list(),
logDetJacobian = list(ignore = c('iNode','j','dd','ddm1','i')))
)
Loading