Addition, subtraction, network power of diffnet and logical operators such as & and | as objects

# S3 method for class 'diffnet'
x^y

graph_power(x, y, valued = getOption("diffnet.valued", FALSE))

# S3 method for class 'diffnet'
y/x

# S3 method for class 'diffnet'
x - y

# S3 method for class 'diffnet'
x * y

# S3 method for class 'diffnet'
x & y

# S3 method for class 'diffnet'
x | y

Arguments

x

A diffnet class object.

y

Integer scalar. Power of the network

valued

Logical scalar. When FALSE all non-zero entries of the adjacency matrices are set to one.

Value

A diffnet class object

Details

Using binary operators, ease data management process with diffnet.

By default the binary operator ^ assumes that the graph is valued, hence the power is computed using a weighted edges. Otherwise, if more control is needed, the user can use graph_power instead.

See also

Examples

# Computing two-steps away threshold with the Brazilian farmers data --------
data(brfarmersDiffNet)

expo1 <- threshold(brfarmersDiffNet)
expo2 <- threshold(brfarmersDiffNet^2)

# Computing correlation
cor(expo1,expo2)
#>           threshold
#> threshold 0.7684998

# Drawing a qqplot
qqplot(expo1, expo2)


# Working with inverse ------------------------------------------------------
brf2_step <- brfarmersDiffNet^2
brf2_step <- 1/brf2_step

# Removing the first 3 vertex of medInnovationsDiffnet ----------------------
data(medInnovationsDiffNet)

# Using a diffnet object
first3Diffnet <- medInnovationsDiffNet[1:3,,]
medInnovationsDiffNet - first3Diffnet
#> Dynamic network of class -diffnet-
#>  Name               : Medical Innovation
#>  Behavior           : Adoption of Tetracycline
#>  # of nodes         : 122 (1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, ...)
#>  # of time periods  : 18 (1 - 18)
#>  Type               : directed
#>  Final prevalence   : 1.00
#>  Static attributes  : city, detail, meet, coll, attend, proage, length, ... (58)
#>  Dynamic attributes : -

# Using indexes
medInnovationsDiffNet - 1:3
#> Dynamic network of class -diffnet-
#>  Name               : Medical Innovation
#>  Behavior           : Adoption of Tetracycline
#>  # of nodes         : 122 (1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, ...)
#>  # of time periods  : 18 (1 - 18)
#>  Type               : directed
#>  Final prevalence   : 1.00
#>  Static attributes  : city, detail, meet, coll, attend, proage, length, ... (58)
#>  Dynamic attributes : -

# Using ids
medInnovationsDiffNet - as.character(1001:1003)
#> Dynamic network of class -diffnet-
#>  Name               : Medical Innovation
#>  Behavior           : Adoption of Tetracycline
#>  # of nodes         : 122 (1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, ...)
#>  # of time periods  : 18 (1 - 18)
#>  Type               : directed
#>  Final prevalence   : 1.00
#>  Static attributes  : city, detail, meet, coll, attend, proage, length, ... (58)
#>  Dynamic attributes : -