Using R ver 2.15.2, package glmmADMB_0.7.3 in Win7, I've been
attempting to run a negative binomial model to determine the effects of
season and forest stand types on snowshoe hare pellet densities. Year
is a random (nuisance) variable. Each stand type (treatment) has
unequal sample sizes that vary by year. The count data are constrained
at zero, zero inflated, and range from 0 - 990 (residuals show
overdispersion).<br>
<br>Data Structure:<br><br>> str(ps)<br>'data.frame': 387 obs. of 7 variables:<br> $ year : Factor w/ 5 levels "2008","2009",..: 1 1 1 1 1 1 1 1 1 1 ... ### random nuisance var.<br>
$ season : Factor w/ 2 levels "Smr","Wtr": 1 1 1 1 1 1 1 1 1 1 ... ### fixed var. of interest <br>
$ stand : Factor w/ 39 levels "AF1","AF2","AF3",..: 32 33 25 27 26 34 23 31 24 28 ...<br> $ stndtyp: Factor w/ 3 levels "MT","RG","SEL": 1 1 1 1 1 1 1 1 1 1 ... ### fixed var of interest<br>
$ pellets: int <a href="tel:1%201%202%202%204%205%207%209%2012%2013" value="+12245791213" target="_blank">1 1 2 2 4 5 7 9 12 13</a> ...<br> $ days : num 114 114 127 127 127 127 122 112 115 112 ...<br> $ ln.days: num 4.74 4.74 4.84 4.84 4.84 ... ### offset var.<br>
<br>Model:<br>>
nb1 <- glmmadmb(pellets ~ season * stndtyp + offset(ln.days) +
(1|year), na.omit, data=ps,family="nbinom", link="logit")<br>
<br> Warning in glmmadmb(pellets ~ season * stndtyp + offset(ln.days) + (1 | :<br> NAs removed in constructing fixed-effect model frame: you should probably remove them manually, e.g. with na.omit()<br> Warning in II[, ii] + REmat$codes[[i]] :<br>
longer object length is not a multiple of shorter object length<br> Error in II[, ii] = II[, ii] + REmat$codes[[i]] : <br> number of items to replace is not a multiple of replacement length<br><br>Are
there syntax problems? - with the na.omit and random specification.
Model problems? - with unequal sample sizes, or wrong specification of
the link. Do the algorithms require equal sample sizes?<br>
I'm also confused about how to know what value of theta to specify, and when it is appropriate to specify?<br><br>Thanks all.<br>############ UPDATE ###########<br>Mollie informed me that the logit was inappropriate for the negbinom family (oops). I could not find the correct syntax for using na.omit, so ...<br>
<div><div><img src="https://mail.google.com/mail/u/0/images/cleardot.gif"></div>
</div> The model worked when I removed the NAs from the dataframe! <br><br>> nb1 <- glmmadmb(pellets ~ season * stndtyp + offset(ln.days) + (1|year), data=ps2,family="nbinom")<br>> summary(nb1)<br>
<br>Call:<br>glmmadmb(formula = pellets ~ season * stndtyp + offset(ln.days) + <br>
(1 | year), data = ps2, family = "nbinom")<br><br>Coefficients:<br> Estimate Std. Error z value Pr(>|z|) <br>(Intercept) -3.005 0.159 -18.94 < 2e-16 ***<br>
season[T.Wtr] 0.552 0.184 3.00 0.0027 **<br><div id=":1iw">stndtyp[T.RG] 2.342 0.161 14.53 < 2e-16 ***<br>stndtyp[T.SEL] 1.096 0.179 6.13 8.6e-10 ***<br>
season[T.Wtr]:stndtyp[T.RG] 0.218 0.215 1.02 0.3090 <br>season[T.Wtr]:stndtyp[T.SEL] -0.247 0.240 -1.03 0.3025 <br>---<br>Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 <br>
<br>Number of observations: total=302, year=5 <br>Random effect variance(s):<br>Group=year<br> Variance StdDev<br>(Intercept) 0.02859 0.1691<br>Negative binomial dispersion parameter: 2.197 (std. err.: 0.18795)<br>
<br>Log-likelihood: -1452.6 <br><br>Sheryn<div class="yj6qo ajU"><div id=":1gu" class="ajR" tabindex="0"><img class="ajT" src="https://mail.google.com/mail/u/0/images/cleardot.gif"></div></div></div>Graduate Research Assistant, The University of Maine<br>