Skip to content

Instantly share code, notes, and snippets.

@cristianounix
Created April 5, 2018 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianounix/4405556fe5fcddddc643d92b31f96d5d to your computer and use it in GitHub Desktop.
Save cristianounix/4405556fe5fcddddc643d92b31f96d5d to your computer and use it in GitHub Desktop.
Generate data correlation
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