Skip to content

Instantly share code, notes, and snippets.

@rmcelreath
Created April 13, 2017 11:22
Show Gist options
  • Save rmcelreath/12cc02883a1ba02452433868275e6d2a to your computer and use it in GitHub Desktop.
Save rmcelreath/12cc02883a1ba02452433868275e6d2a to your computer and use it in GitHub Desktop.
Example of how selecting top 10% of papers can induce negative correlation between positively associated desired features
# berkson's paradox journal example
library(rethinking)
n <- 500
rho <- 0.25
y <- rmvnorm2( n , Mu=c(0,0) , sigma=c(1,1) , Rho=matrix( c(1,rho,rho,1) , 2 , 2 ) )
b <- 1
score <- y[,1] + b*y[,2]
theshold <- quantile( score , 0.9 )
pass <- ( score > theshold )
plot( y , xlab="rigorous" , ylab="innovative" )
plot( y , xlab="rigorous" , ylab="innovative" ,
pch=ifelse(pass,16,1) ,
col=ifelse(pass,"orange","black") )
abline( a=theshold/b , b=-1/b , lwd=0.5 )
cor( y )
cor( y[pass,] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment