snha_graph2data {snha}R Documentation

create correlated data for the given adjacency matrix representing a directed graph or an undirected graph

Description

This function is a short implementation of the Monte Carlo algorithm described in Novine et. al. 2022.

Usage

snha_graph2data( 
  A, 
  n=100, 
  iter=50, 
  val=100, 
  sd=2, 
  prop=0.025, 
  noise=1, 
  method="mc" 
  ) 

Arguments

A

an adjacency matrix

n

number of values, measurements per node, default: 100

iter

number of iterations, default: 50

sd

initial standard deviation, default: 2

val

initial node value, default: 100

prop

proportion of the target node value take from the source node, default: 0.025

noise

sd for the noise value added after each iteration using rnorm function with mean 0, default: 1

method

method for data generation, either 'mc' for using Monte Carlo simulation or 'pc' for using a precision matrix, default: 'mc'

Value

matrix with the node names as rows and samplings in the columns

References

Examples

 
opar=par(mfrow=c(1,2),mai=rep(0.2,4)) 
A=matrix(0,nrow=6,ncol=6) 
rownames(A)=colnames(A)=LETTERS[1:6] 
A[1:2,3]=1 
A[3,4]=1 
A[4,5:6]=1 
A[5,6]=1 
plot.snha(A,layout="circle");  
data=snha_graph2data(A) 
round(cor(t(data)),2) 
P=snha(t(data)) 
plot(P,layout="circle") 
par(opar) 

[Package snha version 0.1.3 Index]