Package 'fase'

Title: Functional Adjacency Spectral Embedding
Description: Latent process embedding for functional network data with the Functional Adjacency Spectral Embedding. Fits smooth latent processes based on cubic spline bases. Also generates functional network data from three models, and evaluates a network generalized cross-validation criterion for dimension selection. For more information, see MacDonald, Zhu and Levina (2022+) <arXiv:2210.07491>.
Authors: Peter W. MacDonald [aut, cre, cph]
Maintainer: Peter W. MacDonald <[email protected]>
License: GPL (>= 3)
Version: 1.0.1.9000
Built: 2025-01-26 06:11:21 UTC
Source: https://github.com/peterwmacd/fase

Help Index


Functional adjacency spectral embedding

Description

fase fits a functional adjacency spectral embedding to snapshots of (undirected) functional network data. The latent processes are fit in a spline basis specified by the user, with additional options for ridge penalization.

Usage

fase(A,d,self_loops,spline_design,lambda,optim_options,output_options)

Arguments

A

An n×n×mn \times n \times m array containing the snapshots of the functional network.

d

A positive integer, the number of latent space dimensions of the functional embedding.

self_loops

A Boolean, if FALSE, all diagonal entries are ignored in optimization. Defaults to TRUE.

spline_design

A list, containing the spline design information. For fitting with a BB-spline design (the default):

type

The string 'bs'.

q

A positive integer, the dimension of the BB-spline basis.

x_vec

A vector, the snapshot evaluation indices for the data. Defaults to an equally spaced vector of length mm from 0 to 1.

x_max

A scalar, the maximum of the index space. Defaults to max(spline_design$x_vec).

x_min

A scalar, the minimum of the index space. Defaults to min(spline_design$x_vec).

spline_matrix

An m×qm \times q matrix, the B-spline basis evaluated at the snapshot indices. If not specified, it will be calculated internally.

ridge_mat

The m×mm \times m matrix for the generalized ridge penalty. If lambda>0> 0, defaults to diag(m).

For fitting with a smoothing spline design:

type

The string 'ss'.

x_vec

A vector, the snapshot evaluation indices for the data. Defaults to an equally spaced vector of length mm from 0 to 1.

x_max

A scalar, the maximum of the index space. Defaults to max(spline_design$x_vec).

x_min

A scalar, the minimum of the index space. Defaults to min(spline_design$x_vec).

spline_matrix

An m×mm \times m matrix, the natural cubic spline basis evaluated at the snapshot indices. If not specified, it will be calculated internally.

ridge_mat

The m×mm \times m matrix for the generalized ridge penalty. Defaults to the second derivatives of the natural cubic spline basis evaluated at the snapshot indices.

lambda

A positive scalar, the scale factor for the generalized ridge penalty (see Details). Defaults to 0.

optim_options

A list, containing additional optional arguments controlling the gradient descent algorithm.

eps

A positive scalar, the convergence threshold for gradient descent in terms of relative change in objective value. Defaults to 1e-5.

eta

A positive scalar, the step size for gradient descent. Defaults to 1/(n*m).

K_max

A positive integer, the maximum iterations for gradient descent. Defaults to 2e3.

verbose

A Boolean, if TRUE, console output will provide updates on the progress of gradient descent. Defaults to FALSE.

init_W

A 3-dimensional array containing initial basis coordinates for gradient descent. Dimension should be n×n \timesspline_design$q×d\times d for BB-spline designs, and n×m×dn \times m \times d for smoothing spline designs. If included, init_M, init_L and init_sigma are ignored.

init_sigma

A positive scalar, the estimated edge dispersion parameter to calibrate initialization. If not provided, it is either estimated using the robust method proposed by Gavish and Donoho (2014) for weighted edge networks, or set to a default value 0.5 for binary edge networks.

init_L

