This file contains 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
<<>>= | |
# 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 |
This file contains 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
### 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, |
This file contains 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
## 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: |
This file contains 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
## 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: |
This file contains 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
### 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") |
This file contains 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
### 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( |
This file contains 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
### 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) |
This file contains 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
### 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: |
This file contains 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
### R code from vignette source 'recoveringcorrelations.Rnw' | |
################################################### | |
### code chunk number 1: recoveringcorrelations.Rnw:93-151 | |
################################################### | |
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, |
This file contains 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(MASS) | |
new.df <- function(cond1.rt=600, effect.size=10, sdev=40, | |
sdev.int.subj=10, sdev.slp.subj=10, | |
rho.u=0.6, | |
nsubj=10, | |
sdev.int.items=10, sdev.slp.items=10, | |
rho.w=0.6, | |
nitems=10) { | |
ncond <- 2 |