Coder Social home page Coder Social logo

fitting-size-spectra's Introduction

fitting-size-spectra

NEWS I have finished converting this code into an R package, which should make it much more usable. The package also includes the code for our second paper for fitting data that are only available in binned form, and has vignettes to reproduce all results in both papers and to help users apply the methods to their own data. The package is at https://github.com/andrew-edwards/sizeSpectra.


This repository contains R code for the paper

Testing and recommending methods for fitting size spectra to data

by Andrew M. Edwards, James P. W. Robinson, Michael J. Plank, Julia K. Baum and Julia L. Blanchard

published in Methods in Ecology and Evolution (2017, 8:57-67). The paper is freely available at

http://onlinelibrary.wiley.com/doi/10.1111/2041-210X.12641/full

The aim of sharing this code is so that others can repeat (and extend) our simulation study, and also analyse their own data. I have endeavoured to properly document the code.

To download the code from the GitHub site just click the 'Clone or Download' button (near the top on the right) and select 'Download ZIP'. Make a note of the 'Latest commit' number in case you have any questions for me. If you use GitHub then feel free to fork and adapt the code.

If you want to run new simulations or apply the code to your own data then just use the latest version that will be automatically displayed on the GitHub site.

To exactly reproduce the results in the paper you should download release version 1.0.0 (click on 'release' tab in the GitHub site) and see the notes in code/readReRun.txt concerning the seed and how require(dplyr) generates a random number. Later updates of the code will have some generalisation of functions that should not affect the older code (but I won't re-test it all for back compatibility).

There are functions (in code/PLBfunctions.r) that may be of more general use, such as logTicks() for adding tick marks to a log-log plot, and legJust() for right-justifying a legend (based on an example in ?legend).

If you have problems with the code then please contact me. Some of it has been independently used by co-author James Robinson, who got it working fine for his own data.

Thanks,

Andrew Edwards.

http://www.chebucto.ns.ca/~english

[email protected] - this may change at some point, and if it does not work then try [email protected] which will always automatically forward to my correct email.

Repository Contents

README.md - this file (can be read in a Markdown viewer or simply any text editor).

.gitignore - ignore this if you don't know what it is.

code/ - directory containing all the R code.

code/readMeCode.txt - readme file for the code directory. Contains instructions and details of the files and further subdirectories.

The subdirectories of code/ are summarised below, but see readMeCode.txt for full details.

code/single/ - testing the eight methods on a single data set.

code/multiple/ - testing the eight methods on multiple (10,000) simulated data sets. Contains subdirectories for the sensitivity tests.

code/MLEbin/ - MLEbin method for likelihood when the data are only available in binned form.

code/recommend/ - recommended likelihood calculations and resulting plots of data and fitted size spectrum (Figure 6).

15th May 2017 - corrected a minor error regarding the likelihood function for the MLEbin method when b=-1. In practice this should not have any effect. See Issue #7.

12th December 2017 - fully corrected the above point. Phil Wallhead correctly pointed out that I had not completely corrected the code for b=-1. Again, in practice this should not have any effect (though it would for simulating data with b=-1). See Issue #7.

fitting-size-spectra's People

Contributors

andrew-edwards avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fitting-size-spectra's Issues

Minor error in calculation of MLEbin log-likelihood function when b=-1

image

The corresponding code therefore needs to be corrected in the negLL.PLB.binned() function in code/PLBfunctions.r .

In practice this error is very unlikely to matter, as it will only occur when the log-likelihood function negLL.PLB.binned() is called with a value of exactly b=-1. Due to machine precision this is highly unlikely to occur when minimising the negative log-likelihood function.

This error did not occur for the negLL.PLB() function for unbinned data, since the analogous equation (A.11) in Edwards et al. (2017) correctly has the logarithm of the logarithm term:
image

Make a 'release' version when submitting the revised version of the manuscript.

From Chris: You want releases which are a special kind of tag. On our hake-assessment repo, go to the code tab, then click releases. I did this through the git shell using tags and pushed them just like you would push commits. There is a simple version of tag and a more complex one which you can add the comments to.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.