Skip to content

Instantly share code, notes, and snippets.

@wviechtb
Created June 2, 2018 11:32
Show Gist options
  • Save wviechtb/e87ee35ea5544a3a5f875f61e270cd18 to your computer and use it in GitHub Desktop.
Save wviechtb/e87ee35ea5544a3a5f875f61e270cd18 to your computer and use it in GitHub Desktop.
Show density of product-moment correlation as a function of sample size
devtools::install_github("wviechtb/metafor")
library(metafor)
rs <- seq(-1,1,length=1001)
ns <- c(seq(10, 100, 10), 150, 200, 300)
ys <- lapply(ns, function(n) metafor:::.dcor(rs, n, rho=0))
plot(NA, xlim=range(rs), ylim=range(ys), xlab="Correlation", ylab="Density")
invisible(lapply(ys, function(y) lines(rs, y)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment