Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set.seed(421) # for reproducibility
- m = 20000; n = 5
- par(mfrow=c(1,3))
- x = rnorm(m*n); DTA = matrix(x, nrow=m)
- a = rowMeans(DTA); s = apply(DTA, 1, sd)
- plot(a, s, pch=".", main="Standard Normal")
- cor(a,s)
- [1] -0.001354763 # consistent with 0
- x = rexp(m*n); DTA = matrix(x, nrow=m)
- a = rowMeans(DTA); s = apply(DTA, 1, sd)
- plot(a, s, pch=".", main="Standard Exponential")
- cor(a,s)
- [1] 0.7695967
- x = rbeta(m*n, .1,.1); DTA = matrix(x, nrow=m)
- a = rowMeans(DTA); s = apply(DTA, 1, sd)
- plot(a, s, pch=".", main="Standard Normal")
- cor(a,s)
- [1] -0.008673277 # consistent with 0
- par(mfrow=c(1,1))
- set.seed(2019)
- m = 10^4 # for good graph, don't use too many
- # for accurate est of r, use very many
- x = runif(m); x1 = (x<.3); x2 = (x>=.8)
- cor(x1, x2)
- [1] -0.327649
- jit1 = runif(m, -.25, .25); jit2 = runif(m, -.25, .25)
- plot(x1+jit1, x2+jit2, pch=".")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement