Skip to content

Instantly share code, notes, and snippets.

View eipi10's full-sized avatar

Joel Schwartz eipi10

  • California State University, Sacramento
View GitHub Profile
@eipi10
eipi10 / zoib-recovery.R
Created May 16, 2022 16:25 — forked from mbjoseph/zoib-recovery.R
Simulation for zero-one inflated beta regression in Stan
## DATA GENERATION
# reproducibility
library(bayesplot)
set.seed(1839)
# matches the stan function
inv_logit <- function(x){
exp(x) / (1 + exp(x))
}
@eipi10
eipi10 / helper_functions.r
Created May 14, 2021 02:32 — forked from mike-lawrence/helper_functions.r
Stan vs LME4 for hiearchical within-subjects designs with binomial outcomes
#' Installs any packages not already installed
#' @examples
#' \dontrun{
#' install_if_missing(c('tidyverse','github.com/stan-dev/cmdstanr'))
#' }
install_if_missing = function(pkgs){
missing_pkgs = NULL
for(this_pkg in pkgs){
@eipi10
eipi10 / extract_plots_from_list.R
Created April 18, 2019 00:23 — forked from bschneidr/extract_plots_from_list.R
Extract all of the ggplot2 plots from a list (including sub-lists)
#' @title Extract ggplot2 plots from a list
#' @description Takes a list (potentially containing sublists) and extracts all of the ggplot2 'plot-type' objects from that list into a simple list of 'plot-type' objects.
#' @param x A list object, potentially containing sublists.
#' @return Returns a 'flat', single-level list of all the ggplot2 'plot-type' objects from within `x`, reaching recursively into sub-lists as needed. If there are no 'plot-type' objects, returns an empty list.
#' @note Whether an object is a ggplot2 'plot-type' object is defined here as an object with classes 'gg', 'gTree', or 'gtable'.
#' @export
#' @examples
#'
#' library(ggplot2)
#'
@eipi10
eipi10 / xtable.decimal.r
Created February 18, 2016 16:12 — forked from jbryer/xtable.decimal.r
Prints a LaTeX table with numeric columns aligned on their decimal points. This function wraps the xtable and print.xtable functions in the xtable package so that numeric columns are aligned on their decimal place.
require(xtable)
#' Prints a LaTeX table with numeric columns aligned on their decimal points.
#'
#' This function wraps the \code{\link{xtable}} and \code{\link{print.xtable}}
#' functions in the \code{xtable} package so that numeric columns are aligned
#' on their decimal place.
#'
#' See \url{http://jason.bryer.org/posts/2013-01-04/xtable_with_aligned_decimals.html}
#' for more information.