txm676 / gambin

The gambin R package
3 stars 3 forks source link

Odd interface to fitGambin #4

Closed csgillespie closed 7 years ago

csgillespie commented 7 years ago

The fitGambin has (I think) a strange interface. It becomes obvious(?) now there is a function for generating random numbers. To generate random numbers from the gambin distribution

x = rgambin(1000, alpha=2, 6)

To estimate alpha we now use the clunky

R> d = data.frame(octave = as.numeric(names(table(x))), species = as.vector(table(x)))
R> fitGambin(d)

GamBin distribution fit
Data: d

Coefficients:
    Alpha  MaxOctave  
    1.066      3.000  

Typically fit* functions would take x as an input.


Proposal:

  1. Properly deprecate fitGambin
  2. Create a function fit_gambin. If x is a vector assume that the numbers come from a gambin distribution. If x is a data.frame, do as is currently done.
mkborregaard commented 7 years ago

Not sure I follow - I cannot find rgambin on your fork, so I'm not quite sure what it returns?

If x is a vector of abundances, the current function should take it:

> x = c(2,2,5,4,6,8,6,123,3,4554)
> fitGambin(x)

GamBin distribution fit
Data: x

Coefficients:
    Alpha  MaxOctave  
     1.59      12.00  
csgillespie commented 7 years ago

The rgambin function simulates values from the gambin distribution (https://github.com/csgillespie/gambin/blob/master/R/dgambin.R#L63) - it uses a simple look-up method.

In fitGambin, the input isn't values from the gambin distribution, it's abundances. The fitGambin detects that x is a vector and calls create_octaves (https://github.com/csgillespie/gambin/blob/master/R/fit_gambin.R#L36)

My point is that this seems odd. It would be cleaner to separate your particular use case (ecology) with the general statistical distribution.

mkborregaard commented 7 years ago

I see what you mean, but I actually think of the 'octaves' as an integral part of the gambin distribution. I think of the gambin distribution as a distribution over abundances rather than a distribution over octaves, though I realize that is slightly at odds with the name (because the distribution is gamma-binomial over octaves). Hm, maybe worth debating this with Karl Ugland who designed the distribution.

mkborregaard commented 7 years ago

I think Tom'll ask Ugland - either way, you've given us something to think about here.

txm676 commented 7 years ago

So Karl replied. He said, GAMBIN is not attached to octaves. The reason octaves were attached to GAMBIN was that I developed the method in cooperation with community ecologists who preferred to work with octaves in the Species-Abundance analysis. Gambin will work for any histogram.

But he said he was happy with what ever we decided to do

mkborregaard commented 7 years ago

Huh, so it is the octaves/histogram that is gambin distributed, not the abundances? It is like he does not really answer that, isn’t it?

txm676 commented 7 years ago

He also said he agreed with your opinion Michael, so I'm not sure?

mkborregaard commented 7 years ago

oh did he (so confused)? Can you forward the mail? —


Michael Krabbe Borregaard, MSc, PhD Assistant Professor (TT), Center for Macroecology, Evolution & Climate Natural History Museum of Denmark, University of Copenhagen Universitetsparken 15, DK-2100 Copenhagen

Subject Editor, Ecography Associate Editor, Global Ecology and Biogeography

Featured paper: Oceanic island biogeography through the lens of the general dynamic model: assessment and prospecthttp://onlinelibrary.wiley.com/doi/10.1111/brv.12256/full, Biological Reviews (2016). An Anthropocene map of genetic diversityhttp://science.sciencemag.org/content/353/6307/1532, Science (2016)

Fra: txm676 notifications@github.com<mailto:notifications@github.com> Svar til: mkborregaard/gambin reply@reply.github.com<mailto:reply@reply.github.com> Dato: torsdag den 22. december 2016 kl. 12.17 Til: mkborregaard/gambin gambin@noreply.github.com<mailto:gambin@noreply.github.com> Cc: Michael Krabbe Borregaard mkborregaard@snm.ku.dk<mailto:mkborregaard@snm.ku.dk>, Comment comment@noreply.github.com<mailto:comment@noreply.github.com> Emne: Re: [mkborregaard/gambin] Odd interface to fitGambin (#4)

He also said he agreed with your opinion Michael, so I'm not sure?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/mkborregaard/gambin/issues/4#issuecomment-268779485, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AICg6oWVFYAQeBZSecY6t-iLUUANvkZjks5rKlxggaJpZM4LQPeo.