glmmLasso-二项式

时间:2019-06-29 12:40:45

标签: r mixed-models

我正在使用lme4软件包编写一些混合效果模型。我找到了glmmLasso软件包,并认为我会尝试做一些比较。我拥有的真实数据有“试验和成功”总数栏,以及一些固定和随机影响。

我正在努力仅将glmmLasso函数用于仅具有一种固定效果而没有随机效果的基本情况。数据是私有的,因此模拟了一些随机数以突出显示我得到的错误。任何建议都很好! :)

# fake data, to capture error for minimal e.g.
set.seed(1)
N <- 50
dt <- data.frame(total = as.integer(round(rnorm(50, 100, 10), 0)))
dt$success <- as.integer(round(dt$total * rbeta(N, 20, 160), 0))
dt$x <- runif(N, 0, 1)
plot(dt$x, dt$success/dt$total)

# using glm structure, works ok
glm_mod <- glm(cbind(success, total-success) ~ x, data=dt, family=binomial())
summary(glm_mod)

# In my real data I want to build a mixed effects model, been using glmer
# but wanted to see how it compares with one with fixed effects regularisation
# From documentation looks like its structured similar to glm, but can't get a
# basic model to work for binomial family
library(glmmLasso)
las_mod <- glmmLasso(cbind(success, total-success) ~ x, rnd=NULL, 
                     data=dt, family=binomial(), lambda=1)

# in details, it accepts a two column integer matrix of success and failures
?binomial

0 个答案:

没有答案