[R-sig-ME] Warning message after "unscaling" predictor variable

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Tue May 7 23:39:27 CEST 2019


  Quick answer (1): if you get the same likelihood (or very similar,
e.g. difference < 1e-3) for both models, then it should be safe to
disregard the warning.

  (2) If you want to double-check that you're really getting equivalent
results, you can try unscaling the parameters "by hand": this is covered
in the following StackOverflow questions:

https://stackoverflow.com/questions/23642111/how-to-unscale-the-coefficients-from-an-lmer-model-fitted-with-a-scaled-respon/23643740#23643740

https://stackoverflow.com/questions/24268031/unscale-and-uncenter-glmer-parameters

  It would take a few minutes longer than I have right now to dig in and
see what causes the warning (i.e., what combination of
correlation/difference in parameter scales is actually causing the
problem).  My offhand guess would be that it's the centering, not the
scaling, that's important here, but I could be wrong.


On 2019-05-07 5:17 p.m., Rachael Mady wrote:
> Hello,
> 
> I have been successfully using the glmmTMB package, but have come across a
> Warning today that I cannot solve. The data and the code are provided below
> this posting.
> 
> I have been running mixed models with julian date scaled and centered (such
> that it is a z-score; julian2 in the data). Today, I tried to run the same
> models without julian date scaled and centered and received this warning:
> 
> *Warning message:*
> *In nlminb(start = par, objective = fn, gradient = gr, control =
> control$optCtrl) :*
> *  NA/NaN function evaluation*
> 
> To recreate, see the code below. Mod1 is with julian not scaled/centered
> and mod2 is with julian scaled.
> 
> *The data and code to reproduce situation: *
> 
> data <-
> structure(list(sum.50 = c(2L, 1L, 2L, 0L, 0L, 7L, 0L, 6L, 1L,
> 0L, 3L, 8L, 1L, 0L, 2L, 7L, 0L, 0L, 1L, 3L, 2L, 0L, 8L, 9L, 6L,
> 1L, 8L, 8L, 0L, 5L, 0L, 0L, 5L, 3L, 1L, 5L, 2L, 0L, 0L, 2L, 7L,
> 0L, 0L, 7L, 1L, 0L, 5L, 8L, 5L, 3L, 0L, 4L, 8L, 2L, 7L, 0L, 2L,
> 7L, 0L, 1L, 12L, 5L, 0L, 14L, 0L, 5L, 5L, 2L, 6L, 0L, 3L, 1L,
> 0L, 4L, 5L, 1L, 0L, 3L, 9L, 1L, 13L, 0L, 5L, 7L, 8L, 5L, 0L,
> 9L, 11L, 0L, 0L, 4L, 3L, 0L, 4L, 7L, 7L, 7L, 0L, 1L, 5L, 1L),
>     trtmt_simple = structure(c(3L, 1L, 2L, 3L, 1L, 2L, 1L, 2L,
>     3L, 1L, 2L, 3L, 2L, 3L, 1L, 2L, 3L, 1L, 1L, 2L, 3L, 1L, 2L,
>     3L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 2L, 3L,
>     1L, 2L, 3L, 1L, 1L, 2L, 3L, 1L, 2L, 3L, 2L, 3L, 1L, 2L, 3L,
>     1L, 3L, 1L, 2L, 2L, 3L, 1L, 2L, 3L, 1L, 3L, 1L, 2L, 3L, 1L,
>     2L, 1L, 2L, 3L, 1L, 2L, 3L, 3L, 1L, 2L, 3L, 1L, 2L, 1L, 2L,
>     3L, 2L, 3L, 1L, 2L, 3L, 1L, 1L, 2L, 3L, 1L, 2L, 3L, 2L, 3L,
>     1L, 2L, 3L, 1L), .Label = c("control", "constant", "pulsed"
>     ), class = "factor"), site = structure(c(3L, 4L, 5L, 3L,
>     4L, 5L, 8L, 9L, 6L, 8L, 9L, 6L, 1L, 2L, 7L, 1L, 2L, 7L, 4L,
>     5L, 3L, 4L, 5L, 3L, 6L, 8L, 9L, 6L, 8L, 9L, 2L, 7L, 1L, 2L,
>     7L, 1L, 9L, 6L, 8L, 9L, 6L, 8L, 7L, 1L, 2L, 7L, 1L, 2L, 5L,
>     3L, 4L, 5L, 3L, 4L, 6L, 8L, 9L, 1L, 2L, 7L, 1L, 2L, 7L, 3L,
>     4L, 5L, 3L, 4L, 5L, 8L, 9L, 6L, 8L, 9L, 6L, 2L, 7L, 1L, 2L,
>     7L, 1L, 4L, 5L, 3L, 9L, 6L, 8L, 9L, 6L, 8L, 7L, 1L, 2L, 7L,
>     1L, 2L, 5L, 3L, 4L, 5L, 3L, 4L), .Label = c("bakh", "icel",
>     "lid1", "lid2", "lid3", "mtpl", "nemi", "yb01", "yb02"), class =
> "factor"),
>     julian = c(12L, 12L, 12L, 14L, 14L, 14L, 19L, 19L, 19L, 21L,
>     21L, 21L, 26L, 26L, 26L, 28L, 28L, 28L, 33L, 33L, 33L, 35L,
>     35L, 35L, 40L, 40L, 40L, 42L, 42L, 42L, 47L, 47L, 47L, 49L,
>     49L, 49L, 61L, 61L, 61L, 63L, 63L, 63L, 68L, 68L, 68L, 70L,
>     70L, 70L, 75L, 75L, 75L, 77L, 77L, 77L, 84L, 84L, 84L, 89L,
>     89L, 89L, 91L, 91L, 91L, 96L, 96L, 96L, 98L, 98L, 98L, 103L,
>     103L, 103L, 105L, 105L, 105L, 110L, 110L, 110L, 112L, 112L,
>     112L, 119L, 119L, 119L, 124L, 124L, 124L, 126L, 126L, 126L,
>     131L, 131L, 131L, 133L, 133L, 133L, 138L, 138L, 138L, 140L,
>     140L, 140L), julian2 = structure(c(-1.60484310158565,
> -1.60484310158565,
>     -1.60484310158565, -1.55457625178932, -1.55457625178932,
>     -1.55457625178932, -1.42890912729851, -1.42890912729851,
>     -1.42890912729851, -1.37864227750218, -1.37864227750218,
>     -1.37864227750218, -1.25297515301137, -1.25297515301137,
>     -1.25297515301137, -1.20270830321504, -1.20270830321504,
>     -1.20270830321504, -1.07704117872422, -1.07704117872422,
>     -1.07704117872422, -1.0267743289279, -1.0267743289279,
> -1.0267743289279,
>     -0.901107204437083, -0.901107204437083, -0.901107204437083,
>     -0.850840354640757, -0.850840354640757, -0.850840354640757,
>     -0.725173230149941, -0.725173230149941, -0.725173230149941,
>     -0.674906380353615, -0.674906380353615, -0.674906380353615,
>     -0.373305281575658, -0.373305281575658, -0.373305281575658,
>     -0.323038431779332, -0.323038431779332, -0.323038431779332,
>     -0.197371307288516, -0.197371307288516, -0.197371307288516,
>     -0.14710445749219, -0.14710445749219, -0.14710445749219,
>     -0.0214373330013746, -0.0214373330013746, -0.0214373330013746,
>     0.0288295167949516, 0.0288295167949516, 0.0288295167949516,
>     0.204763491082093, 0.204763491082093, 0.204763491082093,
>     0.330430615572909, 0.330430615572909, 0.330430615572909,
>     0.380697465369235, 0.380697465369235, 0.380697465369235,
>     0.506364589860051, 0.506364589860051, 0.506364589860051,
>     0.556631439656377, 0.556631439656377, 0.556631439656377,
>     0.682298564147192, 0.682298564147192, 0.682298564147192,
>     0.732565413943518, 0.732565413943518, 0.732565413943518,
>     0.858232538434334, 0.858232538434334, 0.858232538434334,
>     0.90849938823066, 0.90849938823066, 0.90849938823066, 1.0844333625178,
>     1.0844333625178, 1.0844333625178, 1.21010048700862, 1.21010048700862,
>     1.21010048700862, 1.26036733680494, 1.26036733680494, 1.26036733680494,
>     1.38603446129576, 1.38603446129576, 1.38603446129576, 1.43630131109209,
>     1.43630131109209, 1.43630131109209, 1.5619684355829, 1.5619684355829,
>     1.5619684355829, 1.61223528537923, 1.61223528537923, 1.61223528537923
>     ), .Dim = c(102L, 1L), "`\`scaled:center\``" = 75.8529411764706,
> "`\`scaled:scale\``" = 39.7876534555816)), row.names = c(NA,
> -102L), class = "data.frame")
> 
> # library
> library(glmmTMB)
> 
> # model
> mod1 <- glmmTMB(sum.50 ~ trtmt_simple + julian + (1|site), data = data,
> ziformula=~1, family=nbinom1)
> summary(mod1)
> 
> mod2 <- glmmTMB(sum.50 ~ trtmt_simple + julian2 + (1|site), data = data,
> ziformula=~1, family=nbinom1)
> summary(mod2)
> 
> Thank you very much in advance for your help!
> 
> Cheers,
> Rachael
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



More information about the R-sig-mixed-models mailing list