要分析拟合对象的结构,我们可以使用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