首页 > 解决方案 > R - Gamma 分布 - 线性混合效应模型 - lmer/glmer 错误

问题描述

第一次在这里问,所以请让我知道是否需要其他任何帮助!

我已经分析了我的数据,使用lmer()效果很好。从那以后,我意识到伽玛分布比我目前使用的高斯分布更合适。为了能够使用它,我相信我必须改用 GLMER。

我一直在尝试运行它,但遇到了一个我不明白的错误,我找不到谷歌搜索的答案。我的代码目前看起来像这样;

glmer(primordial.cm ~ sr * bw + (1|litter) + sw + sa, data = counts, na.action = na.exclude, family=Gamma)

我得到的错误是;

Error in pwrssUpdate(pp, resp, tol = tolPwrss, GQmat = GQmat, compDev = compDev,  : 
  PIRLS loop resulted in NaN value

我想我的问题是双重的 - 有没有办法仍然使用lmer但使用 Gamma 分布?错误消息告诉我/我该如何解决?

非常感谢您的帮助!

编辑; 以下评论是df使用前 20 行的输出

dput(head(counts, 20))
structure(list(tag = structure(c(1L, 3L, 7L, 32L, 24L, 2L, 4L, 
8L, 9L, 13L, 33L, 37L, 36L, 38L, 39L, 27L, 28L, 10L, 11L, 12L
), .Label = c("1137", "1140", "1257", "1258", "16", "17", "1882", 
"1883", "1912", "1920", "1921", "1923", "1928", "210", "212", 
"22", "222", "24", "250", "312", "3655", "391", "403", "471", 
"478", "479", "482", "483", "484", "490", "502", "5620", "5650", 
"5688", "6627", "Y558", "Y649", "Y862", "Y869"), class = "factor"), 
    bw = c(1.47, 1.63, 2.4, 1.51, 1.43, 1.39, 1.67, 
    2.18, 1.02, 1.9, 1.32, 1.1, 1.48, 1.25, 1.45, 1.46, 1.43, 
    1.81, 1.36, 1.37), sw = c(96.2, 96.1, 106.6, 
    114.64, 106.1333, 97.4, 102.6, 109, 114.2, 119.32, 109.8714, 
    NA, NA, NA, NA, 108.27, 109.5333, 117.45, 116.76, 107.66), 
    litter = c("3", "5", "11", "9", "6", "3", "5", "11", "1", 
    "1", "9", "21", "21", "20", "20", "10", "10", "7", "12", 
    "12"), sa = c(155, 154, 160, 172, 180, 155, 154, 
    160, 167, 167, 179, 174, 174, 174, 174, 174, 181, 168, 168, 
    175), sex.ratio... = c(70L, 75L, 75L, 53L, 47L, 70L, 75L, 
    75L, 27L, 27L, 53L, 71L, 71L, 50L, 50L, 47L, 47L, 46L, 50L, 
    50L), sr = c(0.7, 0.75, 0.75, 0.53, 0.47, 0.7, 0.75, 
    0.75, 0.27, 0.27, 0.53, 0.71, 0.71, 0.5, 0.5, 0.47, 0.47, 
    0.46, 0.5, 0.5), bias = structure(c(3L, 3L, 3L, 2L, 2L, 3L, 
    3L, 3L, 1L, 1L, 2L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Male-biased", 
    "Non-biased", "Female-biased"), class = "factor"), primordial.cm = c(114.6903044, 
    47.31075931, 117.9993577, 57.00768991, 21.14809511, 100.2912585, 
    48.62879289, 163.7782553, 420.2023737, 22.90648124, 155.5015055, 
    134.0178424, 37.92752873, 20.88138829, 50.34685719, 105.6690685, 
    113.7977974, 77.58597154, 53.58654997, 73.89749036), ), row.names = c(NA, 20L), class = "data.frame")

标签: rglmlme4gamma-distribution

解决方案


推荐阅读