0

I ran some multivariate multiple regression models by combining the multiple dependent variables with cbind() in lm():

dv1 <- rnorm(15)
dv2 <- rnorm(15)
dv3 <- rnorm(15)
iv1 <- rnorm(15)
iv2 <- rnorm(15)

m1 <- lm(cbind(dv1, dv2, dv3) ~ iv1 + iv2)  

I need a classic publication table for my models with significance stars, etc, and usually use stargazer for that. I think it gives me an error message because of the multiple DVs.

library(stargazer)
stargazer(mmr1, type = "html")

The error is: "Error in if (.global.coefficient.variables[i] %in% .global.intercept.strings) { : argument is of length zero"

The package updated to the most current version (that was what solved a similar stargazer error in another question) and if I run the same model with only one dependent variable, I do not get an error message.

I couldn't find any threads specifically targeted at getting multivariate regression results plotted in a publication table, only multiple regression models.

Can anyone give me a tip here? Which function goes well with multivariate models that provide a publication table similar to the stargazer ones?

stm
  • 1
  • 1
  • Please read [(1)](https://stackoverflow.com/help/how-to-ask) how do I ask a good question, [(2)](https://stackoverflow.com/help/mcve) how to create a MCVE as well as [(3)](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... – Christoph Oct 13 '21 at 14:41

1 Answers1

1

Consider running the three models individually and combine them later in the stargazer command.

m1 <- lm(dv1 ~ iv1 + iv2)  
m2 <- lm(dv2 ~ iv1 + iv2) 
m3 <- lm(dv3 ~ iv1 + iv2) 
stargazer(m1,m2,m3, type = "html")

sample output when using "text" option:

===========================================================
                                   Dependent variable:     
                              -----------------------------
                                 dv1       dv2       dv3   
                                 (1)       (2)       (3)   
-----------------------------------------------------------
iv1                            -0.135    -0.230     0.104  
                               (0.352)   (0.366)   (0.521) 
                                                           
iv2                             0.198    -0.079     0.392  
                               (0.322)   (0.335)   (0.477) 
                                                           
Constant                       -0.306    -0.192    -0.394  
                               (0.212)   (0.220)   (0.314) 
                                                           
-----------------------------------------------------------
Observations                     15        15        15    
R2                              0.062     0.032     0.054  
Adjusted R2                    -0.094    -0.129    -0.103  
Residual Std. Error (df = 12)   0.810     0.842     1.199  
F Statistic (df = 2; 12)        0.399     0.198     0.344  
===========================================================
Note:                           *p<0.1; **p<0.05; ***p<0.01
pascal
  • 1,036
  • 5
  • 15
  • Hi Pascal, thank you very much for your answer! If I do that, however, I would not account for the intercorrelations between the dependent variables, which I attempted to do by running the multivariate multiple regression ... Do you know any solution that still takes the intercorrelation between the dependent variables into account? – stm Oct 13 '21 at 15:17
  • I'm not sure if I understand you correctly. My answer presents you a way to summarize the model you are suggesting 'm1 <- lm(cbind(dv1, dv2, dv3) ~ iv1 + iv2)' using stargazer. Compare 'summary(m1)' to the above output. It is identical. In case this is more a statistical question, please consider asking it on https://stats.stackexchange.com/. – pascal Oct 13 '21 at 15:27
  • My fault - I mixed something up - you are right, they are identical! Thank you very much! – stm Oct 13 '21 at 18:07
  • Ok. Welcome. Maybe accept my answer or give it an upvote. – pascal Oct 13 '21 at 18:31