Skip to content

Instantly share code, notes, and snippets.

View vasishth's full-sized avatar
💭
My status is high.

Shravan Vasishth vasishth

💭
My status is high.
View GitHub Profile
@vasishth
vasishth / gist:9bef6eac226c4d17f931
Created October 7, 2014 18:39
Paris Lecture 1 code
### R code from vignette source '01_ADAIntroLecture.Rnw'
###################################################
### code chunk number 1: 01_ADAIntroLecture.Rnw:134-141
###################################################
## load data:
data<-read.table("~/Git/Statistics-lecture-notes-Potsdam/AdvancedDataAnalysis/data/gibsonwu2012data.txt",header=T)
## take reciprocal rt to normalize residuals:
data$rrt<- -1000/data$rt
## define predictor x:
### R code from vignette source '02_ADALecture2.Rnw'
###################################################
### code chunk number 1: 02_ADALecture2.Rnw:66-72
###################################################
library(mvtnorm)
u0 <- u1 <- seq(from = -3, to = 3, length.out = 30)
Sigma1<-diag(2)
f <- function(u0, u1) dmvnorm(cbind(u0, u1), mean = c(0, 0),sigma = Sigma1)
z <- outer(u0, u1, FUN = f)
@vasishth
vasishth / ParisLecture3.R
Created October 14, 2014 20:49
Paris lecture 3 code
### R code from vignette source '03_ADALecture3.Rnw'
###################################################
### code chunk number 1: 03_ADALecture3.Rnw:85-92
###################################################
data<-read.table("~/Git/Statistics-lecture-notes-Potsdam/AdvancedDataAnalysis/data/gibsonwu2012data.txt",header=T)
## take reciprocal rt to normalize residuals:
data$rrt<- -1000/data$rt
## define predictor x:
data$x <- ifelse(
@vasishth
vasishth / ParisLecture4.R
Created October 17, 2014 05:25
Paris Lecture 4
### R code from vignette source '04_ADALecture4.Rnw'
###################################################
### code chunk number 1: 04_ADALecture4.Rnw:67-72
###################################################
vpost<-function(v=0.2609^2,n=1,s=0.15^2){
return(1/((1/v)+n/s))
}
n<-seq(1,1000,by=1)
plot(n,vpost(v=2600,n=n),type="l",ylab="posterior variance",xlab="sample size")
@vasishth
vasishth / falsepositives.R
Last active August 29, 2015 14:10
False positives in a scientist's lifetime
## store proportion of false positives
## in one lifetime of 200 experiments:
prop_fps<-rep(NA,1000)
## run k=1000 scientists, each with
## a lifetime of 200 experiments:
for(k in 1:1000){
## number of experiments for each scientist:
nexp<-200
## prob of sampling from a population
## where the null is true:
@vasishth
vasishth / falsepositivesversion2.R
Last active September 27, 2015 11:02
False positives in a lifetime [revised 23 Nov 2014; comments and corrections welcome]
## Our simulated scientist will declare
## significance only if he/she gets
## 2 replications with p<0.05:
stringent<-FALSE
## Set the above to FALSE if you want to
## have the scientist publish a single
## expt. as soon as it's significant:
#stringent <- FALSE
## num of scientists to simulate:
@vasishth
vasishth / recoveringcorrelationsV2.R
Created November 25, 2014 08:25
Maximal models in linear mixed models
### R code from vignette source 'recoveringcorrelationsV2.Rnw'
###################################################
### code chunk number 1: recoveringcorrelationsV2.Rnw:98-156
###################################################
new.df <- function(cond1.rt=487, effect.size=123,
sdev=544,
sdev.int.subj=160, sdev.slp.subj=195,
rho.u=0.6,
nsubj=37,
@vasishth
vasishth / ranking.Rnw
Created November 25, 2014 18:20
hospital rankings
<<>>=
# n: no of operations
# x: no of deaths
# N: no of hospitals
dat<-list(n=c(47,211,810,148,196,360,119,207,97,
256,148,215),
x=c(0,8,46,9,13,24,8,14,8,29,18,31),
N=12)
cat("model
@vasishth
vasishth / vincentgranville.txt
Created December 15, 2014 08:36
vincentgranville.txt
“He seems to have a solid stats background back in the day”
A lot of people claim a lot of things about themselves. I have met a lot of people who characterize themselves as “fluent in Japanese” (oddly, these are always Americans), where their actual on-the-ground fluency level is pretty laughable.
I couldn’t find any clear statements about what his educational background is. He says on his linkedin page: “Facultés universitaires ‘Notre-Dame de la Paix’ Ph.D., Statistics, Mathematics, Science, 1983 – 1993″, Then he lists two courses he did there, “Stochastic Geometry, Markov Processes.” I find it odd that a guy does a PhD somewhere, over 10 years, and lists two courses under that PhD.
Also, I searched for this mysterious uni I have never heard of: Facultés universitaires ‘Notre-Dame de la Paix.
I ended up at a weird Jesuits page in Belgium:
@vasishth
vasishth / typesm
Created August 27, 2015 13:03
Simulating Type S and Type M errors
## probable effect size derived from past studies:
D<-15
## SE from the study of interest:
se<-46
stddev<-se*sqrt(37)
nsim<-10000
drep<-rep(NA,nsim)
for(i in 1:nsim){
drep[i]<-mean(rnorm(37,mean=D,sd=stddev))
}