Creates a square matrix suitable for spatial statistics models.
Creates a square matrix suitable for spatial statistics models.
diag_expand(...)## S3 method for class 'list'diag_expand(graph, self = is_self(graph), valued = is_valued(graph),...)## S3 method for class 'diffnet'diag_expand(graph, self = is_self(graph), valued = is_valued(graph),...)## S3 method for class 'matrix'diag_expand(graph, nper, self = is_self(graph), valued = is_valued(graph),...)## S3 method for class 'array'diag_expand(graph, self = is_self(graph), valued = is_valued(graph),...)## S3 method for class 'dgCMatrix'diag_expand(graph, nper, self = is_self(graph), valued = is_valued(graph),...)
Arguments
...: Further arguments to be passed to the method.
graph: Any class of accepted graph format (see netdiffuseR-graphs).
self: Logical scalar. When TRUE autolinks (loops, self edges) are allowed (see details).
valued: Logical scalar. When TRUE weights will be considered. Otherwise non-zero values will be replaced by ones.
nper: Integer scalar. Number of time periods of the graph.
Returns
A square matrix of class dgCMatrix of size (nnode(g)*nper)^2
Examples
# Simple example ------------------------------------------------------------set.seed(23)g <- rgraph_er(n=10, p=.5, t=2,undirected=TRUE)# What we've done: A list with 2 bernoulli graphsg
# Expanding to a 20*20 matrix with structural zeros on the diagonal# and on cell 'off' adjacency matrixdiag_expand(g)