[ADMB Users] Fwd: glmmADMB predict with negative binomial

328 views
Skip to first unread message

jnancheta

unread,
Dec 10, 2014, 7:36:37 PM12/10/14
to us...@admb-project.org

---------- Forwarded message ----------
From: <sheryn...@maine.edu>
Date: Fri, Nov 28, 2014 at 8:26 AM
Subject: glmmADMB predict with negative binomial
To: admb-use...@googlegroups.com


Hello, May I post a question?

I would like to plot a predictive graph of hare pellet count response vs. conifer saplings.

It is unclear to me what predict.glmmADMB extracts when the family is nbinom, with log-link.

The documentation says
[type   Whether to return predictions on the scale of the linear predictor ("link") or the scale of the data ("response")]

Does that mean specifying      type = "link"    will extract exponentiated fits?
Or do I exponentiate the fit AFTER it is extracted by predict?

R-code follows
    Call:
    glmmadmb(formula = pellets ~ season * t.con.splgs + offset(ln.days) +
        (1 | stand/plot) + (1 | hareyr), data = hv, family = "nbinom")
    AIC: 8391.6
    Coefficients:
                              Estimate Std. Error z value Pr(>|z|)
    (Intercept)               -4.67230    0.17840  -26.19  < 2e-16 ***
    season[T.smr]             -0.23872    0.09559   -2.50  0.01251 *
    t.con.splgs                0.01686    0.00447    3.77  0.00016 ***
    season[T.smr]:t.con.splgs -0.01653    0.00402   -4.12  3.8e-05 ***


and
    ## prepare predictive dataframe:
    ## Conifer saplings, wi is winter intercept
    ##  and predict pellets based on square root transformed conifer saplings/0.1 ha

    predctCSwi <- data.frame(
                  t.con.splgs = rep(seq(from = min(hv$t.con.splgs),
                                          to = max(hv$t.con.splgs),length.out = 100),2),
                  ln.days=rep(log(30.25),200),   ###### account for month
                  season = factor(rep(1:2, each = 100),
                  levels = 1:2, labels=levels(hv$season)))

    predctCSwi <- cbind(predctCSwi, predict(wi.tconsplgs, predctCSwi, type = "link", se.fit=TRUE))
    head(predctCSwi)
  t.con.splgs  ln.days season       fit    se.fit
1   0.0000000 3.409496    wtr -1.262801 0.1784000
2   0.7142493 3.409496    wtr -1.250759 0.1784448
3   1.4284985 3.409496    wtr -1.238718 0.1785467
4   2.1427478 3.409496    wtr -1.226676 0.1787054
5   2.8569971 3.409496    wtr -1.214635 0.1789210
6   3.5712464 3.409496    wtr -1.202593 0.1791931

# Then scale up to pellets/ha/month (phm)
#  and backtransform saplings to per 0.1 ha by squaring the square-root values
    predctCSwi <- within(predctCSwi, {
       pellets <- exp(fit)
       phm <- pellets/1.5*10000
        LLha <- (exp(fit - 1.96 * se.fit))/1.5*10000
        ULha <- (exp(fit + 1.96 * se.fit))/1.5*10000
        con.splgs.1ha <- (t.con.splgs^2)
     })


Thank you,
Sheryn Olson


Ben Bolker

unread,
Dec 10, 2014, 7:47:55 PM12/10/14
to us...@admb-project.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14-12-10 07:35 PM, jnancheta wrote:
> ---------- Forwarded message ---------- From:
> <sheryn...@maine.edu> Date: Fri, Nov 28, 2014 at 8:26 AM
> Subject: glmmADMB predict with negative binomial To:
> admb-use...@googlegroups.com
>
>
> Hello, May I post a question?
>
> I would like to plot a predictive graph of hare pellet count
> response vs. conifer saplings.
>
> It is unclear to me what predict.glmmADMB extracts when the family
> is nbinom, with log-link.
>
> The documentation says [type Whether to return predictions on the
> scale of the linear predictor ("link") or the scale of the data
> ("response")]
>
> Does that mean specifying type = "link" will extract
> exponentiated fits? Or do I exponentiate the fit AFTER it is
> extracted by predict?

using type="response" will give you the exponentiated fits; using
type="link" will give you the results on the log scale
(I will say that in general you should be able to look at the results
and make a pretty good guess -- for example, any negative values
indicate for sure that you're still on the log scale ...)
> _______________________________________________ Users mailing list
> Us...@admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJUiOlwAAoJEOCV5YRblxUHD6kIANXL+5XZ8xoMmjaIvw24pCMt
gWbVvB9R8gMVAMgAxnknb/I9wtmxK8gPkSPRD/KlAKM/AY1SDKip2RQu8YDbwVvA
8WxxyVLUgT4jflVewwhQ1fGUCOyG3amaDX9mM4mBj+cSGM/GpyFLnmHlKOAYA8x+
TTwa2c+NkEDZMrpWAuIRAgiWCKr8zj0aLrkqVn0MSJ6lJSuRLreovWTOwtWiq8tq
w6b8rzy3zdIQ7d3mzpF92fQUel+uLPUUZuLsBtXCyCMPWDc/X+9s5THrIGgiTtGF
HZMvaS/HAg303MlQdu++iexNC9YRh7BsayI4VVGYh+VnJgXtoHN31nREeXPVGTA=
=g8RD
-----END PGP SIGNATURE-----
_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users
Reply all
Reply to author
Forward
0 new messages