A positive integer, the number of contiguous groups used for initialization. Defaults to the floor of (2nm/init_sigma2)1/3(2nm/\texttt{init\_sigma}^2)^{1/3}.

init_M

A positive integer, the number of snapshots averaged in each group for initialization. Defaults use all snapshots.

output_options

A list, containing additional optional arguments controlling the output of fase.

align_output

A Boolean, if TRUE, the returned latent processes have been aligned according to a Procrustes alignment which minimizes (in terms of Frobenius norm) the overall discrepancies between consecutive snapshots. Defaults to TRUE.

return_coords

A Boolean, if TRUE, the basis coordinates for each latent process component are also returned as an array. Defaults to FALSE.

return_ngcv

A Boolean, if TRUE and spline_design$type=='bs', the network generalized cross validation criterion is returned. Defaults to TRUE.

Details

fase finds a functional adjacency spectral embedding of an n×n×mn \times n \times m array AA of symmetric adjacency matrices on a common set of nodes, where each n×nn \times n slice is associated to a scalar index xkx_k for k=1,...,mk=1,...,m. Embedding requires the specification of a latent space dimension dd and spline design information (with the argument spline_design).

fase can fit latent processes using either a cubic BB-spline basis with equally spaced knots, or a natural cubic spline basis with a second derivative (generalized ridge) smoothing penalty: a smoothing spline. To fit with a BB-spline design (spline_design$type = 'bs'), one must minimally provide a basis dimension qq of at least 4 and at most mm.

When fitting with a smoothing spline design, the generalized ridge penalty is scaled by λ/n\lambda/n, where λ\lambda is specified by the argument lambda. see MacDonald et al., (2022+), Appendix E for more details. lambda can also be used to introduce a ridge penalty on the basis coordinates when fitting with BB-splines.

Fitting minimizes a least squares loss, using gradient descent (Algorithm 2) on the basis coordinates wi,rw_{i,r} of each component process

zi,r(x)=wi,rTB(x).z_{i,r}(x) = w_{i,r}^{T}B(x).

Additional options for the fitting algorithm, including initialization, can be specified by the argument optim_options. For more details on the fitting and initialization algorithms, see MacDonald et al., (2022+), Section 3.

By default, fase will return estimates of the latent processes evaluated at the snapshot indices as an n×d×mn \times d \times m array, after performing a Procrustes alignment of the consecutive snapshots. This extra alignment step can be skipped. fase will also return the spline design information used to fit the embedding, convergence information for gradient descent, and (if specified) the basis coordinates.

When fitting with BB-splines, fase can return a network generalized cross validation criterion, described in MacDonald et al., (2022+), Section 3.3. This criterion can be minimized to choose appropriate values for qq and dd.

Value

A list is returned with the functional adjacency spectral embedding, the spline design information, and some additional optimization output:

Z

An n×d×mn \times d \times m array containing the latent process embedding evaluated at the indices in spline_design$x_vec.

W

For BB-spline designs, an n×q×dn \times q \times d array; or for smoothing spline designs, an n×m×dn \times m \times d array of estimated basis coordinates. If output_options$return_coords is FALSE, this is not returned.

spline_design

A list, describing the spline design:

type

A string, either 'bs' or 'ss'.

q

A positive integer, the dimension of the BB-spline basis. Only returned for BB-spline designs.

x_vec

A vector, the snapshot evaluation indices for the data.

x_max

A scalar, the maximum of the index space.

x_min

A scalar, the minimum of the index space.

spline_matrix

For BB-spline designs, an m×qm \times q matrix; or for smoothing spline designs, an m×mm \times m matrix, the basis evaluated at the snapshot indices.

ridge_matrix

An m×mm \times m matrix used in the generalized ridge penalty. Only returned for lambda > 0.

ngcv

A scalar, the network generalized cross validation criterion (see Details). Only returned for BB-spline designs and when output_options$return_ngcv is TRUE.

K

A positive integer, the number of iterations run in gradient descent.

converged

