<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/a-note-on-aic-scores-for-quasi-families-in-rstats/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.christopherlortie.info/a-note-on-aic-scores-for-quasi-families-in-rstats/"> R – christopher lortie</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a target="_blank" rel="nofollow" href="https://i2.wp.com/www.christopherlortie.info/wp-content/uploads/2017/05/Field_Studies_Quasi_album.jpg"><img sizes="(max-width: 300px) 100vw, 300px" alt="" class="wp-image-1305" src="https://i2.wp.com/www.christopherlortie.info/wp-content/uploads/2017/05/Field_Studies_Quasi_album.jpg?resize=300%2C300" data-recalc-dims="1"></a></p>
<p>A summary note on recent set of #rstats discoveries in estimating AIC scores to better understand a quasipoisson family in GLMS relative to treating data as poisson.</p>
<p><strong>Conceptual GLM workflow rules/guidelines</strong></p>
<ol>
<li>Data are best untransformed. Fit better model to data.</li>
<li>Select your data structure to match purpose with statistical model.</li>
<li>Use logic and understanding of data not AIC scores to select best model.</li>
</ol>
<p>(1) Typically, the power and flexibility of GLMs in R (even with base R) get most of the work done for the ecological data we work with within the research team. We prefer to leave data untransformed and simple when possible and use the family or offset arguments within GLMs to address data issues.</p>
<p>(2) Data structure is a new concept to us. We have come to appreciate that there are both individual and population-level queries associated with many of the datasets we have collected.  For our purposes, data structure is defined as the level that the dplyr::group_by to tally or count frequencies is applied. If the ecological purpose of the experiment was defined as the population response to a treatment for instance, the population becomes the sample unit – not the individual organism – and summarised as such. It is critical to match the structure of data wrangled to the purpose of the experiment to be able to fit appropriate models. Higher-order data structures can reduce the likelihood of nested, oversampled, or pseudoreplicated model fitting.</p>
<p>(3) Know thy data and experiment. It is easy to get lost in model fitting and dive deep into unduly complex models. There are tools before model fitting that can prime you for better, more elegant model fits.</p>
<p><strong>Workflow</strong></p>
<ol>
<li>Wrangle then data viz.</li>
<li>Library(fitdistrplus) to explore distributions.</li>
<li>Select data structure.</li>
<li>Fit models.</li>
</ol>
<p>Now, specific to topic of <strong>AIC scores for quasi-family field studies</strong>.</p>
<p>We recently selected quasipoisson for the family to model frequency and count data (for individual-data structures). This addressed overdispersion issues within the data. AIC scores are best used for understanding prediction not description, and logic and exploration of distributions, CDF plots, and examination of the deviance (i.e. not be more than double the degrees of freedom) framed the data and model contexts. To contrast poisson to quasipoisson for prediction, i.e. would the animals respond differently to the treatments/factors within the experiment, we used the following #rstats solutions.</p>
<p>————</p>
<p>#Functions####</p>
<p>#deviance calc</p>
<p>dfun &lt;-function(object) {</p>
<p>with(object,sum((weights * residuals^2)[weights > 0])/df.residual)</p>
<p>}</p>
<p>#reuses AIC from poisson family estimation</p>
<p>x.quasipoisson &lt;-function(…) {</p>
<p>res &lt;-quasipoisson(…)</p>
<p>res$aic &lt;-poisson(…)$aic</p>
<p>res</p>
<p>}</p>
<p>#AIC package that provided most intuitive solution set####</p>
<p>require(MuMIn)</p>
<p>m &lt;-update(m,family=”x.quasipoisson”, na.action=na.fail)</p>
<p>m1 &lt;-dredge(m,rank=”QAIC”, chat=dfun(m))</p>
<p>m1</p>
<p>#repeat as needed to contrast different models</p>
<p>————</p>
<p><strong>Outcomes</strong></p>
<p>This #rstats opportunity generated a lot of positive discussion on data structures, how we use AIC scores, and how to estimate fit for at least this quasi-family model set in as few lines of code as possible.</p>
<p><strong>Resources</strong></p>
<ol>
<li>An <strong><a target="_blank" rel="nofollow" href="https://cran.r-project.org/web/packages/bbmle/vignettes/quasi.pdf">R vignette</a></strong> by Ben Bolker of quasi solutions.</li>
<li>An <strong><a target="_blank" rel="nofollow" href="http://fisher.utstat.toronto.edu/reid/sta2201s/QUASI-POISSON.pdf">Ecology article</a></strong> on quasi-possion versus nb.regression for overdispersed count data.
<div title="Page 2"></div>
</li>
<li>A <strong><a target="_blank" rel="nofollow" href="https://stats.stackexchange.com/questions/81427/aic-guidelines-in-model-selection">StatsExchange discussion</a></strong> on AIC scores.</li>
</ol>
<p><strong>Fundamentals</strong></p>
<p>Same data, different structure, lead to different models. Quasipoisson a reasonable solution for overdispersed count and frequency animal ecology data. AIC scores are a bit of work, but not extensive code, to extract. AIC scores provide a useful insight into predictive capacities if the purpose is individual-level prediction of count/frequency to treatments.</p>
<p> </p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.christopherlortie.info/a-note-on-aic-scores-for-quasi-families-in-rstats/"> R – christopher lortie</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/uXbk3VeqVBQ"></a></div>