Betareg causes memory allocation issue

本秂侑毒 提交于 2021-02-04 19:58:26

问题


I am trying to run a beta regression model in R using the betareg package. However, I am surprisingly running into memory size issue. Let me explain why this surprises me.

I am using Windows 7, 64 Bit, R-64, and have 32 GB in RAM.

The betareg command I am running is::

br1 <- betareg(dfp ~ ago + evl + spe + low + poly(fpt, 4, raw = T), data = tt[tt$zero_one_ind == 1, ], model = T, y = F, x = F)

The object size of the betareg model is:

print(object.size(br1), units = "Mb") 46 Mb

This is the error message I am receiving:

Error: cannot allocate vector of size 344.1 Gb
In addition: Warning messages:
1: In diag(x %*% xwx1 %*% t(x)) :
Reached total allocation of 32693Mb: see help(memory.size)
2: In diag(x %*% xwx1 %*% t(x)) :
 Reached total allocation of 32693Mb: see help(memory.size)
3: In diag(x %*% xwx1 %*% t(x)) :
 Reached total allocation of 32693Mb: see help(memory.size)
4: In diag(x %*% xwx1 %*% t(x)) :
Reached total allocation of 32693Mb: see help(memory.size)

The betareg model successfully ran in R and estimated the coefficients, and as far as I can tell all of the slots are filled, but it looks like R is unable to construct the variance covariance matrix. Any pointers to what is going wrong here?


回答1:


I had the same problem, the solution is quite simple.

From the manual:

Note that the default residuals "sweighted2" might be burdensome to compute in large samples and hence might need modification in such applications.

You could for instance use one of the other options in the summary:

type = c(“pearson”, “deviance”, “response”, “weighted”, “sweighted”, “sweighted2”)




回答2:


I had same problem using betareg. I was only interested in p-values for coefficient significance so this worked for me as a work-around:

fit_frst_spnd_model <- betareg(formula = frst_spnd_util_pc2 ~ .
                        ,data = train_data_frst_txn2_2
                        )
library(lmtest)
coeftest(fit_frst_spnd_model)


来源:https://stackoverflow.com/questions/26369099/betareg-causes-memory-allocation-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!