# Meta-analysis: Modeling (Part 3) 1. Pull in data from data extraction. .... ### Taxonomic data Pulled taxanomic data from rfishbase. Using this code: ``` library(rfishbase) library(dplyr) rfishbase::load_taxa() %>% filter(Species %in% clean.dat2$Species.name) %>% collect() -> tax.data dplyr::rename(tax.data, Species.name = Species) %>% # join taxonomic data to working dataframe left_join(clean.dat2,tax.data,by="Species.name") -> clean.dat3 ``` Now that all data is merged, let's do some exploring on the effect of taxanomic status. #### Models Ran models in single exploratory variables along with full additive and interactive model. ``` t0 <- glmmTMB(data=clean.dat3, lnrr~1 + (1 | ID)+ (1 | Order)) t1 <- glmmTMB(data=clean.dat3, lnrr~Length + (1 | ID)+ (1 | Order)) t2 <- glmmTMB(data=clean.dat3, lnrr~RepGuild1 + (1 | ID)+ (1 | Order)) t3 <- glmmTMB(data=clean.dat3, lnrr~FoodTroph + (1 | ID)+ (1 | Order)) t4 <- glmmTMB(data=clean.dat3, lnrr~Length + RepGuild1 + FoodTroph + (1 | ID) + (1 | Order)) t5 <- glmmTMB(data=clean.dat3, lnrr~ Length * RepGuild1 * FoodTroph + (1 | ID) + (1 | Order)) t6 <- glmmTMB(data=clean.dat3, lnrr~ Length + RepGuild1 + FoodTroph + (1 | ID:Order)) # nested Order within Study ID as a random effect t7 <- glmmTMB(data=clean.dat3, lnrr~ Length * RepGuild1 * FoodTroph + (1 | ID:Order)) # nested Order within Study ID as a random effect ``` Calculate confidence intervals from model: Here, we aim to calculate confidence intervals of predictions made from a glmmTMB model, specifically intersted in taxonomic status. - Example of how it can be done: [Pore et al. paper](https://onlinelibrary.wiley.com/doi/full/10.1111/j.1461-0248.2012.01804.x) - To obtain CIs, authors used *REML estimates of fixed effects and their 95% confidence intervals were derived from the linear mixed models and used in all figures. Or, in other words, the means and 95% confidence intervals are derived from linear mixed models of log response ratio against predictor variables* - Note: can we [bootstrap](https://www.alexejgossmann.com/bootstap_confidence_intervals/)? ### Model Diagnostics #### Resources - [Regression diagnostics](https://data.princeton.edu/wws509/notes/c2s9) #### DHARMa Posts that are helpful: - Blog post from Florian's website-- [Theorietical Ecology](https://theoreticalecology.wordpress.com/2016/08/28/dharma-an-r-package-for-residual-diagnostics-of-glmms/) - [R Documentation](https://www.rdocumentation.org/packages/DHARMa/versions/0.4.1) - [CRAN vinette](https://cran.r-project.org/web/packages/DHARMa/vignettes/DHARMa.html) - [GitHub](http://florianhartig.github.io/DHARMa/) - [Reference Manuel](https://cran.r-project.org/web/packages/DHARMa/DHARMa.pdf) Notes: - Quantile tests: - Quantile regression: Model quantiles of the conditional distribution of a variable (instead of the conditional mean). - Quantile regression does not make distributional assumptions, i.e., assumptions about residuals, other than assuming that the response variable is almost continuous. - More info: https://people.umass.edu/biep640w/pdf/diagnosticsStudentNotes.pdf