An integer convergence code, 1 if gradient descent converged in fewer than optim_options$K_max iterations, 0 otherwise.

Examples

# Gaussian edge data with sinusoidal latent processes
set.seed(1)
data <- gaussian_snapshot_ss(n=50,d=2,
                             x_vec=seq(0,1,length.out=50),
                             self_loops=FALSE,sigma_edge=4)


# fase fit with B-spline design
fit_bs <- fase(data$A,d=2,self_loops=FALSE,
               spline_design=list(type='bs',q=9,x_vec=data$spline_design$x_vec),
               optim_options=list(eps=1e-4,K_max=40),
               output_options=list(return_coords=TRUE))

# fase fit with smoothing spline design
fit_ss <- fase(data$A,d=2,self_loops=FALSE,
               spline_design=list(type='ss',x_vec=data$spline_design$x_vec),
               lambda=.5,
               optim_options=list(eta=1e-4,K_max=40,verbose=FALSE),
               output_options=list(align_output=FALSE))

#NOTE: both examples fit with small optim_options$K_max=40 for demonstration

Functional adjacency spectral embedding (sequential algorithm)

Description

fase_seq fits a functional adjacency spectral embedding to snapshots of (undirected) functional network data, with each of the dd latent dimensions fit sequentially. The latent processes are fit in a spline basis specified by the user, with additional options for ridge penalization.

Usage

fase_seq(A,d,self_loops,spline_design,lambda,optim_options,output_options)

Arguments

A

An n×n×mn \times n \times m array containing the snapshots of the functional network.

d

A positive integer, the number of latent space dimensions of the functional embedding.

self_loops

A Boolean, if FALSE, all diagonal entries are ignored in optimization. Defaults to TRUE.

spline_design

A list, containing the spline design information. For fitting with a BB-spline design (the default):

type

The string 'bs'.

q

A positive integer, the dimension of the BB-spline basis.

x_vec

A vector, the snapshot evaluation indices for the data. Defaults to an equally spaced vector of length mm from 0 to 1.

x_max

A scalar, the maximum of the index space. Defaults to max(spline_design$x_vec).

x_min

A scalar, the minimum of the index space. Defaults to min(spline_design$x_vec).

spline_matrix

An m×qm \times q matrix, the B-spline basis evaluated at the snapshot indices. If not specified, it will be calculated internally.

ridge_mat

The m×mm \times m matrix for the generalized ridge penalty. If lambda>0> 0, defaults to diag(m).

For fitting with a smoothing spline design:

type

The string 'ss'.

x_vec

A vector, the snapshot evaluation indices for the data. Defaults to an equally spaced vector of length mm from 0 to 1.

x_max

A scalar, the maximum of the index space. Defaults to max(spline_design$x_vec).

x_min

A scalar, the minimum of the index space. Defaults to min(spline_design$x_vec).

spline_matrix

An m×mm \times m matrix, the natural cubic spline basis evaluated at the snapshot indices. If not specified, it will be calculated internally.

ridge_mat

The m×mm \times m matrix for the generalized ridge penalty. Defaults to the second derivatives of the natural cubic spline basis evaluated at the snapshot indices.

lambda

A positive scalar, the scale factor for the generalized ridge penalty (see Details). Defaults to 0.

optim_options

A list, containing additional optional arguments controlling the gradient descent algorithm.

eps

A positive scalar, the convergence threshold for gradient descent in terms of relative change in objective value. Defaults to 1e-5.

eta

A positive scalar, the step size for gradient descent. Defaults to 1/(n*m).

K_max

A positive integer, the maximum iterations for gradient descent. Defaults to 2e3.

verbose

A Boolean, if TRUE, console output will provide updates on the progress of gradient descent. Defaults to FALSE.

init_W

A 3-dimensional array containing initial basis coordinates for gradient descent. Dimension should be n×n \timesspline_design$q×d\times d for BB-spline designs, and n×m×dn \times m \times d for smoothing spline designs. If included, init_M, init_L and init_sigma are ignored.

