问题描述
我在Amazon EC2上使用RStudio 0.97.320(R 2.15.3).我的数据框有20万行和12列.
I am using RStudio 0.97.320 (R 2.15.3) on Amazon EC2. My data frame has 200k rows and 12 columns.
我正在尝试使用约1500个参数来拟合逻辑回归.
I am trying to fit a logistic regression with approximately 1500 parameters.
R使用7%的CPU,并具有60 + GB的内存,并且仍需要很长时间.
R is using 7% CPU and has 60+GB memory and is still taking a very long time.
这是代码:
glm.1.2 <- glm(formula = Y ~ factor(X1) * log(X2) * (X3 + X4 * (X5 + I(X5^2)) * (X8 + I(X8^2)) + ((X6 + I(X6^2)) * factor(X7))),
family = binomial(logit), data = df[1:150000,])
有什么建议可以大大提高速度吗?
Any suggestions to speed this up by a significant amount?
推荐答案
您可以尝试使用speedglm
包中的speedglm
函数.我还没有在您描述的问题上使用过它,但是特别是如果您安装了BLAS库(如评论中的@Ben Bolker建议),它应该易于使用并给您带来不错的减速效果.
You could try the speedglm
function from the speedglm
package. I haven't used it on problems as large as you describe, but especially if you install a BLAS library (as @Ben Bolker suggested in the comments) it should be easy to use and give you a nice speed bump.
我记得看到有一个基准测试glm
和speedglm
的表,带有和不带有经过性能调整的BLAS库,但是我今天似乎找不到它.我记得那使我相信我都想要.
I remember seeing a table benchmarking glm
and speedglm
, with and without an performance-tuned BLAS library, but I can't seem to find it today. I remember that it convinced me that I would want both.
这篇关于如何加快GLM估算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!