Skip to contents

Generates a null distribution of imaginary-census motif counts by repeatedly sampling CSS networks with sample_css_network() and compares the observed counts to this null distribution. Returns an S3 object of class "imaginarycss_test" with print, summary, and plot methods.

Usage

test_imaginary_census(graph, n_sim = 100L, alpha = 0.05, counter_type = 0L)

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

# S3 method for class 'imaginarycss_test'
summary(object, ...)

# S3 method for class 'imaginarycss_test'
plot(x, main = "Motif Z-Scores vs Null", ...)

Arguments

graph

A barry_graph object.

n_sim

Integer. Number of null-model simulations (default 100).

alpha

Numeric. Significance level for the two-sided test (default 0.05).

counter_type

Integer passed to count_imaginary_census() (default 0L).

x

An object of class "imaginarycss_test".

...

Currently ignored.

object

An object of class "imaginarycss_test".

main

Character. Plot title.

Value

An object of class "imaginarycss_test", which is a list containing:

results

A data frame with columns motif, observed, null_mean, null_sd, z_score, p_value, and significant.

observed

Named numeric vector of observed motif totals.

null_matrix

Matrix of null motif totals (motifs x simulations).

n_sim

Number of simulations used.

alpha

Significance level used.

print.imaginarycss_test() returns the input object invisibly. Called for its side effect of printing a summary of significant motifs.

summary.imaginarycss_test() returns the input object invisibly. Called for its side effect of printing the full results table.

plot.imaginarycss_test() returns the input object invisibly. Called for its side effect of drawing a horizontal barplot of z-scores.

Examples

data(krackhardt_advice)
data(krackhardt_advice_perceptions)

n_people <- 21
advice_matrix <- matrix(0L, nrow = n_people, ncol = n_people)
advice_matrix[cbind(krackhardt_advice$from, krackhardt_advice$to)] <-
  krackhardt_advice$value

krack_graph <- new_barry_graph(
  c(list(advice_matrix), krackhardt_advice_perceptions)
)
res <- test_imaginary_census(krack_graph, n_sim = 50)
res
#> Imaginary-census significance test
#>   Simulations: 50  | Alpha: 0.05 
#> 
#> Significant motifs:
#>                            motif observed z_score p_value
#>                   Accurate null       992    8.03    0.00
#>  Partial false positive (assym)       412    7.22    0.00
#>   Partial false positive (null)       343   -6.39    0.00
#>                  Accurate assym      1052   -4.96    0.00
#>                     Mixed assym       173    4.34    0.00
#>  Complete false positive (null)        30   -4.11    0.00
#>  Partial false negative (assym)       463   -2.46    0.04
summary(res)
#> Imaginary-census significance test
#>   Simulations: 50  | Alpha: 0.05 
#>   Motifs tested: 10 | Significant: 7 
#> 
#>                            motif observed null_mean null_sd z_score p_value
#>                   Accurate null       992     865.0   15.82    8.03    0.00
#>  Partial false positive (assym)       412     301.9   15.24    7.22    0.00
#>   Partial false positive (null)       343     440.2   15.20   -6.39    0.00
#>                  Accurate assym      1052    1164.0   22.59   -4.96    0.00
#>                     Mixed assym       173     127.5   10.48    4.34    0.00
#>  Complete false positive (null)        30      59.8    7.25   -4.11    0.00
#>  Partial false negative (assym)       463     506.6   17.77   -2.46    0.04
#>  Complete false negative (full)        81      85.7    7.13   -0.65    0.60
#>   Partial false negative (full)       395     388.7   14.47    0.43    0.48
#>                   Accurate full       469     470.6   14.56   -0.11    0.88
#>  significant
#>         TRUE
#>         TRUE
#>         TRUE
#>         TRUE
#>         TRUE
#>         TRUE
#>         TRUE
#>        FALSE
#>        FALSE
#>        FALSE
plot(res)