Skip to contents

These functions can be used to generate null distributions for testing the prevalence of imaginary CSS. The null is a function of the individual level accuracy rates, in other words. Pr(i perceives a one| there is a one) and Pr(i perceives a zero| there is a zero).

Usage

tie_level_accuracy(graph, which_nets = NULL)

sample_css_network(
  graph,
  prob = tie_level_accuracy(graph),
  i = 1L:attr(graph, "netsize"),
  keep_baseline = TRUE
)

Arguments

graph

A barry_graph object.

which_nets

Integer vector. The networks to sample from.

prob

A numeric vector of length 4L or a data frame (see details).

i

Integer vector. The network to sample from.

keep_baseline

Logical scalar. When TRUE, the function returns the baseline network as the first element of the list.

Value

The function tie_level_accuracy returns a data frame with the following columns:

  • k: The perceiver id.

  • p_0_ego: The probability of no tie between the perceiver (ego) and an alter.

  • p_1_ego: The probability of a tie between the perceiver and an alter.

  • p_0_alter: The probability of no tie between two alters.

  • p_1_alter: The probability of a tie between two alters.

The function sample_css_network returns a list of square matrices of size attr(graph, "netsize"). If keep_baseline = TRUE, the first element of the list is the baseline network. Otherwise, it is not returned.

Details

There are two special cases worth mentioning. First, when the dyads in question are all present the probability of true negative is set to NA. On the other hand, if the dyads in question are all null, the probability of true positive is NA as well. This doesn't affect the sample_css_network function because those probabilities are unsed since tie/no tie probabilities are according to the baseline graph, meaning that, for instance, a fully connected network will never use the p_0_ego and p_0_alter probabilities and an empty network will never use the p_1_ego and p_1_alter probabilities.

The function sample_css_network samples perceived networks from the baseline network. The baseline network is the first network in the graph object. The function tie_level_accuracy can be used to generate the probability vector.

The probability vector is a numeric vector of length 4L. The first two elements are the probability of a tie/no tie between an ego and an alter. The third and fourth elements are the probability of a tie/no tie between two alters. When prob is a data frame, the function will sample from each row of the data frame (returned from the function tie_level_accuracy).

Examples

if (FALSE) { # \dontrun{
taccuracy <- tie_level_accuracy(graph)
boxplot(taccuracy[,-1])
} # }