Skip to content
Christophe Dutang edited this page May 7, 2015 · 3 revisions

#Coding convention

Naming convention for R files

  • for the MBBEFD distribution, distinguish parametrizations
    • first parametrization MBBEFD(a,b) : mbbefdR-1stparam.R, mbbefdCpp-1stparam.R
    • second parametrization MBBEFD(g,b) : mbbefdR-2ndparam.R, mbbefdCpp-2ndparam.R
  • for one-inflated distributions
    • 1infl-xxx.R

Naming convention for R functions (d, p, q, r)

  • for the MBBEFD distribution, append the letter (d, p, q, r) + distr name in upper or lower case + R or C
    • first parametrization : dmbbefdR(), dmbbefdC()
    • second parametrization : dMBBEFDR(), dMBBEFDC()
  • for one-inflated distributions, append the letter (d, p, q, r) + oi + distr name in lower case
    • doi<origdistr>() for example doiunif()

How to choose between R and C++

  • for the MBBEFD distribution, do both R or C
    • first parametrization : dmbbefdR(), dmbbefdC()
    • second parametrization : dMBBEFDR(), dMBBEFDC()
    • for random generation (r), use C++
    • otherwise (d, p, q) use R
  • for one-inflated distributions, always use R

Name for the exposure curve function

  • for the MBBEFD distribution
    • first parametrization : ecmbbefd()
    • second parametrization : ecMBBEFD()
  • for base R distributions,
    • ec<origdistr>() for example ecunif()
  • for one-inflated distributions,
    • ecoi<origdistr>() for example ecoiunif()

Name for the moment and total loss functions

  • for the MBBEFD distribution
    • first parametrization : mmbbefd() and tlmbbefd()
    • second parametrization : mMBBEFD() and tlMBBEFD()
  • for base R distributions,
    • moments are already implemented in actuar
    • tl<origdistr>() for example tlunif()
  • for one-inflated distributions,
    • moi<origdistr>() for example moiunif()
    • tloi<origdistr>() for example tloiunif()

Mimic R functions

  • arguments
    • log for dfunc
    • log.p for pfunc and qfunc
    • lower.tail for pfunc and qfunc
  • NaN values
    • inconsistent probability p<0 or p>1
    • invalid parameter
  • recycling arguments : The numerical arguments other than n are recycled to the length of the result. Only the first elements of the logical arguments are used.
  • manual page : should take the R base template

Unit testing

  • do as much as possible unit testing.