1

The table data1 has around 350k observations. I would like to estimate the 6 models below and output the results in latex using stargazer.I should specify that y1 is a binary variable and I'm dealing with 100 firms. I'm afraid I don't have any data to post.

Here is my code. The problem is that each estimation is stored in the RAM and there are not enough memory left to run Stargazer.

I'll have two questions?

  1. Is there a way to store the `glm' objects on the disk and then call them back with stargazer?
  2. Does stargazer need the whole 'glm' object to output the latex code.?

    l0 <- glm(y1~ x1 + log(x2)+ x3+ factor(x5)+ factor(firms) ,data=data1, family=binomial(link=logit), model=FALSE)

    l1 <- glm(y1~ x1 + log(x2)+ x3+
                factor(x5)+  x4+factor(firms) ,data = data1,family=binomial(link=logit), model=FALSE)
    
    l2 <- glm(y1~x1 +log(x2)+  x3+ 
                factor(x5)+x4+ factor(x6) + factor(firms), data=data1,family=binomial(link=logit)
              , model=FALSE)
    
    l3 <- glm(y1~x1 +log(x2) + x3+
                factor(x5) + x4+factor(x6)   + x7+ factor(firms)
             ,data = data1,family=binomial(link=logit), model=FALSE)
    
    l4 <- glm(y1~x1 + log(x2) + x3+ 
                factor(x5) +x4+ factor(x6)+ x7+installments + 
                factor(firms) ,data = data1,family=binomial(link=logit), model=FALSE)
    
    l5 <- glm(y1~x1 + log(x2) + x3+ 
                factor(x5) +x4+ factor(x6)+ x7 +installments + x8+
                factor(firms) ,data = data1,family=binomial(link=logit), model=FALSE)
    
    
    stargazer(l0,l1,l2,l3,l4,title="Regression Results with Fixed Effects",     align=TRUE,apply.coef=or
          ,out = "path.tex", covariate.labels=covlabel,omit="firms",
          omit.labels="Firms", omit.yes.no=c("Yes","No"))
    
DJJ
  • 2,481
  • 2
  • 28
  • 53
  • This is currently to vague... no data, no code, no description of the task. You should edit to fix these defects or it may get closed. – IRTFM Mar 22 '14 at 21:44
  • Thanks for the commment. I've updated the my question trying to be more specific. Please free to make any suggestions – DJJ Mar 23 '14 at 10:43
  • Regarding your second question, it looks like the answer here will be helpful: http://stackoverflow.com/questions/26010742/using-stargazer-with-memory-greedy-glm-objects – Jake Fisher Jun 19 '16 at 21:52
  • 1
    As a temporary measure, I added support for speedglm (logistic regressions *only*) to stargazer. You can download it from my GitHub account at https://github.com/jcfisher/stargazer (or use `devtools::install_github("jcfisher/stargazer")`). – Jake Fisher Jun 20 '16 at 15:56
  • Thanks for the info. I'm using [texreg](https://cran.r-project.org/web/packages/texreg/index.html) now as it is more flexible. A solution would be to take what you need from the glm object and create another object, say myglm. then create a function to extract the information from myglm. I would suggest having a look at [this doc](https://www.jstatsoft.org/article/view/v055i08) and [this post](http://stackoverflow.com/questions/24098295/combining-two-tables-and-adding-a-header-for-each-table-in-r/24193452#24193452) – DJJ Jun 20 '16 at 16:10

2 Answers2

1

My approach when faced with this problem is to first convert the *lm object to a "coeftest" class using the lmtest package. For more details, see my answer to a related question here.

Community
  • 1
  • 1
Grant
  • 1,536
  • 13
  • 25
0

As per stargazer manual, it does not support the packages you mention at the time of this writing. As for other options, I would first try running the analysis with the stock lm(). If it does not lead to RAM-related problems, you'll have a choice to make between the speed of estimation and the ease of formatting your table.

You might also choose to contact the developer, asking to add bigglm and speedglm to the feature wish list.

Maxim.K
  • 4,120
  • 1
  • 26
  • 43
  • Thanks for the suggestion. I forgot to mention that I need to estimate a non linear model so as far as I understand, lm cannot do the job. I'll try the wish list. – DJJ Mar 22 '14 at 13:28
  • @DJJ this depends on what you mean by "non-linear". If you mean polynomials (quadratic, cubic terms etc), then lm() will do the job just fine; see poly() function. – Maxim.K Mar 22 '14 at 18:55
  • I was thinking more of a logistic estimation. – DJJ Mar 22 '14 at 20:48