I have 3 matrices Y, x1, and x2 each having 3420 rows and 29 columns. I want the row wise linear regression coefficients of Y on x1, x2, and the interaction between x1 and x2 for their corresponding rows such that the regression coefficient term for each of them is of 3420 rows and 1 column.
I tried the following code:
X(i,4)=[ones([28,1]) x1(i,:)' x2(i,:)' (x1(i,:).*x2(i,:))'];
But it is not giving the desired result.
How to get the linear regression coefficients of Y on x1, x2, and interaction between x1, x2 as a 3420 rows and 1 column array?