init_sigma

A positive scalar, the estimated edge dispersion parameter to calibrate initialization. If not provided, it is either estimated using the robust method proposed by Gavish and Donoho (2014) for weighted edge networks, or set to a default value 0.5 for binary edge networks.

init_L

A positive integer, the number of contiguous groups used for initialization. Defaults to the floor of (2nm/init_sigma2)1/3(2nm/\texttt{init\_sigma}^2)^{1/3}.

init_M

A positive integer, the number of snapshots averaged in each group for initialization. Defaults use all snapshots.

output_options

A list, containing additional optional arguments controlling the output of fase.

return_coords

A Boolean, if TRUE, the basis coordinates for each latent process component are also returned as an array. Defaults to FALSE.

return_ngcv

A Boolean, if TRUE and spline_design$type=='bs', the network generalized cross validation criterion is returned. Defaults to TRUE.

Details

Note that fase_seq is a wrapper for fase. When d=1d=1, fase_seq coincides with fase.

fase_seq finds a functional adjacency spectral embedding of an n×n×mn \times n \times m array AA of symmetric adjacency matrices on a common set of nodes, where each n×nn \times n slice is associated to a scalar index xkx_k for k=1,...,mk=1,...,m. Embedding requires the specification of a latent space dimension dd and spline design information (with the argument spline_design).

fase_seq can fit latent processes using either a cubic BB-spline basis with equally spaced knots, or a natural cubic spline basis with a second derivative (generalized ridge) smoothing penalty: a smoothing spline. To fit with a BB-spline design (spline_design$type = 'bs'), one must minimally provide a basis dimension qq of at least 4 and at most mm.

When fitting with a smoothing spline design, the generalized ridge penalty is scaled by λ/n\lambda/n, where λ\lambda is specified by the argument lambda. see MacDonald et al., (2022+), Appendix E for more details. lambda can also be used to introduce a ridge penalty on the basis coordinates when fitting with BB-splines.

Fitting minimizes a least squares loss, using gradient descent (Algorithm 1) on the basis coordinates wi,rw_{i,r} of each component process

zi,r(x)=wi,rTB(x).z_{i,r}(x) = w_{i,r}^{T}B(x).

Additional options for the fitting algorithm, including initialization, can be specified by the argument optim_options. For more details on the fitting and initialization algorithms, see MacDonald et al., (2022+), Section 3.

By default, fase_seq will return estimates of the latent processes evaluated at the snapshot indices as an n×d×mn \times d \times m array, after performing a Procrustes alignment of the consecutive snapshots. This extra alignment step can be skipped. fase_seq will also return the spline design information used to fit the embedding, convergence information for gradient descent, and (if specified) the basis coordinates.

When fitting with BB-splines, fase_seq can return a network generalized cross validation criterion, described in MacDonald et al., (2022+), Section 3.3. This criterion can be minimized to choose appropriate values for qq and dd.

Value

A list is returned with the functional adjacency spectral embedding, the spline design information, and some additional optimization output:

Z

An n×d×mn \times d \times m array containing the latent process embedding evaluated at the indices in spline_design$x_vec.

W

For BB-spline designs, an n×q×dn \times q \times d array; or for smoothing spline designs, an n×m×dn \times m \times d array of estimated basis coordinates. If output_options$return_coords is FALSE, this is not returned.

spline_design

A list, describing the spline design:

type

A string, either 'bs' or 'ss'.

q

A positive integer, the dimension of the BB-spline basis. Only returned for BB-spline designs.

x_vec

A vector, the snapshot evaluation indices for the data.

x_max

A scalar, the maximum of the index space.

x_min

A scalar, the minimum of the index space.

spline_matrix

For BB-spline designs, an m×qm \times q matrix; or for smoothing spline designs, an m×mm \times m matrix, the basis evaluated at the snapshot indices.

