0

I have a dataframe/list containing regression results and want to perform coefficient tests (coeftest in R) on everyone of them from the original regression.

Example code:

coef1 <- coeftest(Regression_ret$coef1, vcov = NeweyWest)
coef2 <- coeftest(Regression-res$coef2, vcov = NeweyWest)
coef3 <- coeftest(Regression_res$coef3, vcov = NeweyWest)
coef4 <- coeftest(Regression_res$coef4, vcov = NeweyWest)
coef5 <- coeftest(Regression_res$coef5, vcov = NeweyWest)
coef6 <- coeftest(Regression_res$coef6, vcov = NeweyWest)          
coef7 <- coeftest(Regression_res$coef7, vcov = NeweyWest)
coef8 <- coeftest(Regression_res$coef8, vcov = NeweyWest)      
coef9 <- coeftest(Regression_res$coef9, vcov = NeweyWest)

Is there any method to avoid doing it line by line and instead do multiple coefs by writing one line of code. Or as an alternative do a for loop that performs coeftest on all coefficients in a dataframe/list and then store them in a new dataframe so that I can use Stargazer to create a table.

Andycode
  • 171
  • 1
  • 1
  • 10
  • 5
    Maybe `lapply(Regression_ret, function(x) coeftest(x, vcov = NeweyWest))`. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Apr 27 '20 at 08:14
  • I’ve read texreg package is a superior option to stargazer for tables. – Mark Neal Apr 27 '20 at 10:04
  • That works! Thank you @MrFlick. Follow-up question: Do you know if there is any way to convert the coeftest list (result of your code) into a dataframe (i want to subtract variables starting with the same letters into a new list or dataframe for Stargazer table purposes..) E.g all variables starting with letters X subsetted into a new list or dataframe, and all starting with Y subsetted into another list or dataframe. – Andycode Apr 27 '20 at 10:49

0 Answers0