# Basic Question on Bivariate/Linear Model

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]?

• You may format code using the button with curly brackets rather than the one with the quotation mark (which is intended for quotations). Commented Oct 26, 2016 at 19:26
• You specified that x[,2] and x[,1] must be strongly negatively correlated and you constructed y to be highly correlated with x[,2]. That doesn't leave much doubt about how y and x[,1] must be correlated!
– whuber
Commented Oct 26, 2016 at 19:30
• You mean by adding 3*X[,2], I constructed this correlation myself? I thought 3*X[,2] would only be affecting Y, and not X. Commented Oct 26, 2016 at 20:54
• Ahh I see what you mean, you mean the covariance matrix specifies these correlations. Thanks a lot1 Commented Oct 26, 2016 at 21:27