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
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
###### | |
# 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('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
# 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('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
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) { |
NewerOlder