<div dir="ltr"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername"></b> <span dir="ltr"><<a href="mailto:sheryn.olson@maine.edu">sheryn.olson@maine.edu</a>></span><br>Date: Fri, Nov 28, 2014 at 8:26 AM<br>Subject: glmmADMB predict with negative binomial<br>To: <a href="mailto:admb-users%2Bowners@googlegroups.com">admb-users+owners@googlegroups.com</a><br><br><br>Hello, May I post a question?<br>
<br>
I would like to plot a predictive graph of hare pellet count response vs. conifer saplings.<br>
<br>
It is unclear to me what predict.glmmADMB extracts when the family is nbinom, with log-link.<br>
<br>
The documentation says<br>
[type Whether to return predictions on the scale of the linear predictor ("link") or the scale of the data ("response")]<br>
<br>
Does that mean specifying type = "link" will extract exponentiated fits?<br>
Or do I exponentiate the fit AFTER it is extracted by predict?<br>
<br>
R-code follows<br>
Call:<br>
glmmadmb(formula = pellets ~ season * t.con.splgs + offset(ln.days) +<br>
(1 | stand/plot) + (1 | hareyr), data = hv, family = "nbinom")<br>
AIC: 8391.6<br>
Coefficients:<br>
Estimate Std. Error z value Pr(>|z|)<br>
(Intercept) -4.67230 0.17840 -26.19 < 2e-16 ***<br>
season[T.smr] -0.23872 0.09559 -2.50 0.01251 *<br>
t.con.splgs 0.01686 0.00447 3.77 0.00016 ***<br>
season[T.smr]:t.con.splgs -0.01653 0.00402 -4.12 3.8e-05 ***<br>
<br>
<br>
and<br>
## prepare predictive dataframe:<br>
## Conifer saplings, wi is winter intercept<br>
## and predict pellets based on square root transformed conifer saplings/0.1 ha<br>
<br>
predctCSwi <- data.frame(<br>
t.con.splgs = rep(seq(from = min(hv$t.con.splgs),<br>
to = max(hv$t.con.splgs),length.out = 100),2),<br>
ln.days=rep(log(30.25),200), ###### account for month<br>
season = factor(rep(1:2, each = 100),<br>
levels = 1:2, labels=levels(hv$season)))<br>
<br>
predctCSwi <- cbind(predctCSwi, predict(wi.tconsplgs, predctCSwi, type = "link", se.fit=TRUE))<br>
head(predctCSwi)<br>
t.con.splgs ln.days season fit se.fit<br>
1 0.0000000 3.409496 wtr -1.262801 0.1784000<br>
2 0.7142493 3.409496 wtr -1.250759 0.1784448<br>
3 1.4284985 3.409496 wtr -1.238718 0.1785467<br>
4 2.1427478 3.409496 wtr -1.226676 0.1787054<br>
5 2.8569971 3.409496 wtr -1.214635 0.1789210<br>
6 3.5712464 3.409496 wtr -1.202593 0.1791931<br>
<br>
# Then scale up to pellets/ha/month (phm)<br>
# and backtransform saplings to per 0.1 ha by squaring the square-root values<br>
predctCSwi <- within(predctCSwi, {<br>
pellets <- exp(fit)<br>
phm <- pellets/1.5*10000<br>
LLha <- (exp(fit - 1.96 * se.fit))/1.5*10000<br>
ULha <- (exp(fit + 1.96 * se.fit))/1.5*10000<br>
con.splgs.1ha <- (t.con.splgs^2)<br>
})<br>
<br>
<br>
Thank you,<br>
Sheryn Olson<br>
<br>
</div><br></div>