ridge_matrix

An m×mm \times m matrix used in the generalized ridge penalty. Only returned for lambda > 0.

ngcv

A scalar, the network generalized cross validation criterion (see Details). Only returned for BB-spline designs and when output_options$return_ngcv is TRUE.

K

A positive integer, the number of iterations run in gradient descent.

converged

An integer convergence code, 1 if gradient descent converged in fewer than optim_options$K_max iterations, 0 otherwise.

Examples

# Gaussian edge data with sinusoidal latent processes
set.seed(1)
data <- gaussian_snapshot_ss(n=50,d=2,
                             x_vec=seq(0,1,length.out=50),
                             self_loops=FALSE,sigma_edge=4)


# fase fit with B-spline design
fit_bs <- fase_seq(data$A,d=2,self_loops=FALSE,
                   spline_design=list(type='bs',q=9,x_vec=data$spline_design$x_vec),
                   optim_options=list(eps=1e-4,K_max=40),
                   output_options=list(return_coords=TRUE))

# fase fit with smoothing spline design
fit_ss <- fase_seq(data$A,d=2,self_loops=FALSE,
                   spline_design=list(type='ss',x_vec=data$spline_design$x_vec),
                   lambda=.5,
                   optim_options=list(eta=1e-4,K_max=40,verbose=FALSE))

#NOTE: both models fit with small optim_options$K_max=40 for demonstration

Simulate Gaussian edge networks with B-spline latent processes

Description

gaussian_snapshot_bs simulates a realization of a functional network with Gaussian edges, according to an inner product latent process model. The latent processes are generated from a BB-spline basis with equally spaced knots.

Usage

gaussian_snapshot_bs(n,d,m,self_loops=TRUE,
                     spline_design,sigma_edge=1,
                     process_options)

Arguments

n

A positive integer, the number of nodes.

d

A positive integer, the number of latent space dimensions.

m

A positive integer, the number of snapshots. If this argument is not specified, it is determined from the snapshot index vector spline_design$x_vec.

self_loops

A Boolean, if FALSE, all diagonal adjacency matrix entries are set to zero. Defaults to TRUE.

spline_design

A list, describing the BB-spline design:

q

A positive integer, the dimension of the BB-spline basis. Must be at least 4 and at most m.

x_vec

A vector, the snapshot evaluation indices for the data. Defaults to an equally spaced sequence of length m from 0 to 1.

x_max

A scalar, the maximum of the index space. Defaults to max(spline_design$x_vec).

x_min

A scalar, the minimum of the index space. Defaults to min(spline_design$x_vec).

sigma_edge

A positive scalar, the entry-wise standard deviation for the Gaussian edge variables. Defaults to 1.

process_options

A list, containing additional optional arguments:

sigma_coord

A positive scalar, or a vector of length dd. If it is a vector, the entries correspond to the standard deviation of the randomly generated basis coordinates for each latent dimension. If is is a scalar, it corresponds to the standard deviation of the basis coordinates in all dimensions. Defaults to 1.

Details

The spline design of the functional network data (snapshot indices, basis dimension) is generated using the information provided in spline_design, producing a qq-dimensional cubic BB-spline basis with equally spaced knots.

The latent process basis coordinates are generated as iid Gaussian random variables with standard deviation process_options$sigma_coord. Each latent process is given by

zi,r(x)=wi,rTB(x).z_{i,r}(x) = w_{i,r}^{T}B(x).

Then, the n×nn \times n symmetric adjacency matrix for snapshot k=1,...,mk=1,...,m has independent Gaussian entries with standard deviation sigma_edge and mean

E([Ak]ij)=zi(xk)Tzj(xk)E([A_k]_{ij}) = z_i(x_k)^{T}z_j(x_k)

for iji \leq j (or i<ji < j with no self loops).

Value

