'R - Gamma distribution - Linear Mixed-Effects Model - lmer/glmer errors

First time asking here so please let me know if anything else is needed to be able to help!

I have analysed my data using lmer() which worked well. I have since realised that a Gamma distribution is more fitting than the Gaussian I am currently using. To be able to use this I believe I have to use the GLMER instead.

I have been trying to run it but am coming across an error I don't understand, and I can't find the answer to googling about. My code currently looks like this;

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

and the error I am getting is;

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

I guess my question is twofold - Is there a way to still use lmer but with a Gamma distribution? What is the error message telling me/how do I fix it?

Many thanks for any help!

Edit; Following comment this is the df output using the first 20 rows

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")


Solution 1:[1]

I was receiving the same error, which was resolved after following Ben Bolker's advice and switching to a log link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Scott Worland