inputs_lmnet: Input preprocessing

Description Usage Arguments Details Value See Also Examples

View source: R/inputs_lmnet.R

Description

Prepare covariates and optional response in adjacency matrix form. If undirected, the values are drawn from the lower triangle of the adjacency matrices.

Usage

1
2
inputs_lmnet(Xlist, Y = NULL, directed = TRUE, add_intercept = TRUE,
  time_intercept = FALSE)

Arguments

Xlist

List of n \times n \times tmax matrices, possibly containing response matrix labeled ‘Y’. Diagonals (self-loops) are ignored.

Y

Optional n \times n \times tmax response matrix. NAs in this matrix will be automatically removed. Diagonals (self-loops) are ignored.

directed

Optional logical indicator of whether input data is for a directed network, default is TRUE. Undirected data format is lower triangle of adjacencey matrix.

add_intercept

Optional logical indicator of whether intercept should be added to X, default is TRUE.

time_intercept

Optional logical indicator of whether separate intercept should be added to X for each observation of the relational matrix, default is FALSE.

Details

This function takes a list of network covariates (in adjacency matrix form) and prepares them for the regression code lmnet. Accomodates 3-dimensional relational arrays with tmax repeated observations of the network (over time or context). Typical network data with a single observation may be input as matrices, i.e. tmax = 1.

Value

A list of:

Y

Vector of responses (column-wise vectorization order) of appropriate length.

X

Matrix of covariates (column-wise vectorization order) of appropriate size.

nodes

2-column matrix (or 3-column for repeated observations) indicating directed relation pairs to which each entry in Y and each row in X corresponds.

See Also

lmnet, vhat_exch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# tmax = 1
set.seed(1)
n <- 10
Xlist <- list(matrix(rnorm(n^2),n,n), matrix(sample(c(0,1), n^2, replace=TRUE),n,n))
Xlist$Y <- matrix(rnorm(n^2), n, n)
Xlist$Y[1:5] <- NA
r <- inputs_lmnet(Xlist)
r
lmnet(r$Y,r$X,nodes=r$nodes)

# tmax = 4
set.seed(1)
n <- 10
tmax <- 4
X1 <- array(rnorm(n^2*tmax),c(n,n,tmax))
X2 <- array(sample(c(0,1), n^2*tmax, replace=TRUE), c(n,n,tmax))
Xlist <- list(X1, X2)
Xlist$Y <- array(rnorm(n^2)*tmax, c(n, n, tmax))
Xlist$Y[1:5] <- NA
r <- inputs_lmnet(Xlist)
head(r$nodes)

netregR documentation built on May 1, 2019, 10:13 p.m.