Dear all,
I have a dataset with 30 stocks. All rows represent different dates. In the columns there is data on things as returns, sentiment etc. The last column represents an indicator as to which stock ('equity') it regards (1 to 30), meaning all stocks are below each other with the dates starting again below each other for every stock. Now I have to run 30 different regressions and predict the residuals for each, and then use these residuals in another regression for every stock specific. Is there a quick way to do this? if so what would be the code? my first regression would be something like: reg equity_return market_return, then I need the residuals of this and use them in the following: reg residuals Twitter_sentiment_daily_avg (for each stock separately thus).
I have a dataset with 30 stocks. All rows represent different dates. In the columns there is data on things as returns, sentiment etc. The last column represents an indicator as to which stock ('equity') it regards (1 to 30), meaning all stocks are below each other with the dates starting again below each other for every stock. Now I have to run 30 different regressions and predict the residuals for each, and then use these residuals in another regression for every stock specific. Is there a quick way to do this? if so what would be the code? my first regression would be something like: reg equity_return market_return, then I need the residuals of this and use them in the following: reg residuals Twitter_sentiment_daily_avg (for each stock separately thus).
Comment