My question is actually pretty basic, so much so I believe it might be an issue with my mathematical literacy than anything else, I'll keep it concise.
I'm creating two random variables from a bivariate normal distribution with mean (1,1) and a covariance matrix as shown below, I add some noise (designated as eps) and then plug these into an equation to form a response variable, Y.
Create two random variables from bivariate distribution.
set.seed(1234)
X =rmvnorm(50, c(1,1), sig=matrix(c(1,-0.8,-0.8,1),2))
Add some noise, create a linear model of these variables:
eps = rnorm(50,mean = 0, sd = 0.25)
Y = 0.5*X[,1] + 3*X[,2] + eps
Plot both data
plot(X[,1], Y, main = "X[,1] vs. Y", xlim =c(-3,5))
plot(X[,2], Y, main = "X[,2] vs. Y", xlim = c(-3,5))
Now, the plots look like this:
This to me is weird. Y is essentially being compared to two random variables, X[,1] and X[,2] that should be very similar numbers - why is it positively correlated with X[,2] and not with X[,1]?
x[,2]
andx[,1]
must be strongly negatively correlated and you constructedy
to be highly correlated withx[,2]
. That doesn't leave much doubt about howy
andx[,1]
must be correlated! $\endgroup$