Chapter 3 Linear regression, Q12
$\beta = \frac{\sum xy}{\sum x^{2}} = \frac{\sum yx}{\sum y^{2}} \\ \sum x^{2} = \sum y^{2}$
For the coefficient estimates of linear regression of Y onto X and X onto Y to be equal, the sum of the squares of X and Y should be equal.
set.seed(1)
x = rnorm(100,mean=0,sd=1)
eps = rnorm(100,mean=0,sd=sqrt(0.25))
y = 4*x+eps
plot(x,y)
lm.model1 = lm(y~x+0)
summary(lm.model1)
lm.model2 = lm(x~y+0)
summary(lm.model2)
We can see that the coefficient estimates of the linear regression of Y onto X and X onto Y are different.
x = rnorm(100,mean=0,sd=1)
y = sample(x,100)
#output True if both are equal
sum(x^2)==sum(y^2)
lm.model1 = lm(y~x+0)
summary(lm.model1)
lm.model2 = lm(x~y+0)
summary(lm.model2)
The coefficients of both models are equal when the sum of square of X and Y are equal.