# load dagitty, and hack to make it work (we hope)
library(dagitty)
dagitty("dag{}")

# our favorite suite of packages
library(brms)           
library(ggformula)      # formula interface to ggplot2
library(R2jags)         # use JAGS from R

library(rstan)          # use Stan from R
library(ggmcmc)
library(coda)           # work with MCMC samples
library(bayesplot)      # plots related to Bayesian data analysis
library(rethinking)     # Statistical Rethinking
library(CalvinBayes)    # load after coda and bayesplot

# part of tidyverse for data wrangling
library(dplyr)
library(tidyr)
library(purrr)


# Some customization.  You can alter or delete as desired (if you know what you are doing).

# rstan configuration -- as recommended by rstan
  # use as many cores as are available
  options(mc.cores = parallel::detectCores())
  # To avoid recompilation of unchanged Stan programs, we recommend calling
  rstan_options(auto_write = TRUE)

# this sets the black/white theme for plots.
# you can change the base_size to control the size of the text elements in the plot
theme_set(theme_bw(base_size = 8)) 

knitr::opts_chunk$set(
  error = TRUE,     # display error message and keep going if there is an error
  tidy = FALSE,     # display code as typed
  size = "small",   # slightly smaller font for code
  fig.width = 3.0,  # width of figures (can be overridden in individual chunks)
  fig.height = 2.0, # heights of figures (can be overridden in individual chunks)
  fig.show = "hold" # put all figures after all the code
)

Problem ?.?

An example with a couple of plots. Notice that they appear after all of the code and are small enough to fit side-by-side.

gf_dhistogram( ~ age, data = mosaicData::HELPrct)
gf_density( ~ age, data = mosaicData::HELPrct)

Here's a wider plot using fig.width = 6:

gf_dhistogram( ~ age, data = mosaicData::HELPrct, binwidth = 1) %>%
  gf_dens()

Looks like we have a work-around for daggity:

dag <- dagitty("dag{A <- B -> C}")
drawdag(dag)
impliedConditionalIndependencies(dag)


rpruim/CalvinBayes documentation built on April 12, 2021, 1:49 p.m.