How do I print multiple model results with stargazer?

spindoctor Source

I am currently fitting two logistic regression models, from data that look like this:

var1<-sample(c('A', 'B'), size=100, replace=T)
var2<-sample(c('M', 'F'), size=100, replace=T)
var3<-sample(c('Red', 'Blue', 'Yellow'), size=100, replace=T)
df<-data.frame(var1, var2, var3)

However, when I print both using stargazer(), I get an error:

model1<-glm(var1~var2+var3, data=df, family='binomial')
model2<-glm(var1~var2*var3, data=df, family='binomial')
stargazer(model1, model2, type='html')

Error message: number of rows of result is not a multiple of vector length (arg 2)

Now, the above example does not reproduce the error, but I'm at a loss as to how to reproduce it because I don't understand what is going on. It seems like stargazer can't handle the two models I am fitting because one has interactions and the other doesn't, but clearly stargazer can handle that situation; the example above shows it.

I should say, the models are being printed properly in my Rnotebook, but the error message is being printed as well. I have tried message=F and warning=F but those don't seem to work. so my specific questions are:

1) Why is this happening? 2) How could I try to diagnose this? 3) At minimum, how can I suppress this warning message in an R Notebook?



comments powered by Disqus