0
votes

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?

1
Please read (1) how do I ask a good question, (2) how to create a MCVE as well as (3) how to provide a minimal reproducible example in R. Then edit and improve your question accordingly. I.e., abstract from your real problem... - Christoph

1 Answers

1
votes

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