interdep helps researchers prepare cross-sectional and intensive
longitudinal dyadic data for multilevel models, including generalized
multilevel models.
It supports dyadic datasets with distinguishable dyads, exchangeable dyads, or mixed dyad types in the same data, such as female-male, female-female, and male-male couples. It creates composition-aware, model-ready columns for dyadic multilevel model parameterizations such as the Actor-Partner Interdependence Model (APIM), Dyad-Individual Model (DIM), and Dyadic Score Model (DSM).
Start with the vignettes, or scroll down for a quick-start.
| Vignette | Focus |
|---|---|
| Getting Started | Data structure, validation, dyad compositions, generated columns, and basic preparation |
| Actor-Partner Interdependence Model | APIM preparation and formulas for distinguishable and exchangeable dyads in cross-sectional and intensive longitudinal data |
| APIMs with Mixed Dyad Compositions | APIMs that combine distinguishable and exchangeable dyad compositions in one analysis |
| Dyad-Individual Model | DIM predictor construction, formulas, and an interactive demonstration of APIM-DIM equivalence for exchangeable dyads |
| Dyadic Score Model | DSM predictor-score and contrast construction, formulas, and the relationship between the DSM and APIM for distinguishable dyads |
For an in-depth tutorial covering data preparation, model fitting,
diagnostics, and assumption checks, see Distinguishable and
Exchangeable Dyads: Bayesian Multilevel
Modelling. It
uses interdep for cross-sectional and intensive longitudinal APIM and
DIM workflows, with models fitted primarily using brms
(source,
DOI).
You can install the development version of interdep from GitHub with:
# install.packages("pak")
pak::pak("Pascal-Kueng/interdep")Prepare distinguishable dyads for a cross-sectional APIM:
library(interdep)
prepared_data <- prepare_interdep_data(
example_dyadic_crosssectional,
group = coupleID,
member = personID,
role = gender,
predictors = communication,
model_type = "apim"
)
print(prepared_data, n = 4)
#> # interdep data
#> # Rows: 190 | Dyads: 95 | Intensive longitudinal: no
#> # Structure: group = coupleID, member = personID, role = gender
#> #
#> # Dyad compositions:
#> # female_x_male distinguishable 95 dyads
#> #
#> # Added columns:
#> # .i_composition inferred dyad composition
#> # .i_composition_role composition-specific member role
#> # .i_is_{comp-role} composition-role indicator columns
#> # .i_{pred}_actor APIM actor predictor: actor's original predictor
#> # values
#> # .i_{pred}_partner APIM partner predictor: partner's original predictor
#> # values
#> #
#> # A tibble: 190 × 11
#> personID coupleID gender communication satisfaction .i_composition
#> <int> <int> <fct> <dbl> <dbl> <fct>
#> 1 1 1 female 4.79 4.37 female_x_male
#> 2 2 1 male 3.80 2.34 female_x_male
#> 3 3 2 female 2.91 2.44 female_x_male
#> 4 4 2 male 6.51 6.08 female_x_male
#> # ℹ 186 more rows
#> # ℹ 5 more variables: .i_composition_role <fct>,
#> # .i_is_female_x_male_female <dbl>, .i_is_female_x_male_male <dbl>,
#> # .i_communication_actor <dbl>, .i_communication_partner <dbl>The prepared data contains the composition indicators and APIM actor/partner predictor columns used in the model formulas below.
One simple distinguishable APIM formula is:
simple_apim <- glmmTMB::glmmTMB(
satisfaction ~
# Gender-specific intercepts
0 + .i_is_female_x_male_female + .i_is_female_x_male_male +
# Gender-specific actor effects
.i_communication_actor:.i_is_female_x_male_female +
.i_communication_actor:.i_is_female_x_male_male +
# Gender-specific partner effects
.i_communication_partner:.i_is_female_x_male_female +
.i_communication_partner:.i_is_female_x_male_male +
# Dyad-level random effects represent the two members'
# residual covariance structure
us(0 + .i_is_female_x_male_female + .i_is_female_x_male_male | coupleID),
# With the residual covariance represented by the dyad-level
# random effects above, the Gaussian residual dispersion is fixed near zero.
dispformula = ~ 0,
family = gaussian(),
data = prepared_data
)If you use interdep, please cite the package directly:
@Manual{interdep,
title = {interdep: Prepare Dyadic Data for Multilevel Models},
author = {Pascal Küng},
year = {2026},
note = {R package version 0.0.0.9000},
url = {https://github.com/Pascal-Kueng/interdep},
}An archival DOI will be added once the package has a public release archive.
Continue with the Getting Started Vignette.
Or go directly to a model-specific vignette: