This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'); | |
var http = require('http'); | |
function log(options) { | |
var info = [options.method, options.path].join(' '); | |
sys.log(info); | |
} | |
function proxy(options, req, res) { | |
return http.request(options, function(proxy_res) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library('pwr') # for power calculations | |
library('foreign') # for dreadful spss .sav files | |
library('psych') # required by phack | |
source('http://rynesherman.com/phack.r') | |
SIM <- 10000 | |
set.seed(42) | |
options(warn=-1) # avoid warning by read.spss | |
############################################ | |
# Simulating p-hacking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models from p. 146 of | |
# http://www.uni-tuebingen.de//uni/sii/pw/heller/statistics_III_ws14/stat5www.pdf | |
# c(model1, model2, model3) | |
aic <- c(8128.519, 8249.935, 8163.826) | |
llh <- c(-4039.260, -4118.967, -4074.913) | |
params <- c(25, 6, 7) | |
# compute the relative distance of each model AIC to the | |
# model with the minimum AIC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library('coda') | |
library('BayesFactor') | |
set.seed(1774) # Laplace easter egg :) | |
contains_zero <- function(interval) { | |
return(interval[1] < 0 && interval[2] > 0) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###### | |
# Homework on Chi² Tests / Loglinear Models on 2x2 tables | |
# | |
# instead of computing it by hand or in R, I wrote | |
# it in Julia, an awesome new language for technical | |
# computing. I discovered it yesterday, and it is | |
# truly intriguing. Do check it out! http://julialang.org/ | |
###### | |
# imports; functions in those modules are global now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library('BayesFactor') | |
# Bayesian version of http://rynesherman.com/phack.r | |
# see also http://osc.centerforopenscience.org/2014/07/02/phack/ | |
bhack <- function(n = 30, hackrate = 10, m1 = 0, m2 = 0, sd1 = 1, sd2 = 1, | |
max_n = 100, bf_cutoff = 3, sims = 1000, graph = TRUE) { | |
out <- matrix(NA, nrow = sims, ncol = 4) | |
for (i in 1:sims) { | |
hackcount <- 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(rvest) | |
require(dplyr) | |
scrape <- function(year, top) { | |
possible <- c(10, 25, 100) | |
if (!top %in% possible) stop("top must be 10, 25 or 100!") | |
if (!year %in% 2012:2014) stop("data available only for years 2012 - 2014") | |
targets <- top[1:which(possible == top)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* empirically tests the complexity of a bogosort based algorithm which | |
* shuffles circles until they don't overlap (for stimulus presentation) | |
* is a function of the circle radius, the canvas width and height | |
* | |
* call it with (first arg is radius, then width and height of canvas) | |
* > node test.js 10 300 500 | |
* > node test.js 10 | |
* etc. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library('shiny') | |
# read this: http://alexanderetz.com/2015/04/15/understanding-bayes-a-look-at-the-likelihood/ | |
shinyApp( | |
ui = shinyUI(fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
sliderInput("p1", label = "p1", | |
min = 0, max = 1, value = 0.7, step = 0.01), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' False Discovery Rate (FDR) | |
#' see also http://www.sciencedirect.com/science/article/pii/S1053811901910377 | |
#' | |
#' Declared active Declared inactive | |
#' Active V_aa V_ai T_a | |
#' Inactive V_ia V_ii T_i | |
#' D_a D_i V | |
#' | |
#' instead of controlling the overall family wise error, we control | |
#' the proportion of false discoveries; that is, we want (V_aa) / (V_aa + V_ia) |
OlderNewer