A list is returned with the realizations of the basis coordinates, spline design, and the multiplex network snapshots:

A

An array of dimension n×n×mn \times n \times m, the realized functional network data.

W

An array of dimension n×q×dn \times q \times d, the realized basis coordinates.

spline_design

A list, describing the BB-spline design:

type

The string 'bs'.

q

A positive integer, the dimension of the BB-spline basis.

x_vec

A vector, the snapshot evaluation indices for the data.

x_max

A scalar, the maximum of the index space.

x_min

A scalar, the minimum of the index space.

spline_matrix

An m×qm \times q matrix, the B-spline basis evaluated at the snapshot indices.

Examples

# Gaussian edge data with B-spline latent processes, Gaussian coordinates
# NOTE: x_vec is automatically populated given m

data <- gaussian_snapshot_bs(n=100,d=4,m=100,
                             self_loops=FALSE,
                             spline_design=list(q=12),
                             sigma_edge=3,
                             process_options=list(sigma_coord=.75))

Simulate Gaussian edge networks with nonparametric latent processes

Description

gaussian_snapshot_ss simulates a realization of a functional network with Gaussian edges, according to an inner product latent process model. The latent processes are randomly generated sinusoidal functions.

Usage

gaussian_snapshot_ss(n,d,m,x_vec,self_loops=TRUE,
                     sigma_edge=1,process_options)

Arguments

n

A positive integer, the number of nodes.

d

A positive integer, the number of latent space dimensions.

m

A positive integer, the number of snapshots. If this argument is not specified, it is determined from the snapshot index vector x_vec.

x_vec

A vector, the snapshot evaluation indices for the data. Defaults to an equally spaced sequence of length m from 0 to 1.

self_loops

A Boolean, if FALSE, all diagonal adjacency matrix entries are set to zero. Defaults to TRUE.

sigma_edge

A positive scalar, the entry-wise standard deviation for the Gaussian edge variables. Defaults to 1.

process_options

A list, containing additional optional arguments:

amplitude

A positive scalar, the maximum amplitude of the randomly generated latent processes. Defaults to 3.

frequency

A positive scalar, frequency of the randomly generated latent processes. Defaults to 2.

sigma_int

A positive scalar, or a vector of length dd. If it is a vector, the entries correspond to the standard deviation of the random intercepts of the node processes for each latent dimension. If is is a scalar, it corresponds to the standard deviation of the random intercepts in all dimensions. Defaults to 0.5.

return_fn

A Boolean, if TRUE, then the latent processes are returned as a function which takes a vector of indices and returns the corresponding evaluations of the latent process matrices. Otherwise, the latent processes are returned as an n×d×mn \times d \times m array evaluated at the prespecified snapshot indices. Defaults to FALSE.

Details

The the latent process for node ii in latent dimension rr is given independently by

zi,r(x)=asin[2fπ(xU)/(xmaxxmin)]1+(2a1)[x+B(xmax2x)]+Gz_{i,r}(x) = \frac{a \sin [2f\pi(x - U) / (x_{max} - x_{min})]}{1 + (2a-1)[x + B(x_{max} - 2x)]} + G

Where GG is Gaussian with mean 0 and standard deviation σint,r\sigma_{int,r}, BB is Bernoulli with mean 1/2, and UU is uniform with minimum spline_design$x_min and maximum spline_design$x_max. ff is a frequency parameter specified with process_options$frequency, and aa is a maximum amplitude parameter specified with process_options$amplitude. Roughly, each process is a randomly shifted sine function which goes through f cycles on the index set, with amplitude either increasing or decreasing between 1/21/2 and aa.

Then, the n×nn \times n symmetric adjacency matrix for snapshot k=1,...,mk=1,...,m has independent Gaussian entries with standard deviation sigma_edge and mean

E([Ak]ij)=zi(xk)Tzj(xk)E([A_k]_{ij}) = z_i(x_k)^{T}z_j(x_k)

for iji \leq j (or i<ji < j with no self loops).

This function may return the latent processes as an n×d×mn \times d \times m array evaluated at the prespecified snapshot indices, or as a function which takes a vector of indices and returns the corresponding evaluations of the latent process matrices. It also returns the spline design information required to fit a FASE embedding to this data with a natural cubic spline.

Value

A list is returned with the realizations of the basis coordinates, spline design, and the multiplex network snapshots:

A

An array of dimension n×n×mn \times n \times m, the realized functional network data.

Z

If process_options$return_fn is TRUE, a function, which takes a vector of indices and returns the corresponding evaluations of the latent process matrices. Otherwise, an array of dimension n×d×mn \times d \times m, the latent processes evaluated at the prespecified snapshot indices.

spline_design

A list, describing the BB-spline design:

type

The string 'ss'.

x_vec

A vector, the snapshot evaluation indices for the data.

Examples

# Gaussian edge data with sinusoidal latent processes
# NOTE: latent processes are returned as a function

data <- gaussian_snapshot_ss(n=100,d=2,
                             x_vec=seq(0,3,length.out=80),
                             self_loops=TRUE,
                             sigma_edge=4,
                             process_options=list(amplitude=4,
                                                  frequency=3,
                                                  return_fn=TRUE))

Procrustes alignment

Description

proc_align orthogonally transforms the columns of a matrix AA to find the best approximation (in terms of Frobenius norm) to a second matrix BB. Optionally, it may also return the optimal transformation matrix.

Usage

proc_align(A,B,return_orth=FALSE)

Arguments

A

An n×dn \times d matrix.

B

An n×dn \times d matrix.

return_orth

A Boolean which specifies whether to return the orthogonal transformation. Defaults to FALSE.

Value

If return_orth is FALSE, returns the n×dn \times d matrix resulting from applying the optimal aligning transformation to the columns of A. Otherwise, returns a list with two entries:

Ao

The n×dn \times d matrix resulting from applying the optimal aligning transformation to the columns of A.

orth

The d×dd \times d optimal aligning orthogonal transformation matrix.


Slicewise Procrustes alignment for 3-mode tensors

Description

proc_align_slicewise3 applies an orthogonal transformation to the columns of each of the n×dn \times d slices of an n×d×mn \times d \times m array AA to find the best approximation (in terms of matrix Frobenius norm) to the corresponding n×dn \times d slice of a second n×d×mn \times d \times m array BB.

Usage

proc_align_slicewise3(A,B)

Arguments

A

An n×d×mn \times d \times m array.

B

An n×d×mn \times d \times m array.

Value

Returns the n×d×mn \times d \times m array resulting from applying the optimal aligning transformations to the columns of the n×dn \times d slices of A.


Procrustes alignment for 3-mode tensors

Description

proc_align3 applies one orthogonal transformation to the columns of each of the n×dn \times d slices of an n×d×mn \times d \times m array AA to find the best approximation (in terms of matrix Frobenius norm, averaged over the n×dn \times d slices) to a second n×d×mn \times d \times m array BB. Optionally, it may also return the optimal transformation matrix.

Usage

proc_align3(A,B,return_orth=FALSE)

Arguments

A

An n×d×mn \times d \times m array.

B

An n×d×mn \times d \times m array.

return_orth

A Boolean which specifies whether to return the orthogonal transformation. Defaults to FALSE.

Value

If return_orth is FALSE, returns the n×d×mn \times d \times m array resulting from applying the optimal aligning transformation to the columns of the n×dn \times d slices of A. Otherwise, returns a list with two entries:

Ao

The n×dn \times d matrix resulting from applying the optimal aligning transformation to the columns of the n×dn \times d slices of A.

orth

The d×dd \times d optimal aligning orthogonal transformation matrix.


Simulate binary edge networks with B-spline latent processes

Description

rdpg_snapshot_bs simulates a realization of a functional network with Bernoulli edges, according to an inner product latent process model. The latent processes are generated from a BB-spline basis with equally spaced knots.

Usage

rdpg_snapshot_bs(n,d,m,self_loops=TRUE,
                 spline_design,process_options)

Arguments

n

A positive integer, the number of nodes.

d

A positive integer, the number of latent space dimensions.

m

A positive integer, the number of snapshots. If this argument is not specified, it is determined from the snapshot index vector spline_design$x_vec.

self_loops

A Boolean, if FALSE, all diagonal adjacency matrix entries are set to zero. Defaults to TRUE.

spline_design

A list, describing the BB-spline design:

q

A positive integer, the dimension of the BB-spline basis. Must be at least 4 and at most m.

x_vec

A vector, the snapshot evaluation indices for the data. Defaults to an equally spaced sequence of length m from 0 to 1.

x_max

A scalar, the maximum of the index space. Defaults to max(spline_design$x_vec).

x_min

A scalar, the minimum of the index space. Defaults to min(spline_design$x_vec).

process_options

A list, containing additional optional arguments:

alpha_coord

A positive scalar, or a vector of length dd. If it is a vector, it corresponds to the Dirichlet parameter of the basis coordinates. If is is a scalar, the basis coordinates have Dirichlet parameter rep(alpha_coord,d). Defaults to 0.1.

density

A scalar between 0 and 1, which controls the approximate overall edge density of the resulting multiplex matrix. Defaults to 1/d. If specified larger than 1/d, this argument is reset to 1/d and a warning is given.

Details

The spline design of the functional network data (snapshot indices, basis dimension) is generated using the information provided in spline_design, producing a qq-dimensional cubic BB-spline basis with equally spaced knots.

The (q×dq \times d) latent process basis coordinates WiW_i for each node are generated as qq iid Dirichlet random variables with dd-dimensional parameter process_options$alpha_coord or rep(process_options$alpha_coord,d) depending on the dimension of process_options$alpha_coord. Roughly, smaller values of process_options$alpha_coord will tend to generate latent positions closer to the corners of the simplex.

WiW_i is then rescaled so the overall network density is approximately process_options$density, and the Euclidean norm of zi(x)z_i(x) never exceeds 1. If the density requested is too high, it will revert to the maximum density under this model (1/d1/d). Then each latent process is given by

zi(x)=WiTB(x).z_{i}(x) = W_i^{T}B(x).

The n×nn \times n symmetric adjacency matrix for snapshot k=1,...,mk=1,...,m has independent Bernoulli entries with mean

E([Ak]ij)=zi(xk)Tzj(xk)E([A_k]_{ij}) = z_i(x_k)^{T}z_j(x_k)

for iji \leq j (or i<ji < j with no self loops).

Value

A list is returned with the realizations of the basis coordinates, spline design, and the multiplex network snapshots:

A

An array of dimension n×n×mn \times n \times m, the realized functional network data.

W

An array of dimension n×q×dn \times q \times d, the realized basis coordinates.

spline_design

A list, describing the BB-spline design:

type

The string 'bs'.

q

A positive integer, the dimension of the BB-spline basis.

x_vec

A vector, the snapshot evaluation indices for the data.

x_max

A scalar, the maximum of the index space.

x_min

A scalar, the minimum of the index space.

spline_matrix

An m×qm \times q matrix, the B-spline basis evaluated at the snapshot indices.

Examples

# Bernoulli edge data with B-spline latent processes, Dirichlet coordinates
# NOTE: for B-splines, x_max and x_min do not need to coincide with the
# max and min snapshot times.

data <- rdpg_snapshot_bs(n=100,d=10,
                         self_loops=FALSE,
                         spline_design=list(q=8,
                                            x_vec=seq(-1,1,length.out=50),
                                            x_min=-1.1,x_max=1.1),
                         process_options=list(alpha_coord=.2,
                         density=1/10))