david-barnett / microViz

R package for microbiome data visualization and statistics. Uses phyloseq, vegan and the tidyverse. Docker image available.
https://david-barnett.github.io/microViz/
GNU General Public License v3.0
94 stars 10 forks source link

Beta-binomial regression example error: Error in (function (formula, phi.formula, data, link = "logit", phi.link = "logit", : Model could not be optimized! Try changing initializations or simplifying your model. #39

Closed Leran10 closed 1 year ago

Leran10 commented 2 years ago

Hi,

When I try this example code:

ps0 %>% 
  tax_fix() %>% 
  tax_prepend_ranks() %>% 
  tax_filter(min_prevalence = 0) %>% 
  taxatree_models(
    type = corncob::bbdml, 
    ranks = c("Phylum", "Class", "Order", "Family"),
    variables = c("Treatment","Sample_Site","Time")

  )

I got this error message:

Error in (function (formula, phi.formula, data, link = "logit", phi.link = "logit",  : 
  Model could not be optimized! Try changing initializations or simplifying your model.

I'm not sure what does this error mean?

Thanks! Leran

david-barnett commented 2 years ago

It's an error from the corncob modelling package. For one taxon the specified model could not be fitted. You can set taxatree_models verbose argument to TRUE, which could help identify the problem taxon.

Most likely you'll need to more strictly filter low prevalence taxa before modelling.

For more info on the beta-binomial regression modelling read up the excellent documentation vignette of the corncob package.

Alternatively stick with the log2 compositional linear model approach, which is simpler and can more often fit models to lower abundance /rarer taxa.