as_cascade_wide: Transform wide data to cascade

Description Usage Arguments Details Value Examples

Description

Create a cascade object from data in wide format.

Usage

1
as_cascade_wide(data, node_names = NULL)

Arguments

data

data.frame or matrix, rows corresponding to nodes, columns to cascades. Matrix entries are the event times for each node, cascade pair. Missing values indicate censored observations, that is, nodes that did not have an event). Specify column and row names if cascade and node ids other than integer sequences are desired. Note that, if the time column is of class date or any other special time class, it will be converted to an integer with 'as.numeric()'.

node_names

character, factor or numeric vector, containing names for each node. Optional. If not provided, node names are inferred from the provided data.

Details

If data is in wide format, each row corresponds to a node and each column to a cascade. Each cell indicates the event time for a node - cascade combination. If a node did not experience an event for a cascade (the node is censored) the cell entry must be NA.

Value

An object of class cascade. This is a list containing three (named) elements:

  1. "node_names" A character vector of node names.

  2. "cascade_nodes" A list with one character vector per cascade containing the node names in order of the events.

  3. "cascade_times" A list with one element per cascade containing the event times for the nodes in "cascade_names".

Examples

1
2
3
4
5
6
data("policies")
cascades <- as_cascade_long(policies, cascade_node_name = 'statenam', 
                            event_time = 'adopt_year', cascade_id = 'policy')
wide_policies = as.matrix(cascades)
cascades <- as_cascade_wide(wide_policies)
is.cascade(cascades)

NetworkInference documentation built on May 1, 2019, 9:20 p.m.