ropenscilabs / statistical-software-review

Experiments for rOpenSci's project for peer review of statistical software
1 stars 0 forks source link

bumbl submission #2

Open mpadge opened 4 years ago

mpadge commented 4 years ago

Thanks @Aariq for volunteering to submit your bumbl package for trial "soft submission" to rOpenSci's new system for peer review of statistical software. This issue includes output from our automated assement and reporting tools developed as part of this new system. These currently function as the following two distinct components (which will be integrated later):

packgraph

library(packgraph)
packageVersion ("packgraph")
#> [1] '0.0.0.7'
package <- "/<local>/<path>/<to>/bumbl"

g <- pg_graph (package, plot = FALSE)
pg_report (g)
#> ══ bumbl ═══════════════════════════════════════════════════════════════════════
#> 
#> The package has 3 exported functions, and 2 non-exported funtions. The exported
#> functions are structured into the following 0 primary cluster containing
#> function
#> 
#> There are also 3 isolated functions:
#> 
#> 
#> |  n|name       | loc|
#> |--:|:----------|---:|
#> |  1|bumbl      | 115|
#> |  2|bumbl_plot |  42|
#> |  3|bumbl.nb   | 115|
#> 
#> ── Documentation of non-exported functions ─────────────────────────────────────
#> 
#> 
#> |value  | doclines| cmtlines|
#> |:------|--------:|--------:|
#> |mean   |       20|        7|
#> |median |       20|        7|

autotest

package <- "/<local>/<path>/<to>/bumbl"
library (autotest)
packageVersion ("autotest")
#> [1] '0.0.1.230'
x <- autotest_package (package)
#> Loading bumbl
#> ✔ [1 / 1]: bumbl
x$yaml_hash <- substring (x$yaml_hash, 1, 6)
knitr::kable (x, row.names = TRUE)
type fn_name parameter operation content yaml_hash
1 diagnostic bumbl data tabular structure with new class structure Function [bumbl] should error when class structure of data.frame input is removed. 0f67b3
2 error bumbl formula (unquoted) formula param as (quoted) character $ operator is invalid for atomic vectors 0f67b3
3 diagnostic bumbl augment substitute integer values for logical parameter Parameter augment of function [bumbl] is assumed to be logical, but responds to general integer values. 0f67b3
4 diagnostic bumbl augment substitute character values for logical parameter Parameter augment of function [bumbl] is assumed to be logical, but responds to character input 0f67b3
5 diagnostic bumbl augment length 2 vector for single-length parameter parameter [augment] is assumed to be a single value of logical type, yet admits vectors of length > 1 0f67b3
6 diagnostic bumbl NA compare class of return value with description Function returns an object of class [data.frame] yet documentation describes class of value as [dataframe] 0f67b3
7 diagnostic bumbl NA compare class of return value with description Function returns an object of primary class [bumbldf] yet documentation says value is of class [dataframe] 0f67b3
summary (x)
#> autotesting package [bumbl, v0.0.1.9000] generated 7 rows of output of the following types:
#>      1 error
#>      0 warnings
#>      0 messages
#>      6 other diagnosticss
#> That corresponds to 7 messages per documented function (which has examples)
#> 
#>   fn_name num_errors num_warnings num_messages num_diagnostics
#> 1   bumbl          1           NA           NA               6
#> 
#>     git hash for package as analysed here:
#>     [1bf981190f6d17a98e866b31138a1b10127942bc]

Created on 2020-09-27 by the reprex package (v0.3.0)

The output of autotest includes a column yaml_hash. This in turn refers to the yaml specification used to generate the autotests, which can be generated locally by running examples_to_yaml (<path>/<to>/<package>). Those contain the yaml_hash values, and finding the matching value will show you the base code used to trigger the diagnostic messages. The operation column should then provide a sufficient description of what has been mutated with regard to the structure defined in the yaml.

As there is only one primary function here, you should be able to address most of the aspects raised in the autotest output.

Aariq commented 4 years ago

I'm not sure I understand tests #2 or 6. For 2, is it suggesting that you should be able to pass a formula as a character vector? For 6, I have documented what is returned with @return, but maybe it doesn't pick this up because it uses an itemized list? Or am I just misunderstanding? Similarly, bumbl_plot does have an example.

