I have used the solution presented by @StupidWold here to develop a glm
and the results are stored in models
. The outputs seem to be correct. However I am wondering how to present all of the outputs at once instead of calling each one separately. I tried using the stargazer
package but the result is not as neat as I want it to be, mainly the orientation of the html is horizontal rather than vertical (have to scroll to the right).
Here is the code I used for stargazer
asking for an html file output:
stargazer(models, type="html", out = "table1.html", flip = T)
Any suggestions? Thank you.
Maybe my steps will help clarify things, here is the structure of data
FIPSCode<- c(4030,3820,33654,65985,62587,62548)
PRC_W<- c(86.7,56.4,64,52,22,13.6)
MHHI <- c(32564,365265,100000,35467365,353212,3514635132)
abide <- c(0,1,1,0,0,0)
stuff<- c(0,0,0,1,1,0)
takers <- c(1,1,0,1,1,0)
passers <- c(0,1,1,1,0,1)
df <- as.data.frame(cbind(FIPScode, PRC_W, MHHI, abide, stuff, takers, passers))
I assume here that the structure of the data is correct, i.e. categorical data are read as factors and so on.
DV = colnames(df)[4:7]
IV = colnames(df)[2:3]
models = vector("list",length(DV))
names(models) = DV
for (y in DV){
form <- reformulate(response=y,IV)
models[[y]] <- glm(form, data = df, family="binomial")
}
the output of models
is correct because I can call, for example, summary(abide)
and it works perfectly fine.
So my question is how can I look at all the results at once. I have 9000+ DVs and 3 IVs.