Learn R Programming

defm (version 0.2.1.0)

motif_census: Motif census

Description

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

Usage

motif_census(m, y_indices)

Value

A matrix of class defm_motif_census with the motif counts.

Arguments

m

An object of class DEFM.

y_indices

Non-negative integer vector indicating what dependent variables will be included.

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

Run this code
# 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
td_logit_intercept(mymodel)
td_formula(mymodel, "{y1, 0y2} > {y1, y2}")

# Initialize the model
init_defm(mymodel)

# Motif counts featuring only the first two variables
motif_census(mymodel, y_indices = 0:1)

Run the code above in your browser using DataLab