Closed njtierney closed 1 year ago
This also presents an opportunity to consolidate the existing classes in the package.
Many of the existing classes are just there to control the print method - this could potentially be modified/simplified so that they are just one type of class with new attributes listed that then feed into the print method.
Then a smaller lighter class could be applied on top of that, which helps for example when identifying that the list of setting matrices contains model predictions, which can then be used when generating an NGM or similar.
It also means that we can just use two autoplot methods, one for a matrix with age information, and other for a list of matrices.
The trade off, I guess, is that when creating the new list of matrices, you define the description information that is given for printing when defining it, rather than specifying a custom print method for each one.
Here's a summary of the current classes. These first two contain autoplot methods, and the first one containing the prediction information is used in generate_ngm
"conmat_setting_prediction_matrix"
predict_setting_contacts()
conmat_setting_predictions
conmat_setting_matrix
"conmat_prediction_matrix"
conmat_age_matrix
All of these classes just contain the class information so that they can be used for their own print method - these three are just lists of matrices
"transmission_probability_matrix"
get_setting_transmission_matrices()
conmat_setting_matrix
"setting_vaccination_matrix"
apply_vaccination()
conmat_setting_matrix
"ngm_setting_matrix"
calculate_ngm()
conmat_setting_matrix
These two are different, the first is a list of data frames, one for each setting
get_polymod_setting_data()
This one is a list of models, one for each setting.
fit_setting_contacts()
, which is used in estimate_setting_contacts()
Thinking this through, here is the summary of changes
conmat_age_matrix
class, replaces conmat_prediction_matrix
conmat_prediction_matrix
--> conmat_age_matrix
new conmat_setting_matrix
class
new_conmat_setting_matrix
, provide information
for printingconmat_age_matrix
conmat_setting_prediction_matrix
replaced with two new classes:
conmat_setting_predictions
and conmat_setting_matrix
generate_ngm.conmat_setting_prediction_matrix --> generate_ngm.conmat_setting_predictions
autoplot.conmat_setting_prediction_matrix --> autoplot.conmat_setting_matrix
print.conmat_setting_prediction_matrix --> print.conmat_setting_matrix
The following classes will be removed and replaced like so:
After thinking this through I'm not convinced it is a good idea to simplify the classes - it involves some refactoring that feels a bit complicated at the moment and I'm not really clear on what the benefits are - outside of meaning we can only have fewer autoplot
methods, but the solution to this could be to write new autoplot functions for the new classes.
It would be useful to store some kind of "age breaks" attribute along with some of these objects, rather than just relying on the numbers or rows or columns, since those could be the same length, but represent different age breaks.
Related to #127