项目作者: hesscl

项目描述 :
用于INLA固定效应系数ggplots的R库
高级语言: R
项目地址: git://github.com/hesscl/coefINLA.git
创建时间: 2018-03-11T19:47:10Z
项目社区:https://github.com/hesscl/coefINLA

开源协议:GNU General Public License v2.0

下载


coefINLA

ggplot for INLA Fixed Effect Coefficients

This R package provides high-level graphics functions for converting INLA model output into aesthetically-pleasing ggplot2-based visualizations.

You can get it using:

  1. devtools::install_github("hesscl/coefINLA")


coefINLA() is currently the only function in this library, and requires an INLA model as it’s main argument (mod.inla)

  • For exponentiated coefficients, set argument exp = TRUE
  • To omit the intercept, set argument intercept = FALSE
  • To exclude one or more covariates, set argument exclude = 'varname' or include multiple colnames with c()
  • For custom facet labels, save your_labeller() for ggplot, and utilize this with the function’s labeller argument.
  • You can also pass a character string corresponding to a RColorBrewer palette (e.g. “Reds”, “Blues”) if purple isn’t your thing.
  • The type of visualization this plot returns is akin to bayesplot::mcmc_areas().
    • Instead of showing a colored ribbon for the middle 80%, coefINLA() uses the middle 95% and is based on integrated nested laplace approximation (cuz’ you’re using INLA).
  • This function returns a ggplot as its output. This means you can either use the default plot configuration OR you can still pipe additional graphics helper functions for customizing labels or other aspects of the plot.
  • See example syntax below

Example default graphic using iris

alt text

Example syntax:

  1. #setup your model, run it through INLA
  2. mod1 <- inla(form1, data = df, ...)
  3. #default
  4. coefINLA(mod1)
  5. #for those that don't like purple...
  6. coefINLA(mod1, "Blues")
  7. #add title
  8. coefINLA(mod1) +
  9. labs(title = "My fancy title")
  10. #remove intercept
  11. coefINLA(mod1, intercept = FALSE)
  12. #save plot with title to pdf
  13. coefINLA(mod1) +
  14. labs(title = "My fancy title") +
  15. ggsave(filename = "my fancy file.pdf")