{"id":31338,"date":"2013-07-24T11:16:13","date_gmt":"2013-07-24T18:16:13","guid":{"rendered":"https:\/\/dev-clm-blog.pantheonsite.io\/?p=31338"},"modified":"2013-07-24T11:16:13","modified_gmt":"2013-07-24T18:16:13","slug":"starting-a-new-project","status":"publish","type":"post","link":"https:\/\/blog.clminternship.org\/?p=31338","title":{"rendered":"Starting a New Project&#8230;.."},"content":{"rendered":"<p><!--[if !mso]&gt;--><\/p>\n<p>After a well deserved vacation involving a trip back home to Chicago, an ArcGIS course and a wedding (not mine); I find my self getting ready to return to work. Having just finished that ArcGIS online course I have been spending my free time trying to get my hand on any and all books that could enlighten me on even more creative uses of this program for biologists. With all this new found knowledge I have gained I am ready and anticipating a new project. <span>\u00a0<\/span>Upon returning to the office, my project is set before me! The next question is, can I do it?<\/p>\n<p class=\"MsoNormal\">At first my heart plummets as the project is explained to me. The sudden drop my heart does is not due to disappointment with being assigned a boring project, or even one that doesn\u2019t related to my interest, the plummet my heart takes is caused by the intensity of the project. The project is exactly what I wanted, an outlet to try my newfound knowledge in ArcGIS and continue expanding my repertoire of R commands, but now sitting in front of my mentors, the task seems overly daunting. The explanation is peppered with statistical and technical terms I have never heard of and requests to \u201cwrite an application\u201d figure out the best algorithm\u201d, and \u201cobviously make sure to statistical analyze your models using an AIC\u201d. As the mentors leave with promises of getting me a few papers and the data sets, I sit there in shell shock. The world is spinning around me.<span>\u00a0 <\/span>Doubt slowly creeps in, the fear of failure blinds me. I take a deep breath. Focus. I\u2019ve got this.<\/p>\n<p class=\"MsoNormal\">This brings me to a small tangent. BIOLOGISTS NEED MORE MATH in their training. I know that oftentimes students get to choose some of the courses and one could specialize in math, but what about the core courses? I do not particularly like math, but as I am working on different projects as an ecologist I have been reminded how essential truly understanding statistics is to experimental design. Statistician and GIS professionals are good at what they do, but oftentimes don\u2019t seem to be able to grasp the underlying biological concepts to be to too much use to biologist. So, in essence, I think that this is just my little wake-up call to each and everyone of you to become a stronger biologist by solidifying an intimate knowledge of statistics, modeling and programming. I did not think I would be going back to school (I just finished my Masters), but it seems that this intership might have gotten me super stoked about ecological modeling. Any good programs you guys can recommend?<\/p>\n<p class=\"MsoNormal\">Anyway, my mentor soon returns with a thumb drive loaded with all sorts of goodies. Welcome back!, The equivletant of 3 to4&#8243; inch manila folders filled with reading and data sets gets thrown on my desk.<\/p>\n<p class=\"MsoNormal\">The key, and hardest parts to succeeding at this project is starting. With that in mind, I start out with determining what exactly AIC actually stands for and how do I use it to analyze my models.<\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">With the help of The R coding Hand book and Wikipedia (oh, how students I TA\u2019d would love to yell at me for this as I once did to them) I compiled a little fact sheet about AIC curves<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">I do not expect this to be very useful to you guys but since I wrote it out for myself I figured I would not be selfish and share it.<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">\u00a0AIC Definition, History and R coding<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">The Akaike information criterion also known as AIC is a measure of the relative quality of a statistic model for a certain set of data. It is, more officially a \u201cstatistic trade as a penalized log-likelihood\u201d. It looks at the complexity and goodness of fit allowing a means for model selection. It is important to remember that this criterion can not test a hypothesis or provide an absolute test telling us how good the models fit the data; it just tells you which ones fit better. It was published in 1974 by Hirotuga Akaike; this was in Japanese and was not widely known. Only in 2002 was it published in English by Burhams &amp; Anderson. <\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">The AIC is:<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">K=#of parameters in model <\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">L=max value of likeligood function for the models<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\"><span>\u00a0<\/span>*Best models is the one with the lowest AIC, and simple is better ( too many parameters in an equation is penalized while goodness of fit is sought after)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">**Only used with large sample sizes (number of models) there is a correction if you want to correct for a finite sample size(AICc)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">In practice once you have calculated the AIC criterion for your models then you have to decide which ones minimize the amount of data you lose. This is done by looking at the relative probability of the model in question minimizing information loss, aka ((AICmin-AIC)\/2).<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">R CODING\u00a0<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">#Getting AIC<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">Data&lt;-read.table(\u201c&#8212;&#8211;\u201d, header=T)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">attach( data)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">name(data) # the names are growth and tannin, lets pretend<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">model&lt;-lm(growth~tannin) #this is to work out the linear regression model for this data in R<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: .5in;\"><span style=\"font-size: 11.0pt;\">#now to define all the variable in the equation<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">N&lt;-length (growth)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">sse&lt;- sum((growth-fitted(model))^2)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">s2&lt;- sse\/(n-2)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">s&lt;-sqrt(s2)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\"><span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>#computing log likelihood<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">-(n\/2)*log(2*pi)-n*log(s)-sse\/(2*s2)<br \/>\n<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: .5in;\"><span style=\"font-size: 11.0pt;\">#not to calculate the AIC, -2* loglikelihood+ 2(p+1)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">-2 *(insert your loglik number)+ 2(number of parameters+1)<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: .5in;\"><span style=\"font-size: 11.0pt;\"># Once you have this the AIC you want to compare them to each other<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">model.1&lt;- lm(Fruit~Grazing*Root)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">model.2&lt;-lm(Fruit*Grazing*Root)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">AIC(model.1, model.2) <\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">#if you have more than two models you do this:<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">models&lt;-list(model1, model2, model3, model4)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">aic&lt;- unlist (lapply (models,AIC) #this extracts the aic, aic will be a vector in which you can search for the minimum. <\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">More on this project to come. See you next time! That is, if the monsoons do not wash me and my computer away. <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>After a well deserved vacation involving a trip back home to Chicago, an ArcGIS course and a wedding (not mine); I find my self getting ready to return to work. Having just finished that ArcGIS online course I have been &hellip; <a href=\"https:\/\/blog.clminternship.org\/?p=31338\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1795,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=\/wp\/v2\/posts\/31338"}],"collection":[{"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=\/wp\/v2\/users\/1795"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31338"}],"version-history":[{"count":13,"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=\/wp\/v2\/posts\/31338\/revisions"}],"predecessor-version":[{"id":31710,"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=\/wp\/v2\/posts\/31338\/revisions\/31710"}],"wp:attachment":[{"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.clminternship.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}