Skip to contents

movedata2networkDynamic() converts movenet-format movement and (optional) holding data tibbles into a networkDynamic temporal network representation. This assumes the network is directed with no loops, no hyperedges, and no multiplex edges.

Usage

movedata2networkDynamic(
  movement_data,
  holding_data = NULL,
  incl_nonactive_holdings = FALSE
)

Arguments

movement_data

A movenet-format movement data tibble.

holding_data

A movenet-format holding data tibble (optional).

incl_nonactive_holdings

A logical that indicates whether to include holdings from holding_data that are not present in movement_data. Default is FALSE. If set to TRUE, holdings that don't trade within the period covered by movement_data are included in the network but set as non-active throughout the observation period.

Value

A networkDynamic object consisting of a directed temporal network, with nodes representing holdings, and edges representing connections between holdings. Moves are represented as edge spells (times at which edges are considered active). Additionally, information is printed out about the assumptions made while constructing the network; this output is passed on from networkDynamic::networkDynamic().

Details

For compatibility with the networkDynamic package, node identifiers need to be consecutive integers between 1 and the number of nodes in the network (total number of holdings if incl_nonactive_holdings == TRUE, or number of active holdings if incl_nonactive_holdings == FALSE). If holding identifiers do not meet this condition, new integer identifiers are assigned, in a random order. Original holding identifiers are stored as node attribute true_id and set as persistent ids.

Any movement_data columns beyond from, to and date are set as dynamic edge attributes in the network, and any holding_data columns beyond id are set as unchanging node attributes.

Nodes and edges are set as active only on each movement date associated with the node or edge. Each activity spell is considered instantaneous: the activity occurs on the movement date, but has duration 0.

See also

Other network-related functions: create_temporal_network_analysis_report(), movedata2igraph(), parallel_summarise_temporal_node_properties(), trace_contact_chains()

Examples

movement_data <- head(example_movement_data, 20)
holding_data <- head(example_holding_data, 20)

# Create a network using only movement_data
movedata2networkDynamic(movement_data)
#> Warning: Node identifiers (vertex.id) have been changed to consecutive integers. Original
#> identifiers have been set as persistent identifiers (vertex.pid) and can be
#> identified for each node by running `get.vertex.pid(network_name, vertex.id)`.
#> NetworkDynamic properties:
#>   distinct change times: 20 
#>   maximal time range: 17902 until  18249 
#> 
#>  Dynamic (TEA) attributes:
#>   Edge TEAs:    movement_reference.active 
#>      qty_pigs.active 
#> 
#> Includes optional net.obs.period attribute:
#>  Network observation period info:
#>   Number of observation spells: 1 
#>   Maximal time range observed: 17902 until 18249 
#>   Temporal mode: continuous 
#>   Time unit: unknown 
#>   Suggested time increment: NA 
#> 
#>  Network attributes:
#>   vertices = 40 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   net.obs.period: (not shown)
#>   weight = qty_pigs 
#>   vertex.pid = true_id 
#>   total edges= 20 
#>     missing edges= 0 
#>     non-missing edges= 20 
#> 
#>  Vertex attribute names: 
#>     active true_id vertex.names 
#> 
#>  Edge attribute names: 
#>     active movement_reference.active qty_pigs.active 

# Create a network using movement_data and holding_data, including only
# active holdings
movedata2networkDynamic(movement_data, holding_data,
                        incl_nonactive_holdings = FALSE)
#> Warning: Node identifiers (vertex.id) have been changed to consecutive integers. Original
#> identifiers have been set as persistent identifiers (vertex.pid) and can be
#> identified for each node by running `get.vertex.pid(network_name, vertex.id)`.
#> NetworkDynamic properties:
#>   distinct change times: 20 
#>   maximal time range: 17902 until  18249 
#> 
#>  Dynamic (TEA) attributes:
#>   Edge TEAs:    movement_reference.active 
#>      qty_pigs.active 
#> 
#> Includes optional net.obs.period attribute:
#>  Network observation period info:
#>   Number of observation spells: 1 
#>   Maximal time range observed: 17902 until 18249 
#>   Temporal mode: continuous 
#>   Time unit: unknown 
#>   Suggested time increment: NA 
#> 
#>  Network attributes:
#>   vertices = 40 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   net.obs.period: (not shown)
#>   weight = qty_pigs 
#>   vertex.pid = true_id 
#>   total edges= 20 
#>     missing edges= 0 
#>     non-missing edges= 20 
#> 
#>  Vertex attribute names: 
#>     active coordinates herd_size holding_type true_id vertex.names 
#> 
#>  Edge attribute names: 
#>     active movement_reference.active qty_pigs.active 

# Create a network using movement_data and holding_data, including both
# active and non-active holdings
movedata2networkDynamic(movement_data, holding_data,
                        incl_nonactive_holdings = TRUE)
#> Warning: Node identifiers (vertex.id) have been changed to consecutive integers. Original
#> identifiers have been set as persistent identifiers (vertex.pid) and can be
#> identified for each node by running `get.vertex.pid(network_name, vertex.id)`.
#> NetworkDynamic properties:
#>   distinct change times: 20 
#>   maximal time range: 17902 until  18249 
#> 
#>  Dynamic (TEA) attributes:
#>   Edge TEAs:    movement_reference.active 
#>      qty_pigs.active 
#> 
#> Includes optional net.obs.period attribute:
#>  Network observation period info:
#>   Number of observation spells: 1 
#>   Maximal time range observed: 17902 until 18249 
#>   Temporal mode: continuous 
#>   Time unit: unknown 
#>   Suggested time increment: NA 
#> 
#>  Network attributes:
#>   vertices = 57 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   net.obs.period: (not shown)
#>   weight = qty_pigs 
#>   vertex.pid = true_id 
#>   total edges= 20 
#>     missing edges= 0 
#>     non-missing edges= 20 
#> 
#>  Vertex attribute names: 
#>     active coordinates herd_size holding_type true_id vertex.names 
#> 
#>  Edge attribute names: 
#>     active movement_reference.active qty_pigs.active 

rm(movement_data, holding_data)