Skip to content

Instantly share code, notes, and snippets.

@gaberoo
gaberoo / # augustus - 2019-05-22_15-40-41.txt
Created May 22, 2019 20:02
augustus on macOS 10.14.4 - Homebrew build logs
Homebrew build logs for augustus on macOS 10.14.4
Build date: 2019-05-22 15:40:41
@gaberoo
gaberoo / intersecting.axis.R
Created February 5, 2013 15:05
A replacement for R's "axis()" function that uses intersecting axes rather than the ugly stand-alone axes.
intersecting.axis <- function(side, at = NULL, labels = TRUE,
line = NA, pos = NA, outer = FALSE, lty = "solid",
lwd = 1, lwd.ticks = lwd, col = NULL, col.ticks = NULL,
hadj = NA, padj = NA, ...) {
if (! outer) {
x.range <- extendrange(par("usr")[1:2],f=-0.01)
y.range <- extendrange(par("usr")[3:4],f=-0.01)
pos <- NA
xline <- c(NA,NA)
yline <- c(NA,NA)
@gaberoo
gaberoo / 1-metropolis.R
Last active June 25, 2024 18:05
R code to run an **MCMC** chain using a **Metropolis-Hastings** algorithm with a Gaussian proposal distribution. Although there are hundreds of these in various packages, none that I could find returned the likelihood values along with the samples from the posterior distribution. However, if you have these likelihood values, it's very easy to ca…
##############################################################################
# Metropolis-Hastings MCMC
#
# Runs a Metropolis-Hasting MCMC chain for a given likelihood function.
# Proposal steps are sampled from a Gaussian distribution, either in a single
# step or sequentially over the parameter space.
#
# Input:
# theta : starting value of the chain
# lik.fun : likelihood function
@gaberoo
gaberoo / jelly.beans.R
Last active July 12, 2016 17:02
A boxplot replacement that I call the "Jelly Bean Plot".
jelly.beans <- function(data, brewerset = "Set1", cols = brewer.pal(length(data),brewerset),
diffs = rep(NA,length(data)), notches = FALSE,
xlab = NA, ylab = NA, las = rep(0,2), bean.width = c(3,8,3,1,2), ...) {
require(RColorBrewer)
# data = list(grp1=vector(),grp2=vector(),grp3=vector())
# bean.width = c(0.95-lines,0.5-lines,median-line,grid-line)
# diffs = c("A", "A", "B") eg to present TukeyHSD values
do.call(rbind,lapply(1:length(data),function(i) c(i,data[[i]])))
num.grps <- length(data)
grp.names <- names(data)