mpadge commented 4 years ago

Thanks for the response @Aariq. This should help clarify:

For 2, is it suggesting that you should be able to pass a formula as a character vector?

Not necessarily, but it should certainly be interpreted as indicating an unhelpful error message, and a corresponding implication that either formulae as character vectors should be appropriately processed, or that appropriately informative errors be issued when that is done.

For 6, I have documented what is returned with @return, but maybe it doesn't pick this up because it uses an itemized list? Or am I just misunderstanding?

Thanks for that - this workflow is literally being test-run by, and developed in response to these submissions. The checking of return values has been updated in the output above, and should now make your suggested course of action clearer.

Similarly, bumbl_plot does have an example.

That was also a glitch which has now been rectified, and no longer appears in your output. Please feel free to ask here (or via private slack channels) about any further aspects which we or the code might have failed to clarify. Thanks!

mpadge commented 3 years ago

Thanks @Aariq for your submission and improvements that have already been made to the package. The few remaining diagnostic message produced by autotest can safely be ignored. (autotest will soon allow user control of which tests are actually performed, so the messages currently given for bumbl will be able to be switched off, and you should get a perfectly clean result. The switching-off will also enable you to explain why, with that information potentially used to inform reviewers.)

That means we are now able to proceed to the formal review stage, for which members of the project's advisory board @rkillick and @paula-moraga have kindly agreed to review your package. They are now requested to perform a two-stage review, the first part involving assessment of the package against the standards as they are currently drafted, with the second being a more "traditional" review. We hope, by the time we proceed to this second component, that many aspects which might otherwise have arisen within a "traditional" unstructured review will already have been covered, and will thereby make the review process notably easier.

Our review system will ultimately perform much of the preceding automated assessment prior to actual submission, and reviewers will be provided with a high-level interactive graphical overview of the package's functions and their inter-relationships. Fortunately here, the package has sufficiently few functions that the graph can just be pasted here in static form:

image

(That can be reproduced by running packgraph::pg_graph("/<local>/<path>/<to>/bumbl").)


Instructions for review

@rkillick and @paula-moraga, could you please now asses the bumbl package with respect to the current General Standards for Statistical Software, and the category-specific standards for Time Series Software.

Please do this in two phases:

In each case, please only note those standards which you judge the package not to conform to, along with a description of what you would expect this particular software package to do in order to conform to each standard. When you do that, please provide sufficient information on which standard you are referring to. (The standards themselves are all enumerated, but not yet at a necessarily stable state, so please provide enough information for anyone to clearly know which standard you are referring to regardless of potential changes in nomenclature.) Please also note as a separate list all those standards which you think should not apply to this package, along with brief explanations of why.

Importantly, to aid us in refining the standards which will ultimately guide the peer review of statistical software, we also ask you to please consider whether you perceive any aspects of software (design, functionality, algorithmic implementations or applications, testing, and any other aspects you can think of) which you think might be able to be addressed by standards, and yet which are not addressed by our standards in their current form.

To sum up, please post the following in this issue:

  1. Your 2 itemized lists of standards which the software initially failed to meet, along with an indication of which of that subset of standards the most recent version then actually meets. Please provide git hashes for the repository head in each case.
  2. An indication of any aspects of the software which you think are not addressed by the current standards yet could (potentially) be.

Once you've done that, we'll ask to you proceed to a more general review of the software, for which we'll provide more detail at that time. Thanks all for agreeing to be part of this!

mpadge commented 3 years ago

@rkillick, @Paula-Moraga Neglected one piece of important information:

Due date

We would like to have this review phase completed within 4 weeks, which we'll time from today, so by the 13th of November 2020. We accordingly suggest that you aim to have the first of the two tasks completed within two weeks, by the 30th October.

Could you both please also record approximately how much time you have spent on each review stage. Thank you!

mpadge commented 3 years ago

Update for reviewers @rkillick, @Paula-Moraga, note that this repo now includes an R package which enables you to get a pre-formatted checklist for your reviews (inspired by, and with gratitude to, co-board member @stephaniehicks) by running the following lines:

remotes::install_github("ropenscilabs/statistical-software-review")
library(statsoftrev) # the name of the package
rssr_standards_checklist (category = "time-series")

