'Creating a regression summary table with multiple regressions, adding 1 independent variable at a time (R/Python)
I would like to know, whether there is a pre-built function / package which does a simply OLS regression, by adding one independent variable from a pre-defined set to see, how to coefficients and their significance evolves by adding those variables.
Doing the regressions with a for-loop wouldn't be a problem, but I just wonder whether there is some function for displaying the summary as such, as I see this format very often in academic finance papers.
Attached picture: you can see regression (1) is just a univariate regression with "Mkt-Rf" as independent variable. In regression (2), we add "SMB" and "HML" variables.
Either R or Python package which does this would be great, ideally both. Thank you!
Solution 1:[1]
Have a look at the fixest
package, there you have the option of stepwise estimation tools https://lrberge.github.io/fixest/reference/stepwise.html
Example:
base = iris
names(base) = c("y", "x1", "x2", "x3", "species")
library(fixest)
etable(feols(y ~ sw(x1, x2, x3), base))
Solution 2:[2]
There is the stargazer
package in which creates a table from the regressions.
You can add multiple regressions and it creates the table.
Stargazer Examples
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | ranemak |