Problems with binning data

I learned early on in my PhD that binning is not a good idea. The loss of information from binning will lead to biased results. Here I demonstrate this with a simple linear regression toy model. #generate toy data x = runif(nc, 13,15) y = 22+1.5*x+rnorm(nc, 0,0.5) #bin in y variable nbin = 10 ybins…