rsetienne / PBD

Protracted Birth-Death model in R
GNU General Public License v2.0
2 stars 3 forks source link

Clear error message in PBD::pbd_ML #26

Open richelbilderbeek opened 5 years ago

richelbilderbeek commented 5 years ago

I have a hard time finding out how to use pbd_ML. I wish the error message would be more hulpful, to point a user into the right direction.

Say, I want to do a maximum likelihood optimization for the speciation completion rate. This is one of the many ways I've tried:

# Goal: optimize the SCR
branching_times <- c(1, 2, 3, 4)
erg <- 0.1 # Extinction Rate of Good species
eri <- 0.2 # Extinction Rate of Incipient species
scr <- 0.3 # Speciation Completion Rate
# ML assumes these are the same
sirg <- siri <- 0.4 # Speciation Initiation Rate of Good/Incipient Species

out <- PBD::pbd_ML(
  brts = branching_times,
  idparsopt = 3, # SCR
  initparsopt = scr,
  idparsfix = c(1, 2, 4),
  parsfix = c(sirg, erg, eri),
  exteq = TRUE,
  verbose = TRUE
)

The error message is:

The arguments should be coherent.

I wish the error message would be more detailed. Sure, I can look into the code (and I will in a sec), but it may be preferable to be more helpful to the user.

rsetienne commented 5 years ago

Hi Richel,

exteq = TRUE is incompatible with having four parameters. exteq = TRUE means the extinction rates of good and incipient species are always the same, so no need to set it. A more informative error method would indeed be helpful...

Cheers, Rampal

On 8-11-2018 13:46, Richel Bilderbeek wrote:

I have a hard time finding out how to use |pbd_ML|. I wish the error message would be more hulpful, to point a user into the right direction.

Say, I want to do a maximum likelihood optimization for the speciation completion rate. This is one of the many ways I've tried:

|# Goal: optimize the SCR branching_times <- c(1, 2, 3, 4) erg <- 0.1 # Extinction Rate of Good species eri <- 0.2 # Extinction Rate of Incipient species scr <- 0.3 # Speciation Completion Rate # ML assumes these are the same sirg <- siri <- 0.4 # Speciation Initiation Rate of Good/Incipient Species out <- PBD::pbd_ML( brts = branching_times, idparsopt = 3, # SCR initparsopt = scr, idparsfix = c(1, 2, 4), parsfix = c(sirg, erg, eri), exteq = TRUE, verbose = TRUE ) |

The error message is:

|The arguments should be coherent. |

I wish the error message would be more detailed. Sure, I can look into the code (and I will in a sec), but it may be preferable to be more helpful to the user.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rsetienne/PBD/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/ANkzmQFt-TIC7AeEroGO4DMQd5cOxPU-ks5utCeSgaJpZM4YUmxm.

richelbilderbeek commented 5 years ago

Agree, that's one/a solution. This Issue is about helping other users get there faster.