2

我已经使用 R 中的包运行了带有随机截距模型的 beta 回归gamlss。调用看起来像:

uik.max.model <- gamlss(formula = max.opp.vote ~ n_commute + vote_commute + uik_dummy +
                      opp.gd + opp.m + pay + govt_dep + higher_ed + max.opp.n +
                      opp.m*vote_commute + opp.m*n_commute +
                      re(random = ~1|mf),
                    family = BE(),
                    data = poll_df)

mf我想从模型对象中提取每个分组因子(

分组因子的每个值的随机截距是否可用?如果有,在哪里?

4

2 回答 2

3

要分析拟合对象的结构,我们可以使用str(uik.max.model). 因此,随机效应可以在 中找到uik.max.model$mu.coefSmo[[1]]$coefficients$random。考虑这个例子:

library(gamlss)
# creating some data
variable <- as.factor(rep(1:26, 1e3))
levels(variable) <- LETTERS
value <- rbinom(2.6e4, 10, .5)
df1 <- data.frame(variable, value)

# fitting a minimal model
fit <- gamlss(formula = value ~ 1 +
              re(random = ~1|variable),
            data = na.omit(df1))

# analyzing structure of fitted object
str(fit)
# ...

# random effects for each value of "variable"
fit$mu.coefSmo[[1]]$coefficients$random
# $variable
# (Intercept)
# A -1.029350e-07
# B -2.465111e-09
# C  1.326496e-07
# D -1.632303e-08
# E  2.731609e-09
# F -4.403887e-08
# G -2.465111e-09
# H -7.695143e-08
# I  2.698297e-08
# J  4.950209e-08
# K -3.191319e-08
# L  9.627257e-08
# M -4.057439e-08
# N  3.737641e-08
# O -1.285855e-08
# P  1.551687e-07
# Q  1.312505e-08
# R -8.907712e-08
# S -9.394071e-09
# T  2.178625e-08
# U -7.661831e-09
# V -1.978751e-08
# W -8.734488e-08
# X  3.737641e-08
# Y -1.285855e-08
# Z -1.632303e-08
于 2018-01-26T10:25:35.777 回答
0

以下可能会有所帮助

summary(getSmo(uik.max.model)) # summary
ranef(getSmo(uik.max.model)) # random effect estimates
coef(getSmo(uik.max.model)) # fitted coefficients
intervals(getSmo(uik.max.model)) # Confidence intervals

请参阅:Stasinopoulos DM、Rigby RA、Heller G.、Voudouris V. 和 De Bastiani F.,(2017 年)灵活回归和平滑:在 R、Chapman 和 Hall/CRC 中使用 GAMLSS。第 10 章

最好的问候凯

于 2018-10-12T13:22:44.513 回答