diff --git a/UserManual/src/chapter_InstallingNimble.Rmd b/UserManual/src/chapter_InstallingNimble.Rmd index 6588b9424..a208c8e63 100644 --- a/UserManual/src/chapter_InstallingNimble.Rmd +++ b/UserManual/src/chapter_InstallingNimble.Rmd @@ -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 @@ -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 diff --git a/UserManual/src/chapter_MCMC.Rmd b/UserManual/src/chapter_MCMC.Rmd index e21d9acce..7d378738e 100644 --- a/UserManual/src/chapter_MCMC.Rmd +++ b/UserManual/src/chapter_MCMC.Rmd @@ -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, diff --git a/packages/nimble/R/MCMC_samplers.R b/packages/nimble/R/MCMC_samplers.R index 3914f25ce..bb9608824 100644 --- a/packages/nimble/R/MCMC_samplers.R +++ b/packages/nimble/R/MCMC_samplers.R @@ -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 diff --git a/packages/nimble/R/parameterTransform.R b/packages/nimble/R/parameterTransform.R index 3b70ed50d..fe7eb8ee7 100644 --- a/packages/nimble/R/parameterTransform.R +++ b/packages/nimble/R/parameterTransform.R @@ -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] @@ -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) { @@ -287,13 +288,13 @@ 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)) { @@ -301,7 +302,7 @@ parameterTransform <- nimbleFunction( ## 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 } } } @@ -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'))) )