digivet-consortium / movenet

Generating network representations for livestock movement (and associated) data
https://digivet-consortium.github.io/movenet/
GNU General Public License v3.0
2 stars 3 forks source link

data2contactmatrix: what to do with active holdings with no coordinates (or not included in alternative tm matrix)? #54

Closed CarlijnB closed 1 year ago

CarlijnB commented 1 year ago

data2contactmatrix: what to do with active holdings with no coordinates (or not included in alternative tm matrix)?

Holdings included in holding_data, but not in movement_data, are not a problem: they're simply inactive and movements can be set to 0. On the other hand, holdings included in movement_data, but with no coordinates in holding_data, have distance-based transmission probability = NA ... which means that overall transmission probabilities can't be calculated (or are known to NOT include distance-based transmission). What to do with these?

Similarly, when adding an additional transmission probability matrix - what to do with any holdings that are not included in this matrix and/or NA in the distance matrix?

image

CarlijnB commented 1 year ago

For No/No/Yes, for now I'm coding for these holdings to be filtered out. When replacing alternative tm matrix holding ids with numeric holding ids (approx. lines 102-107 in data2contactmatrix.R; required to match up with numeric ids from holding_data and movement_data), holding ids not included in the key are automatically turned into NAs. These are then omitted from alternative tm matrices.

If instead choosing to keep these holding ids in, need to add rows for these ids in holding_data before running holdingids2consecints.

CarlijnB commented 1 year ago
CarlijnB commented 1 year ago

Error message for accept_missing_coordinates: Error: Assertion on 'holding_data["coordinates"]' failed: Contains empty geometries (missing coordinates; row 10). To proceed with missing coordinates, use 'accept_missing_coordinates = TRUE'. This wil set local spread transmission probabilities to/from holdings with missing coordinates to 0.

+ changed reference from row to holding identifiers in the argument check call, and removed the reference in the create_local_spread_matrix call (because by then identifiers have been changed to numeric form, not easily identifiable).

CarlijnB commented 1 year ago

Implemented a similar argument, error / warning solution for the additional matrices - Yes/No/No no longer filtered out.

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

Movement | Holding | Alternative tm | Action -- | -- | -- | -- Yes | Yes |   | Included No | No |   | Don't exist Yes | No |   | Included if accept_missing_coordinates = TRUE (only movement-based tm), else ERROR No | Yes |   | Included if incl_nonactive_holdings = TRUE (only distance-based local tm), else active holdings only   |   |   |   Yes | Yes | Yes | Included Yes | Yes | No | Included if accept_missing_alt_tm_prob = TRUE, else ERROR No | Yes | Yes | Included if incl_nonactive_holdings = TRUE (distance-based local tm & alternative tm), else active holdings only Yes | No | Yes | Included if accept_missing_coordinates = TRUE (movement-based & alternative tm), else ERROR Yes | No | No | Included if accept_missing_coordinates = TRUE && accept_missing_alt_tm_prob = TRUE No | Yes | No | Included if incl_nonactive_holdings = TRUE && accept_missing_alt_tm_prob = TRUE No | No | Yes | Included if incl_nonactive_holdings = TRUE && accept_missing_coords = TRUE No | No | No | Don't exist