Skip to content

Random tips and tricks

Daniel Turek edited this page Apr 15, 2017 · 28 revisions
  • To check that a C++ compiler installed:
devtools::has_devel()
  • To see the internal adaptation info from adaptive samplers:
nimbleOptions(buildInterfacesForCompiledNestedNimbleFunctions=TRUE)
Cmcmc$samplerFunctions$contentsList[[i]]$propCov
  • To build & install developmental version from github:
remove.packages('nimble')
library(devtools)
install_github('nimble-dev/nimble', ref = 'devel', subdir = 'packages/nimble')
library(nimble)
  • When package build fails around release, possibly with error library not found for -lgfortran, in src/Makevars.in, comment out FLIBS to read: #$(FLIBS)

  • For writing iterative MCMC algorithms, it's extremely useful to not have to recompile model and MCMC objects on every iteration, which takes a long time. This page describes a procedure for writing such iterative algorithms, without having to recompile a model and MCMC algorithm on each iteration.

  • To clear all loaded DLLs w.r.t. any project (pass any object from that project):

nimble:::clearCompiled(Rmodel)
  • Access / assign to a variable in a nested compiled nimbleFunction (without using the option nimbleOptions(buildInterfacesForCompiledNestedNimbleFunctions = TRUE)):
valueInCompiledNimbleFunction(outerNF$nestedNF, 'x')
valueInCompiledNimbleFunction(outerNF$nestedNF, 'x', newValue)
valueInCompiledNimbleFunction(Cmcmc$samplerFunctions[[i]], 'x')
valueInCompiledNimbleFunction(Cmcmc$samplerFunctions[[i]], 'x', newValue)
  • Get ancestors (parents) of a model node:
md <- model$getModelDef()
parentIDs <- md$maps$edgesFrom[ md$maps$edgesTo == md$nodeName2GraphIDs(node) ]
parentNodes <- md$maps$graphID_2_nodeName[ parentIDs ]

Clone this wiki locally