That will produce a markdown-formatted checklist in your clipboard ready to paste where you like, or you can use a filename parameter to specify a local file.

ping @noamross so you'll be notified of these conversations.

rkillick commented 3 years ago

Initial Review of Bumbl (git hash 1bf981): I've not used this package previously so this is a review as a newbie.

Applying General Software Standards:

Test coverage: bumbl Coverage: 89.96% R/plotting.R: 76.67% R/colony-growth.R: 91.63%

Applying Time Series software standards:

rkillick commented 3 years ago

NOTE: all my issues still arise in the new version (git hash ba1371), just the reference to line numbers is different.

rkillick commented 3 years ago

Not covered in standards but should be:

mpadge commented 3 years ago

Thanks @rkillick both for the checklist of points, and those final suggestions for improving the standards. It would be great if you could update current standards by inserting any new aspects which you think could or should be inserted - there are explicit instructions on the source repo for the standards.

@Aariq the next steps for you will be to make any modifications you deem necessary in response both to @rkillick's points above, and those of @Paula-Moraga. It's up to you whether you decide to already respond to these comments, or wait for equivalent comments from @Paula-Moraga.

Paula-Moraga commented 3 years ago

Standards that package fails to meet

git hash ba1371a

Documentation

Documentation should be improved. For example, the documentation of functions bumbl() and bumbl.nb() is the same and the user cannot understand the difference between the two functions unless they read the R code. The documentation says bumbl.nb(): passes arguments to MASS::glm.nb() rather than glm(). This is not enough to understand the differences between the two functions. The same happens with brkpt() and brkpt.nb(). The documentation should clearly state the purpose of each function.

Also the documentation of brkpt() says the value is "a tibble with a column for the winning tau and a column for the winning model". This description can be improved with an explanation of what is tau and what is the winning model.

The package does not provide the code to reproduce the results given in the reference provided (Crone and Williams (2016)).

Input Structures

Functions should check the type of arguments. For example, right now we can call bumbl() by providing a character value for taus.

bumbl(bombus, colonyID = colony, t = week, formula = d.mass ~ week, taus = "a")

Missing data are not checked.

The package does not provide options to handle missing data.

There are functions that could pass data with missing values to base routines with default na.rm = FALSE. For example, in line 45 of https://github.com/Aariq/bumbl/blob/master/R/colony-growth.R bumbl() executes

tvec <- data[[tvar]]
taus <- seq(min(tvec), max(tvec), length.out = 50)

where data[[tvar]] may have missing values:

bombus2 <- bombus
bombus2$week[1] <- NA 
out <- bumbl(bombus2, colonyID = colony, t = week, formula = d.mass ~ week)

The package does not provide options to handle undefined data.

Input data structures and validation

This is not well documented. For example, bumbl() documentation says argument data should be a data.frame but does not describe what should be the columns of this data,frame.

This is not done. The documentation does not explain the type of data that should be passed, and the R code does not check the arguments passed.

This is not done. For example, one can call bumbl() with data that has a character in argument t and this error is not handled.

bombus2 <- bombus
bombus2$week[1] <- "a" 
out <- bumbl(bombus2, colonyID = colony, t = week, formula = d.mass ~ week)

This is not done. There is some validation code at the beginning of the bumbl() function. Then other functions such as brkpt() do not execute this validation code.

Pre-processing and Variable Transformation

The package does not check for missing data. For example, one can execute bumbl() where one d.mass value is NA.

bombus2 <- bombus
bombus2$d.mass[1] <- NA
out <- bumbl(bombus2, colonyID = colony, t = week, formula = d.mass ~ week)

The package does not provide functions to specify how to handle missing data.

There are functions that could pass data with missing values to base routines with default na.rm = FALSE. For example, in line 45 of https://github.com/Aariq/bumbl/blob/master/R/colony-growth.R bumbl() executes

tvec <- data[[tvar]]
taus <- seq(min(tvec), max(tvec), length.out = 50)

where data[[tvar]] may have missing values:

bombus2 <- bombus
bombus2$week[1] <- NA 
out <- bumbl(bombus2, colonyID = colony, t = week, formula = d.mass ~ week)

Documentation should be improved to explain the type of arguments to be passed and possible assumptions.

Visualization

