[R-sig-ME] Help with glmmADMB and ZIP mixed effects models
simone santoro
simonesantoro77 at gmail.com
Sat May 20 23:11:29 CEST 2017
Dear Shirley,
I don’t know why you got the error message and there are many people out
there much more qualified than I am to give you a good answer. I will just
try to suggest something with the hope that you might find it useful.
When there is an error speaking about problems in the curvature I tend to
think of an overparameterized model and/or with a ‘wrong’ distribution. Do
you get the same error if you remove one covariate? Have you tried to use a
different distribution, like a negative binomial? For instance, a negative
binomial could work better, don't know but it is worth a try. You know, the
negative binomial has two parameters (one for mean and one for variance)
instead that one single parameter like in the Poisson that accounts both
for mean and variance and sometimes it fits better.
That said, I have been trying recently to use glmmadmb {package: glmmADMB}
and glmmTMB (package:glmmTMB} and I have found glmmtmb more flexible and
pretty faster than glmmadmb. More flexible because you have more choice in
terms of distributions (e.g. “compois” for the Conway-Maxwell-Poisson) and
because you can – this is for me the greatest advantage – fit a model with
covariates (even with random effects) on the zero inflation. Sometimes I
have seen that if you have a covariate that is clearly related to the p of
getting a zero the fit of model improves very much. I would compare by AIC
the fit of different models with different distributions (e.g. negative
binomial, poisson, compois) and with and without zero inflation for
instance.
The syntax would be something like this (very similar to the syntax in
lme4):
Model1<- glmmTMB(Cut~Time+Group+(1|subject),data=x12,family=nbinom2,zi=~1)
If I remember well you do not need to eliminate the NA before.
Good luck,
Simone
2017-05-20 5:27 GMT+02:00 Wang, Shirley <shirleywang at g.harvard.edu>:
> Hello,
>
> I'm hoping to run a zero-inflated mixed effects poisson regression model
> for count data. My dataset includes 111 subjects, randomized to 3 groups
> and each assessed 7 times (777 observations). Through searching online, it
> seems like the glmmADMB package is my best bet. From my understanding, NA
> missing values should be removed prior to analysis -- this leaves me with
> 264 observations. I tried running glmmadmb() with zero inflation, poisson,
> and mixed effects specified; however, I'm running into some errors. This is
> my dataset:
>
> > str(x12)
> 'data.frame': 264 obs. of 12 variables:
> $ Subject : Factor w/ 111 levels "1","2","3","4",..: 1 1 1 1 2 2 2 3 4 4
> ...
> $ Time : int 1 5 6 7 1 5 7 1 1 6 ...
> $ Group : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
> $ SRS : int 56 55 56 55 50 46 42 49 47 42 ...
> $ BDI : int 40 23 41 35 44 14 11 22 16 9 ...
> $ ERQ : int 14 11 14 15 18 12 15 14 26 27 ...
> $ Cut : int 3 4 10 15 1 1 0 1 0 0 ...
> $ NSSI : int 8 14 32 58 2 2 8 2 0 1 ...
> $ Ideation : int 2 0 5 10 5 3 0 1 0 0 ...
> $ Plan : int 1 0 2 8 1 4 5 0 0 0 ...
> $ Stop : int 2 2 1 2 3 3 3 2 3 2 ...
> $ Likelihood: int 4 4 4 4 3 4 4 4 3 3 ...
> - attr(*, "na.action")=Class 'omit' Named int [1:513] 2 3 4 9 10 11 13 16
> 17 18 ...
> .. ..- attr(*, "names")= chr [1:513] "2" "3" "4" "9" ...
> >
>
> And here is my session info:
>
> > sessionInfo()
> R version 3.3.3 (2017-03-06)
> Platform: x86_64-apple-darwin13.4.0 (64-bit)
> Running under: OS X Yosemite 10.10.5
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] lme4_1.1-13 Matrix_1.2-8 pscl_1.4.9 lattice_0.20-34
> [5] glmmADMB_0.8.3.3 MASS_7.3-45
>
> loaded via a namespace (and not attached):
> [1] Rcpp_0.12.10 magrittr_1.5 splines_3.3.3 devtools_1.12.0
> [5] munsell_0.4.3 colorspace_1.3-2 minqa_1.2.4 stringr_1.2.0
> [9] plyr_1.8.4 tools_3.3.3 grid_3.3.3 nlme_3.1-131
> [13] gtable_0.2.0 coda_0.19-1 withr_1.0.2 digest_0.6.12
> [17] lazyeval_0.2.0 tibble_1.3.0 R2admb_0.7.15 nloptr_1.0.4
> [21] ggplot2_2.2.1 memoise_1.0.0 stringi_1.1.5 scales_0.4.1
> >
>
> I tried to use the following formula, with "Cut" as my outcome, and got
> this lengthy error message:
>
> > results <- glmmadmb(Cut ~ Time + Group + (1|Subject), data = x12,
> zeroInflation = TRUE, family = "poisson")
> matrix not pos definite in sparse choleski
> Parameters were estimated, but standard errors were not: the most likely
> problem is that the curvature at MLE was zero or negative
> Error in glmmadmb(Cut ~ Time + Group + (1 | Subject), data = x12,
> zeroInflation = TRUE, :
> The function maximizer failed (couldn't find parameter file)
> Troubleshooting steps include (1) run with 'save.dir' set and inspect
> output files; (2) change run parameters: see '?admbControl';(3) re-run with
> debug=TRUE for more information on failure mode
> In addition: Warning message:
> running command './glmmadmb -maxfn 500 -maxph 5 -noinit -shess' had status
> 42
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> matrix not pos definite in sparse choleski
> Error: Invalid index 111 used for array range [0, 110] in "double&
> dvector::operator[] (int i)".
> invalid index for array
>
> >
>
> How can I go about fixing this error? Alternatively, is there another way
> to run ZIP mixed models for count data? I had been successfully using the
> lme4 package w/ lmer function to run linear mixed models for continuous
> data, but I'm not sure whether this package can also handle zero-inflated
> count data.
>
> Thank you so much in advance for any help or advice you might be able to
> provide!
>
> Best,
> Shirley
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list