Skip to content

Instantly share code, notes, and snippets.

View sachsmc's full-sized avatar

Michael Sachs sachsmc

View GitHub Profile
favre <- function(model, coeff.index){
favre2 <- matrix(c(1, -1, 0, 0,
1, 0, -1, 0,
1, 0, 0, -1
), nrow = 3, ncol = 4, byrow = T)
theta.hat <- favre2 %*% as.matrix(model$coeff[coeff.index])
cov.hat <- favre2 %*% vcov(model)[coeff.index, coeff.index] %*% t(favre2)
@sachsmc
sachsmc / myBoxplot.R
Last active January 1, 2016 05:19
Boxplot with quantile whiskers
myboxplot <- function(datalist, quantiles = c(.1, .9), names, ...){
bp <- boxplot(datalist, plot = FALSE)
quants <- sapply(datalist, function(df){
quantile(df, quantiles, na.rm = T)
cibars <- function(x, y, y.se, tinyfactor = 50, ...){
lower <- y - 1.96*y.se
upper <- y + 1.96*y.se
segments(x0 = x, y0 = lower, x1 = x, y1 = upper, ...)
tinybarwidth <- (max(x) - min(x))/tinyfactor
segments(x0 = x - tinybarwidth, y0 = lower, x1 = x + tinybarwidth, y1 = lower, ...)
segments(x0 = x - tinybarwidth, y0 = upper, x1 = x + tinybarwidth, y1 = upper, ...)