Calculates the total motif counts for a given model, in terms of the number of times each motif appears in the data.

motif_census(m, locs)

Arguments

m

An object of class DEFM.

locs

Idx (starting from zero) with the variables that will be included in the census.

Value

A matrix of class defm_motif_census with the motif counts.

References

Vega Yon, G. G., Pugh, M. J., & Valente, T. W. (2022). Discrete Exponential-Family Models for Multivariate Binary Outcomes (arXiv:2211.00627). arXiv. https://arxiv.org/abs/2211.00627

Examples

# Loading Valente's SNS data
data(valentesnsList)

mymodel <- new_defm(
  id = valentesnsList$id,
  Y = valentesnsList$Y,
  X = valentesnsList$X,
  order = 1
)

# Adding the intercept terms and a motif from tobacco to mj
term_defm_logit_intercept(mymodel)
term_defm_transition_formula(mymodel, "{y1, 0y2} > {y1, y2}")

# Initialize the model
init_defm(mymodel)

# Motif counts featuring only the first two variables
motif_census(mymodel, locs = 0:1)
#> Motif census for variable set: {alcohol, tobacco}
#>               Motif Total
#> 1 {0, 0} > {0, 0} *   642
#> 2 {1, 0} > {1, 0} *   273
#> 3   {0, 0} > {1, 0}   110
#> 4   {1, 0} > {1, 1}    45
#> 5 {1, 1} > {1, 1} *    33
#> 6   {0, 0} > {1, 1}    25
#> 7   {0, 0} > {0, 1}    14
#> 8   {0, 1} > {1, 1}    11
#> 9 {0, 1} > {0, 1} *     8
#> (*): No change