Learn R Programming

netdiffuseR (version 1.17.0)

diag_expand: Creates a square matrix suitable for spatial statistics models.

Description

Creates a square matrix suitable for spatial statistics models.

Usage

diag_expand(...)
"diag_expand"(graph, self = getOption("diffnet.self"), valued = getOption("diffnet.valued"), ...)
"diag_expand"(graph, self = getOption("diffnet.self"), valued = getOption("diffnet.valued"), ...)
"diag_expand"(graph, nper, self = getOption("diffnet.self"), valued = getOption("diffnet.valued"), ...)
"diag_expand"(graph, self = getOption("diffnet.self"), valued = getOption("diffnet.valued"), ...)
"diag_expand"(graph, nper, self = getOption("diffnet.self"), valued = getOption("diffnet.valued"), ...)

Arguments

...
Further arguments to be passed to the method.
graph
Any class of accepted graph format (see netdiffuseR-graphs).
self
Logical scalar. When TRUE allows loops (self edges).
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.

Value

A square matrix of class dgCMatrix of size (nnode(g)*nper)^2

Examples

Run this code
# 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 graphs
g

# Expanding to a 20*20 matrix with structural zeros on the diagonal
# and on cell 'off' adjacency matrix
diag_expand(g)

Run the code above in your browser using DataLab