【发布时间】:2017-11-27 09:08:14
【问题描述】:
我正在使用lme4 构建协作过滤器并遇到收敛问题。尝试通过以下资源解决并得到一个新的错误:
ans.ret[meth, ] 中的错误 要替换的项目数不是替换长度的倍数
这是在模型运行约 48 小时后趋于收敛。
- https://rstudio-pubs-static.s3.amazonaws.com/33653_57fc7b8e5d484c909b615d8633c01d51.html
-
https://stats.stackexchange.com/questions/242109/model-failed-to-converge-warning-in-lmer
注意:optimx nlmimb 似乎最好,然后是 L-BFGS-B
我有一个结构如下的模型:
library(lme4); library(optimx)
library(stringi)
library(data.table)
set.seed(1423L)
# highly imbalanced outcome variable
y <- sample.int(2L, size= 910000, replace=T, prob= c(0.98, 0.02)) - 1L
# product biases
prod <- sample(letters, size= 910000, replace=T)
# user biases
my_grps <- stringi::stri_rand_strings(n= 35000, length= 10)
grps <- rep(my_grps, each= 26)
x1 <- sample.int(2L, size= 910000, replace=T, prob= c(0.9, 0.1)) - 1L
x2 <- sample.int(2L, size= 910000, replace=T, prob= c(0.9, 0.1)) - 1L
x3 <- sample.int(2L, size= 910000, replace=T, prob= c(0.9, 0.1)) - 1L
x4 <- sample(LETTERS[1:5], size= 91000, replace=T)
dt <- data.table(y= y,
prod= prod, grps= grps,
x1= x1, x2= x2, x3= x3, x4= x4)
lmer1 <- glmer(y ~ -1 + prod + x1 + x2 + x3 + x4 + (1|grps),
data= dt, family= binomial(link= "logit"),
control = glmerControl(optimizer ='optimx', optCtrl=list(method='nlminb')))
我不保证以上数据会重现错误;但这就是模型设置。我根本不明白错误信息。任何帮助将不胜感激
注意:在我的真实用例中,我有接近 1550 万次观察和 30-50 种产品,其中每种产品的平均响应率不同 (y)
我还从 kNN 方法(典型的协同过滤器)切换到 HLM,因为 R 已针对 kNN 进行了大规模优化——应该使用类似 annoy 的东西,我还没有尝试过。
【问题讨论】:
-
只是对尝试重现您的示例的评论,您对
sample.int的所有调用都包含probs参数,但sample.int的基本版本中的参数是prob(即没有@ 987654334@) -
@DouglasBates -- 谢谢,将编辑/已编辑
-
使用 Julia 的
MixedModels包拟合这样的模型没有问题 -
我会遇到一些麻烦,因为据我所知,
ans.ret根本没有出现在我们的代码库中...... -
是的,在
optimx:::optimx.run
标签: r lme4 collaborative-filtering convergence