inputs_lmnet {netregR} | R Documentation |
Input preprocessing
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
inputs_lmnet(Xlist, Y = NULL, directed = TRUE, add_intercept = TRUE,
time_intercept = FALSE)
Arguments
Xlist |
List of |
Y |
Optional |
directed |
Optional logical indicator of whether input data is for a directed network, default is |
add_intercept |
Optional logical indicator of whether intercept should be added to X, default is |
time_intercept |
Optional logical indicator of whether separate intercept should be added to X for each observation of the relational matrix, default is |
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 |
See Also
Examples
# 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)