Package 'multiRDPG'

Title: Multiple Random Dot Product Graphs
Description: Fits the Multiple Random Dot Product Graph Model and performs a test for whether two networks come from the same distribution. Both methods are proposed in Nielsen, A.M., Witten, D., (2018) "The Multiple Random Dot Product Graph Model", arXiv preprint <arXiv:1811.12172> (Submitted to Journal of Computational and Graphical Statistics).
Authors: Agnes Martine Nielsen [aut, cre], Daniela Witten [aut]
Maintainer: Agnes Martine Nielsen <[email protected]>
License: GPL-2
Version: 1.0.1
Built: 2024-10-31 20:48:28 UTC
Source: CRAN

Help Index


Fitting Multiple Random Dot Product Graphs

Description

multiRDPG is used to fit Multiple Random Dot Product Graphs from a set of adjacency matrices.

Usage

multiRDPG(A, d, maxiter = 100, tol = 1e-06)

Arguments

A

List of adjacency matrices representing graphs. Each matrix must be symmetric. All matrices of the same size n x n.

d

Dimension of latent space. d<= n.

maxiter

Maximal number of iterations. Default is 100.

tol

Tolerance for update of the objective function. Default is 1e-6.

Value

Returns a list of the following:

U Matrix of the joint vectors. n x d.
Lambda List of diagonal matrices. One for each graph. d x d.
Converged Represent of the algorithm converged. 1 if converged, 0 if not.
iter Number of iterations
maxiter Maximal number of iterations.Default is 100.
objfun Value of the objective function. sum_k ||A^k - U Lambda U^T||_F^2

Author(s)

Agnes Martine Nielsen ([email protected])

See Also

multiRDPG_test

Examples

#simulate data
U <- matrix(0, nrow=20, ncol=3)
U[,1] <- 1/sqrt(20)
U[,2] <- rep(c(1,-1), 10)/sqrt(20)
U[,3] <- rep(c(1,1,-1,-1), 5)/sqrt(20)

L<-list(diag(c(11,6,2)),diag(c(15,4,1)))
A <- list()
for(i in 1:2){
  P <- U%*%L[[i]]%*%t(U)
  A[[i]] <-apply(P,c(1,2),function(x){rbinom(1,1,x)})
  A[[i]][lower.tri(A[[i]])]<-t(A[[i]])[lower.tri(A[[i]])]
}

#fit model
multiRDPG(A,3)

Performs test based on Multiple Random Dot Product Graph

Description

multiRDPG_test calculates the likelihood ratio test for whether a set of graphs comes from the same disribution.

Usage

multiRDPG_test(A, d, maxiter = 100, tol = 1e-06, B = 1000)

Arguments

A

List of symmetric A matrices

d

Dimension of the latent space

maxiter

Maximum number of iterations in the fit of multiRDPG. Default is 100.

tol

Tolerance for the step in the objective function in multiRDPG. Default is 1e-6.

B

Number of permutation iterations. Default is 1000.

Value

Returns a list of the following elements:

pvalue Estimated p-values
Tval Value of the test statistic
Tstar Vector of the test statistic for each permutation iteration
nullmodel Model fit under the null
altmodel Modelfit under the alternative

Author(s)

Agnes Martine Nielsen ([email protected])

See Also

multiRDPG

Examples

#simulate data
U <- matrix(0, nrow=20, ncol=3)
U[,1] <- 1/sqrt(20)
U[,2] <- rep(c(1,-1), 10)/sqrt(20)
U[,3] <- rep(c(1,1,-1,-1), 5)/sqrt(20)

L<-list(diag(c(11,6,2)),diag(c(15,4,1)))
A <- list()
for(i in 1:2){
  P <- U%*%L[[i]]%*%t(U)
  A[[i]] <-apply(P,c(1,2),function(x){rbinom(1,1,x)})
  A[[i]][lower.tri(A[[i]])]<-t(A[[i]])[lower.tri(A[[i]])]
}

#perform test
multiRDPG_test(A,3,B=100)

nullestimation calculates the estimation under the null hypothesis

Description

nullestimation calculates the estimation under the null hypothesis

Usage

nullestimation(A, d)

Arguments

A

List of symmetric A matrices

d

Dimension of the latent space

Value

Returns a list of the following

U The common latent space vectors. U in R^n x d
Lambda List of Lambdas. Each is a positive diagonal matrix of size d x d.

Author(s)

Agnes Martine Nielsen ([email protected])

See Also

multiRDPG

Examples

#simulate data
U <- matrix(0, nrow=20, ncol=3)
U[,1] <- 1/sqrt(20)
U[,2] <- rep(c(1,-1), 10)/sqrt(20)
U[,3] <- rep(c(1,1,-1,-1), 5)/sqrt(20)

L<-list(diag(c(11,6,2)),diag(c(15,4,1)))
A <- list()
for(i in 1:2){
  P <- U%*%L[[i]]%*%t(U)
  A[[i]] <-apply(P,c(1,2),function(x){rbinom(1,1,x)})
  A[[i]][lower.tri(A[[i]])]<-t(A[[i]])[lower.tri(A[[i]])]
}

#fit model
nullestimation(A,3)

Plots object from multiRDPG

Description

Plots object from multiRDPG

Usage

## S3 method for class 'multiRDPGfit'
plot(x, ...)

Arguments

x

multiRDPGfit object from function multiRDPG

...

further arguments passed to or from other methods

Author(s)

Agnes Martine Nielsen ([email protected])

See Also

multiRDPG


Plots object from multiRDPG_test

Description

Plots histogram of permutation test statistics and indicates test statistic value with red line.

Usage

## S3 method for class 'multiRDPGtest'
plot(x, ...)

Arguments

x

multiRDPGtest object from function multiRDPG_test

...

further arguments passed to or from other methods

Details

Red line indicates the value of the test statistics with a red line.

Author(s)

Agnes Martine Nielsen ([email protected])

See Also

multiRDPG_test


Print object from multiRDPG

Description

Print object from multiRDPG

Usage

## S3 method for class 'multiRDPGfit'
print(x, ...)

Arguments

x

multiRDPGfit object from function multiRDPG

...

further arguments passed to or from other methods

Author(s)

Agnes Martine Nielsen ([email protected])

See Also

multiRDPG


Print object from multiRDPG_test

Description

Print object from multiRDPG_test

Usage

## S3 method for class 'multiRDPGtest'
print(x, ...)

Arguments

x

multiRDPGtest object from function multiRDPG_test

...

further arguments passed to or from other methods

Author(s)

Agnes Martine Nielsen ([email protected])

See Also

multiRDPG_test