Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize output #31

Closed
wleoncio opened this issue Apr 21, 2022 · 4 comments
Closed

Standardize output #31

wleoncio opened this issue Apr 21, 2022 · 4 comments
Assignees

Comments

@wleoncio
Copy link
Member

wleoncio commented Apr 21, 2022

Not sure if fixing #27 will consequently solve this, but something could be done to standardize the output of similar functions. See, for example, how Wald_CI_1x2(X = 250, n = 533) outputs a vector whereas LR_CI_1x2(X = 13, n = 16) outputs a string.

Here's a list of remaining functions:

  • Adjusted_inv_sinh_CI_OR_2x2
  • Adjusted_inv_sinh_CI_ratio_2x2
  • Adjusted_log_CI_2x2
  • AgrestiCaffo_CI_2x2
  • AgrestiCoull_CI_1x2
  • BaptistaPike_exact_conditional_CI_2x2
  • BaptistaPike_midP_CI_2x2
  • Bhapkar_test_paired_cxc
  • Blaker_exact_CI_1x2
  • Blaker_exact_test_1x2
  • Blaker_midP_CI_1x2
  • Arcsine_CI_1x2
  • Blaker_midP_test_1x2
  • BonettPrice_hybrid_Wilson_score_CI_CC_paired_2x2
  • BonettPrice_hybrid_Wilson_score_CI_paired_2x2
  • Bonferroni_type_CIs_paired_cxc
  • Bonferroni_type_CIs_rxc
  • Brant_test_2xc
  • BreslowDay_homogeneity_test_stratified_2x2
  • Chacko_test_1xc
  • ClopperPearson_exact_CI_1x2_beta_version
  • ClopperPearson_exact_CI_1x2
  • ClopperPearson_midP_CI_1x2
  • Cochran_Q_test_stratified_2x2
  • CochranArmitage_CI_rx2
  • CochranArmitage_exact_cond_midP_tests_rx2
  • CochranArmitage_MH_tests_rx2
  • CochranMantelHaenszel_test_stratified_2x2
  • Cornfield_exact_conditional_CI_2x2
  • Cornfield_midP_CI_2x2
  • Cumulative_models_for_2xc
  • Cumulative_models_for_rxc
  • Exact_binomial_test_1x2
  • Exact_cond_midP_linear_rank_tests_2xc
  • Exact_cond_midP_tests_rxc
  • Exact_cond_midP_unspecific_ordering_rx2
  • Exact_multinomial_test_1xc(1:3, seq
  • Exact_unconditional_test_2x2
  • Fisher_exact_test_2x2
  • Exact_unconditional_test_2x2
  • Fisher_midP_test_2x2
  • FisherFreemanHalton_asymptotic_test_rxc
  • FleissEveritt_test_paired_cxc
  • FleissLevinPaik_test_paired_cxc
  • gamma_coefficient_rxc_bca
  • gamma_coefficient_rxc
  • Gart_adjusted_logit_CI_2x2
  • Gold_Wald_CIs_1xc
  • Goodman_Wald_CIs_1xc
  • Goodman_Wald_CIs_for_diffs_1xc
  • Goodman_Wilson_score_CIs_1xc
  • Independence_smoothed_logit_CI_2x2
  • Inv_sinh_CI_OR_2x2
  • Inv_sinh_CI_ratio_2x2
  • InverseVariance_estimate_stratified_2x2
  • Jeffreys_CI_1x2
  • JonckheereTerpstra_test_rxc
  • Katz_log_CI_2x2
  • Kendalls_tau_b_rxc_bca
  • Kendalls_tau_b_rxc
  • Koopman_asymptotic_score_CI_2x2
  • KruskalWallis_asymptotic_test_rxc
  • linear_by_linear_test_rxc
  • LR_CI_1x2
  • LR_test_1x2
  • LR_test_1xc
  • LR_test_2x2
  • MantelHaenszel_estimate_stratified_2x2
  • MantelHaenszel_test_2xc
  • McNemar_asymptotic_test_CC_paired_2x2
  • McNemar_asymptotic_test_paired_2x2
  • McNemar_exact_cond_test_paired_2x2
  • McNemar_exact_unconditional_test_paired_2x2
  • McNemar_midP_test_paired_2x2
  • McNemarBowker_test_paired_cxc
  • Mee_asymptotic_score_CI_2x2
  • MidP_binomial_test_1x2
  • MidP_multinomial_test_1xc
  • MiettinenNurminen_asymptotic_score_CI_difference_2x2
  • MiettinenNurminen_asymptotic_score_CI_OR_2x2
  • MiettinenNurminen_asymptotic_score_CI_ratio_2x2
  • ML_estimates_and_CIs_stratified_2x2
  • MOVER_R_Wilson_CI_OR_2x2
  • MOVER_R_Wilson_CI_ratio_2x2
  • MOVER_Wilson_score_CI_paired_2x2
  • Newcombe_hybrid_score_CI_2x2
  • Newcombe_square_and_add_CI_paired_2x2
  • Pearson_chi_squared_test_1xc(n, runif
  • Pearson_chi_squared_test_2x2
  • Pearson_chi_squared_test_CC_2x2
  • Pearson_correlation_coefficient_rxc_bca
  • Pearson_correlation_coefficient_rxc
  • Pearson_LR_homogeneity_test_stratified_2x2
  • Pearson_LR_test_common_effect_stratified_2x2
  • Pearson_LR_tests_cum_OR_2xc
  • Pearson_LR_tests_rxc
  • Pearson_LR_tests_unspecific_ordering_rx2
  • Pearson_residuals_rxc
  • Peto_homogeneity_test_stratified_2x2
  • Peto_OR_estimate_stratified_2x2
  • PriceBonett_approximate_Bayes_CI_2x2
  • QuesenberryHurst_Wilson_score_CIs_1xc
  • RBG_test_and_CI_stratified_2x2
  • Scheffe_type_CIs_paired_cxc
  • Scheffe_type_CIs_rxc
  • Score_test_1x2
  • Score_test_and_CI_marginal_mean_scores_paired_cxc
  • Score_test_CC_1x2
  • Score_test_for_effect_in_the_probit_model_2xc
  • Spearman_correlation_coefficient_rxc_bca
  • Spearman_correlation_coefficient_rxc
  • stratified_2x2_tables
  • Stuart_test_paired_cxc
  • Tang_asymptotic_score_CI_paired_2x2
  • Tango_asymptotic_score_CI_paired_2x2
  • the_1x2_table_CIs
  • the_1x2_table_tests
  • the_1xc_table_CIs
  • the_1xc_table_tests
  • the_2x2_table_CIs_difference
  • the_2x2_table_CIs_OR
  • the_2x2_table_CIs_ratio
  • the_2x2_table_tests
  • the_2xc_table
  • the_paired_2x2_table_CIs_difference
  • the_paired_2x2_table_CIs_OR
  • the_paired_2x2_table_CIs_ratio
  • the_paired_2x2_table_tests
  • the_paired_cxc_table_nominal
  • the_paired_cxc_table_ordinal
  • the_rx2_table
  • the_rxc_table
  • Transformed_Blaker_exact_CI_paired_2x2
  • Transformed_Clopper_Pearson_exact_CI_paired_2x2
  • Transformed_Clopper_Pearson_midP_CI_paired_2x2
  • Transformed_Wilson_score_CI_paired_2x2
  • Trend_estimate_CI_tests_rx2
  • Uncorrected_asymptotic_score_CI_2x2
  • Wald_CI_1x2
  • Wald_CI_2x2
  • Wald_CI_AgrestiMin_paired_2x2
  • Wald_CI_BonettPrice_paired_2x2
  • Wald_CI_CC_1x2
  • Wald_CI_CC_2x2
  • Wald_CI_diff_CC_paired_2x2
  • Wald_CI_diff_paired_2x2
  • Wald_CI_OR_Laplace_paired_2x2
  • Wald_CI_OR_paired_2x2
  • Wald_CI_ratio_paired_2x2
  • Wald_test_1x2
  • Wald_test_and_CI_common_diff_stratified_2x2
  • Wald_test_and_CI_common_ratio_stratified_2x2
  • Wald_test_and_CI_marginal_mean_ranks_paired_cxc
  • Wald_test_and_CI_marginal_mean_scores_paired_cxc
  • Wald_test_CC_1x2
  • Wilson_score_CI_1x2
  • Wilson_score_CI_CC_1x2
  • Woolf_logit_CI_2x2
  • Woolf_test_and_CI_stratified_2x2
  • Z_unpooled_test_2x2

A convenient way to work through the list is by using the https://github.com/ocbe-uio/contingencytables/blob/b0acdc14fd27c3616bf37d55ffab33d9b110c89b/tests/testthat/test-outputFormat.R file.

@wleoncio wleoncio added this to the MVP for 1.1.0 milestone Apr 21, 2022
@wleoncio
Copy link
Member Author

The test starting on this line hows the different outputs to be reduced.

test_that("Output classes are the expected", {

wleoncio added a commit that referenced this issue Aug 24, 2022
For descriptiveness sake; may also reduce confusion when #31 is worked on
@wleoncio
Copy link
Member Author

wleoncio commented Aug 24, 2022

  • Change output of all functions to their own class
  • Create a print() method for this class, remember to output with invisible()
  • Supersede printresults argument

@wleoncio wleoncio self-assigned this Sep 1, 2022
wleoncio added a commit that referenced this issue Sep 1, 2022
Functions now output an object of class contingencytables_output, a
method of which is created for `print()`. Unit tests are adapted
accordingly.
wleoncio added a commit that referenced this issue Sep 1, 2022
Planning ahead for unit test breakage caused by further development of #31.
wleoncio added a commit that referenced this issue Sep 2, 2022
This should accommodate different sets of output, since the class is defined (as best as S3 can, that is) as a list of `name` and `statistics`.
wleoncio added a commit that referenced this issue Sep 2, 2022
wleoncio added a commit that referenced this issue Sep 2, 2022
wleoncio added a commit that referenced this issue Oct 28, 2022
wleoncio added a commit that referenced this issue Jan 18, 2023
In preparation for creation of subclasses to better organize printing methods
wleoncio added a commit that referenced this issue Jan 18, 2023
On second though, it may be better to just have the two subclasses as their own thing. They can be grouped into a superclass if it makes sense, in the future.
wleoncio added a commit that referenced this issue Jan 18, 2023
wleoncio added a commit that referenced this issue Jan 19, 2023
wleoncio added a commit that referenced this issue Jan 19, 2023
Saves one line per function, so around 160 lines in gross (120 net)
total.
wleoncio added a commit that referenced this issue Jan 19, 2023
New idea: giving the instantiator the same name as the class.
wleoncio added a commit that referenced this issue Jan 20, 2023
Improved output of Exact_unconditional_test_2x2 (#31)

Improved output of Fisher exact and midP (#31)

Improved output of FisherFreemanHalton_asymptotic_test_rxc (#31)

Improved output of FleissEveritt_test_paired_cxc (#31)

Improved output of gamma_coefficient_rxc_bca (#31)

Improved output of gamma_coefficient_rxc (#31)

Improved output of Gart_adjusted_logit_CI_2x2 (#31)

Improved output of Gold_Wald_CIs_1xc (#31)

Improved output of Goodman_Wald_CIs_1xc (#31)

Improved output of Goodman_Wald_CIs_for_diffs_1xc (#31)

Improved output of Goodman_Wilson_score_CIs_1xc (#31)
@wleoncio
Copy link
Member Author

We should try having the print format be an attribute. This way, we could retain backwards-compatibility because the statistics elements could be moved up I've level. As a bonus, the print format stays hidden (user doesn't care about it anyway).

@wleoncio
Copy link
Member Author

One potential issue to the above would be that we would end up with a class with a dynamic amount of attributes instead of the current standard in development. Might not be such a big deal, but something to briefly consider.

wleoncio added a commit that referenced this issue Feb 23, 2023
Should supersede the previous one once things are a bit more mature. As
a proof-of-concept, applies the new class to a function. Working through the functions alfabetically will automatically resolve issue #42.
wleoncio added a commit that referenced this issue Feb 24, 2023
wleoncio added a commit that referenced this issue Feb 24, 2023
wleoncio added a commit that referenced this issue May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant