tergmprepare: Prepare data structure for TERGM estimation, including...

View source: R/tergmprepare.R

tergmprepareR Documentation

Prepare data structure for TERGM estimation, including composition change

Description

Prepare data structure for TERGM estimation, including composition change.

Usage

tergmprepare(formula, offset = TRUE, blockdiag = FALSE, verbose = TRUE)

Arguments

formula

The original formula provided by the user, given the data structures in the workspace.

offset

Indicates whether absent nodes should be added where they are missing (offset = TRUE) or removed where they are not missing (offset = FALSE).

blockdiag

Should the time steps be arranged in a blockdiagonal matrix for use with MCMC-MLE or Bayesian estimation (blockdiag = TRUE), or should they be kept as items in a list for use with btergm (blockdiag = FALSE)?

verbose

Report details about dimension adjustment?

Details

This is a helper function that adjusts the dimensions of networks or covariates within a given time step to each other by removing nodes that are not present across all objects within a time step or by adding nodes where they are missing (and simultaneously adding entries to a list of structural zero matrices to indicate their absence). It is not necessary to have identical (numbers of) nodes across time steps as long as the dimensions of the matrices, networks, and vectors match cross-sectionally within time steps, given that temporal dependency terms like memory are interpreted as dyadic covariates in a given time step. This helper function also creates these dyadic covariate data structures for some of the custom temporal model terms, such as memory and delrecip. Leifeld, Cranmer and Desmarais (2018) contain additional details on composition change, dimension adjustment of matrices, and temporal dependencies. Note that this function should not normally be used by the end user. It is automatically called internally by the estimation functions to make the dimensions of all objects conformable to each other for estimation. Use this function only for diagnostic purposes!

Value

A list with the following slots:

lhs.original

A character object containing the original name of the object on the left-hand side of the formula provided by the user. This is saved here because the formula is manipulated such that the left-hand side of the formula contains a new item networks[[i]].

networks

The list of networks on the left-hand side of the formula after dimension adjustment, or a blockdiagonal network representing the left-hand side of the formula after dimension adjustment if argument blockdiag = TRUE was used.

num.vertices

The maximum number of nodes of any time point after adjustment of dimensions.

directed

Are the networks directed?

bipartite

Are the networks bipartite?

form

The formula after manipulation and adjustment of the data, including networks[[i]] on the left-hand side and an added offset covariate on the right-hand side of the formula, in addition to added indices for the covariate terms.

time.steps

The number of time steps of the dataset.

rhs.terms

The right-hand side of the formula after adjustment, as a vector of character objects representing the terms.

covnames

A character vector containing the names of the objects in which the networks and covariates are stored, according to the manipulated formula. This includes "networks" (for the left-hand side of the formula) and all objects containing exogenous covariates on the right-hand side of the formula after manipulation.

...

Each of the covariates mentioned in the slot covnames is stored as an element of the list, either as a list of matrices or networks (if blockdiag = FALSE) or as a matrix or network object (if blockdiag = TRUE).

auto.adjust

Did the function have to adjust the dimensions of the networks or covariates at all?

nvertices

A matrix containing the number of nodes in the rows and columns of each object at each time step, after adjustment.

offsmat

A list of offset covariate matrices or a large blockdiagonal offset covariate matrix containing structural zeros. If offset = FALSE, this matrix or list of matrices will contain only zeros. If offset = TRUE, they will contain ones where nodes were absent in the original data.

Author(s)

Philip Leifeld


btergm documentation built on May 29, 2024, 12:09 p.m.