bumbl_plot() does not provide options to determine how to visualize missing data.

Plots clearly distinguish between data which are represented by points and model predictions which are represented with red lines, but a legend would help in understanding the plot better.

Other aspects not covered in the current standards

mpadge commented 3 years ago

Thanks so much @Paula-Moraga! Could you please give an estimate of how long you spent on that stage of the review?

And @Aariq this checklist was intentionally compared with your package at the time this issue was opened, not with current version. Could you please indicate whether current version has addressed all of those issues, or if not, then please notify here once you have either addressed all issues, or otherwise explained why you deem those issues not to be relevant. Thanks!

Paula-Moraga commented 3 years ago

@mpadge I took me around 3 hours to read the paper and review the package.

rkillick commented 3 years ago

@mpadge Similar amount of time for me, around 3.5 hours for the first pass and then an hour for the second pass. Faster the second time as I'd just done the first and was now familiar with the package!

Aariq commented 3 years ago

Thank you @rkillick and @Paula-Moraga for the comments! I made a lot of improvements (I think) based on your suggestions and I'll try to post a response to your comments in the next few days. Since there are a lot of comments, I think I will address both of your suggestions together, but break up my responses by the standard (e.g. G1, G2, G4, TS1, etc.)

Aariq commented 3 years ago

G1

G1.0 Statistical Software should list at least one primary reference from published academic literature.

\@rkillick:\ Not met as no paper reference in the documentation or package description

G1.1 All statistical terminology should be clarified and unambiguously defined.

\@rkillick:\ Not met. As one example the bumbl function states "Fits models" with no reference in the details for what model forms or assumptions are made - mathematically speaking.

G1.2 Software should use roxygen to documentation all functions.

\@Paula-Moraga:\ Documentation should be improved. For example, the documentation of functions bumbl() and bumbl.nb() is the same and the user cannot understand the difference between the two functions unless they read the R code. The documentation says bumbl.nb(): passes arguments to MASS::glm.nb() rather than glm(). This is not enough to understand the differences between the two functions.

\@Paula-Moraga:\ The same happens with brkpt() and brkpt.nb(). The documentation should clearly state the purpose of each function. Also the documentation of brkpt() says the value is "a tibble with a column for the winning tau and a column for the winning model". This description can be improved with an explanation of what is tau and what is the winning model.

G1.3 Software should include all code necessary to reproduce results which form the basis of performance claims made in associated publications.

\@rkillick:\ Not met. When I build the vignette I get errors on the convergence of the glm fit.

\@Paula-Moraga:\ The package does not provide the code to reproduce the results given in the reference provided (Crone and Williams (2016)).

Aariq commented 3 years ago

G2

G2.1 Provide explicit secondary documentation of expectations on data types of all vector inputs (see the above list).

\@rkillick:\ Not met. It is not clear that the columns of the data frame for input into the bumbl function need to be numeric

G2.3a Use match.arg() or equivalent where applicable to only permit expected values.

\@Paula-Moraga:\ Functions should check the type of arguments. For example, right now we can call bumbl() by providing a character value for taus.

G2.10 Statistical Software should implement appropriate checks for missing data as part of initial pre-processing prior to passing data to analytic algorithms.

\@rkillick:\ Not met. Checks are there for missing colony names and missing output but not for missing data in rows.\ \@Paula-Moraga:\ Missing data are not checked.

G2.11 Where possible, all functions should provide options for users to specify how to handle missing (NA) data

\@rkillick:\ Not met. No options for user-defined NA handling exist. \@Paula-Moraga:\ The package does not provide options to handle missing data.

G2.12 Functions should never assume non-missingness, and should never pass data with potential missing values to any base routines with default na.rm = FALSE-type parameters

\@rkillick:\ Not met. Mutate function called on line 324 of colony-growth.R function with na.rm=TRUE.

\@Paula-Moraga:\ There are functions that could pass data with missing values to base routines with default na.rm = FALSE. For example, in line 45 of https://github.com/Aariq/bumbl/blob/master/R/colony-growth.R

G2.13 All functions should also provide options to handle undefined values (e.g., NaN, Inf and -Inf), including potentially ignoring or removing such values.

\@rkillick:\ Not met. No handling of this in functions.

\@Paula-Moraga:\ The package does not provide options to handle undefined data.

Aariq commented 3 years ago

G4

G4.2b Explicit tests should demonstrate conditions which trigger every one of those messages, and should compare the result with expected values.

\@rkillick:\ Not met Example: Warning "Some taus were not used because they were outside of range of" not covered.

G4.4 Correctness tests to test that statistical algorithms produce expected results to some fixed test data sets.

\@rkillick:\ Not met, no correctness tests in testing, just class and no warnings. Skipping the rest of the guidelines for parameter correctness etc. as none are given. All not met.

G4.5 Correctness tests should be run with a fixed random seed.

\@rkillick:\ Not met. No seed in the sample command for the plotting example

G4.8 Edge condition tests to test that these conditions produce expected behaviour such as clear warnings or errors when confronted with data with extreme properties.

\@rkillick:\ Not met. None included.

G4.9 Noise susceptibility tests. Packages should test for expected stochastic behaviour.

\@rkillick:\ Not met. None included, I would expect to see small perturbations in the input data using jitter() to give the same output for tau and very similar parameter estimates.

G.4.10-12 Extended testing.

\@rkillick:\ All not met as no extended tests are provided. For this package longer datasets will cause problems with the default "taus" argument behaviour.

Aariq commented 3 years ago

TS1

TS1.0 Time Series Software should explicitly document the types and classes of input data able to be passed to each function

\@rkillick:\ Not met. Type assumptions in df are not described.

\@Paula-Moraga:\ This is not well documented. For example, bumbl() documentation says argument data should be a data.frame but does not describe what should be the columns of this data,frame.

TS1.1 Time Series Software should accept input data in as many time series specific classes as possible.

\@rkillick:\ No time series classes are supported. As such the user could enter the rows in the "wrong" unnatural time order and this is not checked by the software. This drastically affects all output and plotting.

\@Paula-Moraga:\ This is not done. The documentation does not explain the type of data that should be passed, and the R code does not check the arguments passed.

TS1.2 Time Series Software should implement validation routines to confirm that inputs are of acceptable classes

\@rkillick:\ Not met. No validation of inputs completed.

\@Paula-Moraga:\ This is not done. For example, one can call bumbl() with data that has a character in argument t and this error is not handled.

TS1.3 Time Series Software should implement a single pre-processing routine to validate input data, and to appropriately transform it to a single uniform type to be passed to all subsequent data-processing functions (the tsbox package provides one convenient approach for this).

\@Paula-Moraga:\ This is not done. There is some validation code at the beginning of the bumbl() function. Then other functions such as brkpt() do not execute this validation code.

TS1.7 Accept inputs defined via the units package for attributing SI units to R vectors.

\@rkillick:\ Not clear if this is supported or whether it should be.

TS1.8 Where time intervals or periods may be days or months, be explicit about the system used to represent such, particularly regarding whether a calendar system is used, or whether a year is presumed to have 365 days, 365.2422 days, or some other value.

\@rkillick:\ Documentation for bumbl function is woolly on this, needs clarification.

Aariq commented 3 years ago

TS2

TS2.0 Appropriate checks for missing data, and associated transformation routines, should be performed as part of initial pre-processing prior to passing data to analytic algorithms.

\@rkillick:\ No checks for missing data are completed.

\@Paula-Moraga:\ The package does not check for missing data.\ For example, one can execute bumbl() where one d.mass value is NA.

TS2.1 Time Series Software which presumes or requires regular data should only allow explicit* missing values, and should issue appropriate diagnostic messages, potentially including errors, in response to any implicit missing values.*

\@rkillick:\ No handling as no checks are made.

TS2.2 Where possible, all functions should provide options for users to specify how to handle missing data,

\@rkillick:\ No options are given to the user

\@Paula-Moraga:\ The package does not provide functions to specify how to handle missing data.

TS2.3 Functions should never assume non-missingness, and should never pass data with potential missing values to any base routines with default na.rm = FALSE-type parameters

TS2.5 Explicitly document all assumptions and/or requirements of stationarity

\@rkillick:\ Not met. Assumptions of independence also required to be clarified.

\@Paula-Moraga:\ Documentation should be improved to explain the type of arguments to be passed and possible assumptions.

TS2.6 Implement appropriate checks for all relevant forms of stationarity,

\@rkillick:\ Not met. In this instance, some model diagnostics would be appropriate.

Aariq commented 3 years ago

TS5

TS5.0 Implement default plot methods for any implemented class system.

\@rkillick:\ Not met. Should use the plot method.

TS5.5 Provide options to determine whether plots of data with missing values should generate continuous or broken lines

\@rkillick:\ No handling of missing values so not met.

\@Paula-Moraga:\ bumbl_plot() does not provide options to determine how to visualize missing data.

TS5.8 By default provide clear visual distinction between model (input) values and forecast (output) values.

\@Paula-Moraga:\ Plots clearly distinguish between data which are represented by points and model predictions which are represented with red lines, but a legend would help in understanding the plot better.

Aariq commented 3 years ago

Other Comments

It would be helpful to include in the documentation a description of the problems that the package can solve and a summary of the methods implemented without the need to look at the reference provided.

This description should be written in a way that is understandable for general users. For example, in this package terms such as "gyne" could be unknown for some users.

There is one reference to the method implemented but it is behind a paywall. If possible the reference should be accessible by everyone.

I think repeated code should be avoided. In this package, functions brkpt() and brkpt.nb(), and functions bumbl() and bumbl.nb() are very similar.

rkillick commented 3 years ago

G4

G4.2b Explicit tests should demonstrate conditions which trigger every one of those messages, and should compare the result with expected values.

@rkillick: Not met Example: Warning "Some taus were not used because they were outside of range of" not covered.

  • I added a test for this

G4.4 Correctness tests to test that statistical algorithms produce expected results to some fixed test data sets.

@rkillick: Not met, no correctness tests in testing, just class and no warnings. Skipping the rest of the guidelines for parameter correctness etc. as none are given. All not met.

  • I've added a function sim_colony() to simulate colony growth and decay data with the parameters used in the simulation returned as attributes.
  • sim_colony() is used to test that expected parameters are returned within some tolerance.

G4.5 Correctness tests should be run with a fixed random seed.

@rkillick: Not met. No seed in the sample command for the plotting example

  • added set.seed() to example
  • new correctness test run with fixed seed

G4.8 Edge condition tests to test that these conditions produce expected behaviour such as clear warnings or errors when confronted with data with extreme properties.

@rkillick: Not met. None included.

  • Data is passed to glm() with only slight modification, so I'm letting glm() handle those edge cases. I'll think about better ways to pass glm() errors to the user (e.g. additional columns in the output containing errors or warnings for each colony's GLM?).

G4.9 Noise susceptibility tests. Packages should test for expected stochastic behaviour.

@rkillick: Not met. None included, I would expect to see small perturbations in the input data using jitter() to give the same output for tau and very similar parameter estimates.

  • I added theses suggested tests

G.4.10-12 Extended testing.

@rkillick: All not met as no extended tests are provided. For this package longer datasets will cause problems with the default "taus" argument behaviour.

  • I'm not sure what is meant by "extended tests". I suspect the bombus dataset I included in the package is a typical size for bumblebee colony growth data.
  • In terms of length of the timeseries, I can see how only 50 values for tau might not be enough to find the maximum likelihood estimate for the switchpoint correctly. I've added a note to the documentation saying as much.

For the extended testing maybe you could include a catch in the function that returns a warning if you think that 50 values will be too small for larger datasets. In the longer term you may want to look at other packages such as changepoint and consider how your cost function may work inside their search functions. As the creator of changepoint I haven't thought about extensions to GLMs but would be interested in pursuing this separately if you are interested too. We have LM functionality currently being tested so would be a natural extension.

Aariq commented 3 years ago

For the extended testing maybe you could include a catch in the function that returns a warning if you think that 50 values will be too small for larger datasets. In the longer term you may want to look at other packages such as changepoint and consider how your cost function may work inside their search functions. As the creator of changepoint I haven't thought about extensions to GLMs but would be interested in pursuing this separately if you are interested too. We have LM functionality currently being tested so would be a natural extension.

I agree that the way bumbl finds the changepoint is not great, but I feel like improving it is beyond the scope of what I'm trying to do right now. I like the idea of adding a warning for larger datasets to increase the number of values to test. I will think about what the threshold for that warning should be.