Created
April 5, 2018 17:41
-
-
Save cristianounix/4405556fe5fcddddc643d92b31f96d5d to your computer and use it in GitHub Desktop.
Generate data correlation
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
make_data_corr = function(corr, n){ | |
x = rnorm(n,0,1) | |
y = rnorm(n,0,1) | |
a = corr/(1-corr^2)^0.5 | |
z=a*x+y | |
the_data = data.frame(x,z) | |
return(the_data) | |
} | |
data=make_data_corr(0.99,50) | |
plot(data$x,data$z) | |
title(main = "Correlação de 0.99 ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment