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

Improve the GSF model implementation #249

Merged
merged 17 commits into from
Feb 1, 2024
Merged

Improve the GSF model implementation #249

merged 17 commits into from
Feb 1, 2024

Conversation

gowerc
Copy link
Collaborator

@gowerc gowerc commented Dec 15, 2023

Closes #123

  • Extends the GSF model to have a centered argument so that users can toggle between the centered and non-centered parameterisations

  • There wasn't a natural conversion between centered and non-centered for the phi parameter so I have converted that to be a beta distribution in both cases (it appears to be stable in this formulation regardless.

  • Introduced a cron job that runs twice a month that runs the full joint GSF model as this unit test currently takes 30 minutes to run so didn't want to include it as part of the default run. This test checks that the model can recover known parameter values within the full model

  • Fixed a bug where the sparse matrix representation of subject -> visit mapping for the longitudinal data was incorrectly using a full intercept column instead of correctly specifying the index's for patient 1 in the first column

  • A handful of minor tweaks (added rounding to print messages, fixed some minor bugs that were blocking unit tests finishing)

  • Converted the GSF simulation function to just use the centered parameterisation (there was literally no point in this function using the non-centered parameterisation, it just made the code more complicated).

  • Includes a directory of example models that build up the GSF model in stages (can be removed as not needed for the package but figured it might be useful if we need to experiment in the future).

  • Added an up-to-date outline of the GSF model specification to the stats-specification vignette

  • For the non-centered parameterisation I converted the means to be on the log-scale so that the parameter estimates are consistent with the estimates in the centered parameterisation (as it is the log(mean) that you specify to the lognormal distribution).

@gowerc gowerc changed the title Fix/gsf bss Improve the GSF model implementation Dec 15, 2023
Copy link
Contributor

github-actions bot commented Dec 15, 2023

badge

Code Coverage Summary

Filename                       Stmts    Miss  Cover    Missing
---------------------------  -------  ------  -------  ---------------------------
R/brier_score.R                  166       0  100.00%
R/DataJoint.R                     76       2  97.37%   264, 270
R/DataLongitudinal.R             119       1  99.16%   245
R/DataSubject.R                   69       1  98.55%   124
R/DataSurvival.R                  74       1  98.65%   146
R/defaults.R                      13       7  46.15%   27, 45-84, 111
R/generics.R                      16       1  93.75%   69
R/JointModel.R                    91       6  93.41%   113-115, 204, 210, 216
R/JointModelSamples.R             54       0  100.00%
R/Link.R                          18       0  100.00%
R/LinkGSF.R                       69      13  81.16%   116-128
R/LinkNone.R                       5       1  80.00%   36
R/LinkRandomSlope.R               11       0  100.00%
R/LongitudinalGSF.R               40       0  100.00%
R/LongitudinalModel.R             17       0  100.00%
R/LongitudinalQuantities.R        85       8  90.59%   100-107
R/LongitudinalRandomSlope.R       22       0  100.00%
R/Parameter.R                     14       0  100.00%
R/ParameterList.R                 37       1  97.30%   175
R/Prior.R                        118       0  100.00%
R/Quantities.R                   105       0  100.00%
R/simulations_gsf.R               41       0  100.00%
R/simulations_os.R                11       5  54.55%   35-39
R/simulations_rs.R                21       0  100.00%
R/simulations.R                   99       1  98.99%   122
R/StanModel.R                     14       0  100.00%
R/StanModule.R                   175       6  96.57%   197-198, 240, 251, 386, 414
R/SurvivalExponential.R           10       0  100.00%
R/SurvivalLoglogistic.R           11       0  100.00%
R/SurvivalModel.R                 19       0  100.00%
R/SurvivalQuantities.R           151       6  96.03%   173-178
R/SurvivalWeibullPH.R             11       0  100.00%
R/utilities.R                    145       1  99.31%   13
R/zzz.R                           11      11  0.00%    4-29
TOTAL                           1938      72  96.28%

Diff against main

Filename               Stmts    Miss  Cover
-------------------  -------  ------  --------
R/JointModel.R             0      -2  +2.20%
R/LongitudinalGSF.R      +16       0  +100.00%
R/Prior.R                 +1       0  +100.00%
R/simulations_gsf.R       -2       0  +100.00%
TOTAL                    +15      -2  +0.13%

Results for commit: 887a170

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Dec 15, 2023

Unit Tests Summary

  1 files   34 suites   2m 16s ⏱️
100 tests  75 ✅ 25 💤 0 ❌
340 runs  315 ✅ 25 💤 0 ❌

Results for commit 887a170.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 15, 2023

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
JointModelSamples 💚 $31.19$ $-25.67$ $0$ $0$ $0$ $0$
LongitudinalGSF 💚 $60.11$ $-2.34$ $+3$ $+1$ $0$ $0$
LongitudinalQuantiles 💚 $40.89$ $-26.48$ $0$ $0$ $0$ $0$
SurvivalExponential 💚 $26.94$ $-20.74$ $0$ $0$ $0$ $0$
brierScore 💚 $26.69$ $-21.73$ $0$ $0$ $0$ $0$
extract_quantities 💚 $14.81$ $-14.48$ $0$ $0$ $0$ $0$
misc_models 💚 $21.15$ $-20.30$ $0$ $0$ $0$ $0$
model_random_slope_2chain 💚 $35.64$ $-26.33$ $0$ $0$ $0$ $0$
stan_functions 💚 $46.09$ $-44.88$ $0$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
JointModelSamples 💚 $31.19$ $-25.67$ smoke_test_for_JointModelSamples
LongitudinalGSF 👶 $+28.72$ Can_recover_known_distributional_parameters_from_a_full_GSF_joint_model
LongitudinalGSF 👶 $+0.38$ Centralised_parameterisation_compiles_without_issues
LongitudinalGSF 💀 $59.88$ $-59.88$ LongitudinalGSF_works_as_expected_with_a_single_study
LongitudinalGSF 👶 $+28.44$ Non_Centralised_parameterisation_compiles_without_issues
LongitudinalQuantiles 💚 $35.28$ $-26.25$ Test_that_LongitudinalQuantities_works_as_expected
SurvivalExponential 💚 $23.52$ $-20.74$ SurvivalExponential_can_recover_true_parameter_no_covariates_
brierScore 💚 $26.56$ $-21.72$ brierScore_SurvivalQuantities_returns_same_results_as_survreg
extract_quantities 💚 $14.81$ $-14.48$ extract_quantities_works_as_expected
misc_models 💚 $21.15$ $-20.30$ Longitudinal_Model_doesn_t_print_sampler_rejection_messages
model_random_slope_2chain 💚 $35.64$ $-26.33$ Can_recover_known_distribution_parameters_from_random_slope_model_when_using_multiple_chains
stan_functions 💚 $15.61$ $-15.18$ GSF_Identity_Link_Function_works_as_expected
stan_functions 💚 $15.18$ $-14.83$ GSF_SLD_function_works_as_expected
stan_functions 💚 $15.30$ $-14.88$ Normal_Log_Density_functions_work_as_expected

Results for commit e6412cc

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@danielinteractive danielinteractive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gowerc , lots of work here, please see few comments below

R/LongitudinalGSF.R Outdated Show resolved Hide resolved
R/LongitudinalGSF.R Outdated Show resolved Hide resolved
vignettes/statistical-specification.Rmd Outdated Show resolved Hide resolved
vignettes/statistical-specification.Rmd Outdated Show resolved Hide resolved
@gowerc
Copy link
Collaborator Author

gowerc commented Jan 31, 2024

@danielinteractive - I have addressed the comments you made, please let me know if there is anything else

@gowerc gowerc merged commit 30e398c into main Feb 1, 2024
24 checks passed
@gowerc gowerc deleted the fix/gsf-bss branch February 1, 2024 08:48
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

Successfully merging this pull request may close these issues.

GSF model converges but has poor diagnostic properties
2 participants