These functions impute what a network did not observe:

  • impute_ties() imputes the ties a network records as missing, and the values of the ties it records as incomplete.

  • impute_nodes() imputes the attributes of the nodes it records as incomplete.

  • to_imputed() runs both in a single call.

A network is missing a tie where the tie itself was not observed, so that whether it exists is not known. A tie or a node is incomplete where it is there and observed, but an attribute of it is not known, such as the strength of a tie or the age of a node. Imputing the first is a question of existence, and imputing the second is a question of value, so each takes its own rules.

If there is nothing to impute, the network data is returned unaltered and no warning is given, so that these functions can be used to ensure conformance.

impute_ties(
  .data,
  rule = c("zero", "density", "reciprocity", "indegree", "mean", "median", "modal"),
  which = c("nonresponse", "unrecorded", "incomplete")
)

impute_nodes(
  .data,
  rule = c("modal", "mean", "median", "neighbourhood"),
  attribute = NULL
)

to_imputed(.data, ties = "zero", nodes = "modal")

Arguments

.data

An object of a {manynet}-consistent class:

  • adjacency or incidence matrix from {base} R

  • edgelist data.frame from {base} R or tbl/tbl_df from {tibble}

  • stocnet stocnet, from the {manynet} package

  • igraph igraph, from the {igraph} package

  • network network, from the {network} package

  • tidygraph tbl_graph, from the {tidygraph} package

rule

How the imputed value is arrived at. See the Rules section for the options and what each does. By default "zero".

which

Which of the states a tie can be in to impute, one or more of "nonresponse", "unrecorded", and "incomplete". See the four states section. By default all three.

attribute

A character vector naming the node attributes to impute. By default NULL, which imputes every attribute that holds a missing value.

ties

The rule to_imputed() passes to impute_ties(), or NULL to leave the ties alone.

nodes

The rule to_imputed() passes to impute_nodes(), or NULL to leave the nodes alone.

Value

An object of the same class as the function was given, modified as explained in the function description, details, or section. Functions that split a network return a list of such objects.

What is recorded

Imputation manufactures data, so what was imputed, how much of it, and by which rule is recorded under the "imputation" name of the network's transformations, which describe_transformations() describes. Item 4.6 of the GRAND guidelines asks for the imputation method and the number of nodes or ties that were imputed, and places it among the transformations of raw data into analytic data, beside symmetrising, dichotomising, projecting, and aggregating, which is where the other to_*() functions record themselves.

One entry is added for the missing ties, one for the incomplete tie values, and one for each node attribute, so that a reader can tell which attributes hold manufactured values and which were observed throughout:

as_infolist(to_imputed(ison_classmates))$transformations$imputation
#> "73 missing ties (zero)"  "4 incomplete 'religion' values (modal)" ...

The element accumulates rather than replaces, so a network imputed in more than one step reports each of them in order. A matrix or an edgelist has nowhere to hold information about itself, so nothing is recorded for those two classes.

References

On missing data

Krause, Robert, Mark Huisman, Christian Steglich, and Tom A.B. Snijders. 2020. "Missing data in cross-sectional networks: An extensive comparison of missing data treatment methods". Social Networks, 62: 99-112. doi:10.1016/j.socnet.2020.02.004

Examples

missTest <- ison_adolescents |>
   add_tie_attribute("weight", c(1,NA,NA,1,1,1,NA,NA,1,1)) |>
   as_matrix()
missTest
#>       Betty Sue Alice Jane Dale Pam Carol Tina
#> Betty     0   1     0    0    0   0     0    0
#> Sue       1   0    NA    0    1  NA     0    0
#> Alice     0  NA     0   NA    1  NA     0    0
#> Jane      0   0    NA    0    1   0     0    0
#> Dale      0   1     1    1    0   0     0    0
#> Pam       0  NA    NA    0    0   0     1    0
#> Carol     0   0     0    0    0   1     0    1
#> Tina      0   0     0    0    0   0     1    0
impute_ties(missTest)
#>       Betty Sue Alice Jane Dale Pam Carol Tina
#> Betty     0   1     0    0    0   0     0    0
#> Sue       1   0     0    0    1   0     0    0
#> Alice     0   0     0    0    1   0     0    0
#> Jane      0   0     0    0    1   0     0    0
#> Dale      0   1     1    1    0   0     0    0
#> Pam       0   0     0    0    0   0     1    0
#> Carol     0   0     0    0    0   1     0    1
#> Tina      0   0     0    0    0   0     1    0
impute_ties(missTest, "mean")
#>       Betty  Sue Alice Jane Dale  Pam Carol Tina
#> Betty     0 1.00  0.00 0.00    0 0.00     0    0
#> Sue       1 0.00  0.25 0.00    1 0.25     0    0
#> Alice     0 0.25  0.00 0.25    1 0.25     0    0
#> Jane      0 0.00  0.25 0.00    1 0.00     0    0
#> Dale      0 1.00  1.00 1.00    0 0.00     0    0
#> Pam       0 0.25  0.25 0.00    0 0.00     1    0
#> Carol     0 0.00  0.00 0.00    0 1.00     0    1
#> Tina      0 0.00  0.00 0.00    0 0.00     1    0
impute_nodes(fict_lotr, "modal", "Race")
#> 
#> ── # Lord of the Rings ─────────────────────────────────────────────────────────
#> # A labelled, complex, undirected network of 36 characters and 66 interaction
#> ties
#> 
#> ── Nodes 
#> # A tibble: 36 × 2
#>   name     Race  
#>   <chr>    <chr> 
#> 1 Aragorn  Human 
#> 2 Beregond Human 
#> 3 Bilbo    Hobbit
#> 4 Celeborn Elf   
#> 5 Denethor Human 
#> 6 Elladan  Elf   
#> # ℹ 30 more rows
#> 
#> ── Ties 
#> # A tibble: 66 × 2
#>    from    to
#>   <int> <int>
#> 1     1     7
#> 2     1     8
#> 3     5     9
#> 4     1    10
#> 5     3    10
#> 6     9    10
#> # ℹ 60 more rows
#> 
to_imputed(ison_classmates)
#> ── # Knecht's Classmates ───────────────────────────────────────────────────────
#> # A longitudinal, labelled, multiplex, directed network of 26 pupils and 460
#> friendship arcs and 86 primary arcs over 4 waves
#> # Transformed by imputation: zero then modal then modal then modal
#> 
#> ── Nodes 
#> # A tibble: 26 × 7
#>   label sex      age ethnicity religion delinquency alcohol
#>   <chr> <chr>  <int> <chr>     <chr>          <dbl>   <dbl>
#> 1 a01   female    12 Dutch     none               2      NA
#> 2 a02   female    12 Dutch     none               1      NA
#> 3 a03   female    12 non-Dutch other              2      NA
#> 4 a04   male      12 Dutch     none               2      NA
#> # ℹ 22 more rows
#> 
#> ── Changes 
#> # A tibble: 144 × 4
#>    time  node var          value
#>   <int> <int> <chr>       <list>
#> 1     2     1 alcohol     1<int>
#> 2     2     1 delinquency 2<int>
#> 3     2     3 alcohol     3<int>
#> 4     2     3 delinquency 2<int>
#> # ℹ 140 more rows
#> 
#> ── Ties 
#> # A tibble: 546 × 4
#>    from    to layer    time
#>   <int> <int> <chr>   <int>
#> 1     3     1 friends     1
#> 2     9     1 friends     1
#> 3    12     1 friends     1
#> 4     3     2 friends     1
#> # ℹ 542 more rows
#>