Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

handleMissings

Handle missing data in matrices


Description

Process NA values (= remove nodes with NAs iteratively).

Usage

handleMissings(mat, na = NA, method = "remove", logical = FALSE)

Arguments

mat

A matrix object.

na

The value that missing data are coded as. Usually NA, sometimes 9 or 10.

method

What should be done with the missing data? If method = "remove" is set, the function determines how many missing entries are in each row and column and iteratively removes rows or columns with the largest amount of missing data until no missing data are left in the matrix. If method = "fillmode" is set, the modal value of the matrix is identified (usually 0 in network matrices) and missing cells are imputed by filling in this modal value. method = "zero" replaces NAs by 0s.

logical

Return a matrix with logical values indicating which cells should be removed? By default the manipulated matrix is returned.

Details

This function deals with missing data in matrices or network objects used for inferential network analysis. It can either remove missing rows and/or columns iteratively (rows and columns with more NA values first, then successively rows and columns with fewer NA entries) or replace missing values by the modal value of the matrix or by 0. The function can return either the manipulated matrix or a matrix with logical values indicating which of the cells should be removed.

Value

Either a matrix in which missing data were taken care of or a matrix indicating where missing data are located.

See Also


btergm

Temporal Exponential Random Graph Models by Bootstrapped Pseudolikelihood

v1.10.3
GPL (>= 2)
Authors
Philip Leifeld [aut, cre], Skyler J. Cranmer [ctb], Bruce A. Desmarais [ctb]
Initial release
2021-06-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.