idem-lab / conmat

Create Contact Matrices from Population Data
https://idem-lab.github.io/conmat/dev/
Other
17 stars 2 forks source link

Store "age breaks" attribute of contact matrices #128

Closed njtierney closed 1 year ago

njtierney commented 1 year ago

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

njtierney commented 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

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

These two are different, the first is a list of data frames, one for each setting

This one is a list of models, one for each setting.

Thinking this through, here is the summary of changes

First stage - replace the single matrix component:

Second stage: simplify the other matrix classes

The following classes will be removed and replaced like so:

njtierney commented 1 year ago

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.