Skip to content

nimble-dev/nimbleMacros

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

151 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nimbleMacros

R build status CRAN DOI

nimbleMacros is an R package that extends NIMBLE, an R package for hierarchical statistical modeling. The package provides a set of model macros, which are special code chunks that NIMBLE automatically expands into larger blocks of valid NIMBLE model code.

For example, the following NIMBLE model code contains a macro called LINPRED, and the objective is to create a linear predictor containing an intercept and a slope for one covariate, x.

code <- nimbleCode({
  mu[1:N] <- LINPRED(~x)
})

Given particular data and constants, NIMBLE will expand this macro into the following code:

{
  for (i_1 in 1:N){
    mu[i_1] <- beta_Intercept + beta_x * x[i_1]
  }
}

Provided macros include:

  • LM: A macro to generate code for complete linear, generalized linear, and generalized linear mixed models. The macro uses the same syntax as familiar R functions such as lm, glm, glmer, and glmmTMB.
  • LINPRED: A macro to generate code for linear predictors using a formula-based syntax, including handling of continuous and categorical covariates and random effects.
  • LINPRED_PRIORS: : A macro to generate code for prior specifications using a formula-based syntax, including handling of continuous and categorical covariates and random effects.
  • FORLOOP: A macro generating a for loop or nested set of for loops based on a bracket and index based syntax.

See the package vignette for more details.

About

Linear modeling macros for use in NIMBLE code

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages