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 |
multiRDPG
is used to fit Multiple Random Dot Product Graphs from a set of adjacency matrices.
multiRDPG(A, d, maxiter = 100, tol = 1e-06)
multiRDPG(A, d, maxiter = 100, tol = 1e-06)
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. |
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 |
Agnes Martine Nielsen ([email protected])
#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)
#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)
multiRDPG_test
calculates the likelihood ratio test for whether a set of graphs
comes from the same disribution.
multiRDPG_test(A, d, maxiter = 100, tol = 1e-06, B = 1000)
multiRDPG_test(A, d, maxiter = 100, tol = 1e-06, B = 1000)
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. |
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 |
Agnes Martine Nielsen ([email protected])
#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)
#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 hypothesisnullestimation
calculates the estimation under the null hypothesis
nullestimation(A, d)
nullestimation(A, d)
A |
List of symmetric A matrices |
d |
Dimension of the latent space |
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. |
Agnes Martine Nielsen ([email protected])
#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)
#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)
multiRDPG
Plots object from multiRDPG
## S3 method for class 'multiRDPGfit' plot(x, ...)
## S3 method for class 'multiRDPGfit' plot(x, ...)
x |
multiRDPGfit object from function |
... |
further arguments passed to or from other methods |
Agnes Martine Nielsen ([email protected])
multiRDPG_test
Plots histogram of permutation test statistics and indicates test statistic value with red line.
## S3 method for class 'multiRDPGtest' plot(x, ...)
## S3 method for class 'multiRDPGtest' plot(x, ...)
x |
multiRDPGtest object from function |
... |
further arguments passed to or from other methods |
Red line indicates the value of the test statistics with a red line.
Agnes Martine Nielsen ([email protected])
multiRDPG
Print object from multiRDPG
## S3 method for class 'multiRDPGfit' print(x, ...)
## S3 method for class 'multiRDPGfit' print(x, ...)
x |
multiRDPGfit object from function |
... |
further arguments passed to or from other methods |
Agnes Martine Nielsen ([email protected])
multiRDPG_test
Print object from multiRDPG_test
## S3 method for class 'multiRDPGtest' print(x, ...)
## S3 method for class 'multiRDPGtest' print(x, ...)
x |
multiRDPGtest object from function |
... |
further arguments passed to or from other methods |
Agnes Martine Nielsen ([email protected])