将Stargazer与内存贪婪的glm对象一起使用 [英] Using stargazer with memory greedy glm objects

查看:122
本文介绍了将Stargazer与内存贪婪的glm对象一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进行以下回归分析:

I'm trying to run the following regression:

m1=glm(y~x1+x2+x3+x4,data=df,family=binomial())
m2=glm(y~x1+x2+x3+x4+x5,data=df,family=binomial())
m3=glm(y~x1+x2+x3+x4+x5+x6,data=df,family=binomial())
m4=glm(y~x1+x2+x3+x4+x5+x6+x7,data=df,family=binomial())

,然后使用 stargazer 软件包进行打印:

and then to print them using the stargazer package:

stargazer(m1,m2,m3,m4 type="html", out="models.html")

事实是,数据帧df很大(〜600MB),因此我创建的每个glm对象至少约为〜1.5GB. 这会导致内存问题,使我无法创建需要在 stargazer 中打印的所有回归.

Thing is, the data frame df is rather big (~600MB) and thus each glm object I create is at least ~1.5GB. This creates a memory issue which prevents me from creating all the regressions I need to print in stargazer.

为了减少glm对象的大小,我尝试了2种方法:

I've tried 2 approches in order to decrease the size of the glm objects:

  1. 使用教程.实际上,尽管从stargazer函数中收到以下错误,但确实将glm对象修剪为< 1MB:
  1. Trim the glm object using this tutorial. This indeed trims the glm object to <1MB, though I get the following error from the stargazer function:

Error in Qr$qr[p1, p1, drop = FALSE] : incorrect number of dimensions

  1. 使用软件包 speedglm .但是, stargazer 不支持此功能.
  1. Use the package speedglm. however, it's not supported by stargazer.

有什么建议吗?

推荐答案

stargazer调用需要qrsummary(请参见源代码).因此,据我所知,这是不可能的.

The stargazer calls summary which requires qr (see source code). So -- as far as I know -- it is not possible.

但是我认为重写stargazer来处理摘要列表作为输入应该很容易.这将非常方便.

BUT I think that it should be easy to rewrite stargazer to handle a list of summaries as an input. It would be extremely handy.

这篇关于将Stargazer与内存贪婪的glm对象一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