Hi ~ I want to ask a quick question related to regression analysis in python. I have the following dataframe
:
group Y X
1 9 3
1 5 4
1 3 1
2 1 6
2 2 4
2 3 9
Y is dependent and X is independent variable. I want to run regression Y=a + bx
by group and output another dataframe
that contains the coefficients, t-stats and R-square. So, the dataframe should be like:
group coefficient t-stats intercept r-square
1 0.25 1.4 4.3 0.43
2 0.30 2.4 3.6 0.49
... ... ... ... ...
Can someone help ? Many thanks in advance for your help.