| Title: | Pattern Identification for Dyadic Sequences Using Transition Matrices |
|---|---|
| Description: | Provides methods for analyzing dyadic interaction sequences using transition matrices within the Actor-Partner Interdependence Model. The package supports the computation of empirical transition counts, maximum likelihood estimation of transition probabilities, and identification of interaction patterns in univariate and bivariate dyadic interaction sequences. |
| Authors: | Mattia Böllenrücher [aut, cre, cph], Mégane Bollenrücher [aut], Jean-Philippe Antonietti [aut] |
| Maintainer: | Mattia Böllenrücher <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-05-31 17:05:23 UTC |
| Source: | https://github.com/boellenruecherm/dyadicmarkov-public |
Identifies the bivariate case as "trivial", "univariate",
"partial", or "complete" using two likelihood-ratio tests
against constrained bivariate structures.
bivariateCase(empirical, alpha = 0.05)bivariateCase(empirical, alpha = 0.05)
empirical |
An empirical bivariate count matrix with 16 rows and 2
columns, as returned by |
alpha |
A single number in (0, 1) giving the significance level. Default is 0.05. |
The returned case corresponds to the global approach of the bivariate method. It determines whether the sequence analyzed is treated as trivial, univariate, partial bivariate, or complete bivariate before the local identification of the pattern of interaction.
A list with class c("dyadic_case", "list") containing
components testUnivariate, testPartial, case, and
metadata fields alpha and call. It remains usable as an
ordinary list.
chainFM_V1 <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM_V1 <- c(2L, 1L, 2L, 1L, 1L, 2L) chainFM_V2 <- c(1L, 1L, 2L, 2L, 1L, 2L) chainSM_V2 <- c(2L, 2L, 1L, 1L, 2L, 1L) emp <- countEmpBivariate( chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L ) bivariateCase(emp, alpha = 0.05)chainFM_V1 <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM_V1 <- c(2L, 1L, 2L, 1L, 1L, 2L) chainFM_V2 <- c(1L, 1L, 2L, 2L, 1L, 2L) chainSM_V2 <- c(2L, 2L, 1L, 1L, 2L, 1L) emp <- countEmpBivariate( chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L ) bivariateCase(emp, alpha = 0.05)
Compares the complete bivariate patterns C, D1–D4, and E1–E4 using AIC and returns the selected pattern.
completePattern(empirical)completePattern(empirical)
empirical |
An empirical bivariate count matrix with 16 rows and 2
columns, as returned by |
Conditional on the complete bivariate case, AIC is used to select among the C, D1–D4, and E1–E4 structures.
A list with class c("dyadic_pattern", "list") containing
components aic (a data frame with columns pattern,
matrix, and aic), pattern (the selected pattern
label), and call. It remains usable as an ordinary list.
chainFM_V1 <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM_V1 <- c(2L, 1L, 2L, 1L, 1L, 2L) chainFM_V2 <- c(1L, 1L, 2L, 2L, 1L, 2L) chainSM_V2 <- c(2L, 2L, 1L, 1L, 2L, 1L) emp <- countEmpBivariate( chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L ) completePattern(emp)chainFM_V1 <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM_V1 <- c(2L, 1L, 2L, 1L, 1L, 2L) chainFM_V2 <- c(1L, 1L, 2L, 2L, 1L, 2L) chainSM_V2 <- c(2L, 2L, 1L, 1L, 2L, 1L) emp <- countEmpBivariate( chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L ) completePattern(emp)
Computes empirical transition counts for the sequences of the first and second member. Rows correspond to dyadic states of the two members, and columns correspond to the state of the first member at the next time point.
countEmp(chainFM, chainSM, states)countEmp(chainFM, chainSM, states)
chainFM |
Vector of observed states for the first member (FM). |
chainSM |
Vector of observed states for the second member (SM). |
states |
A single integer >= 2 giving the number of states. |
Rows correspond to current dyadic states .
For general states, the row index is computed as
1 + states * (FM_t - 1) + (SM_t - 1). Columns correspond to the
state of the first member at the next time point, .
An integer matrix with class
c("dyadic_counts", "matrix", "array"),
with rows and states columns. It remains usable as an
ordinary matrix.
chainFM <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM <- c(2L, 1L, 2L, 1L, 1L, 2L) countEmp(chainFM, chainSM, states = 2L)chainFM <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM <- c(2L, 1L, 2L, 1L, 1L, 2L) countEmp(chainFM, chainSM, states = 2L)
Computes empirical transition counts for bivariate categorical dyadic
sequences with two variables. This function currently supports
states = 2 only.
countEmpBivariate(chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L)countEmpBivariate(chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L)
chainFM_V1, chainSM_V1
|
Vectors of observed states for variable 1 for the first and second member. |
chainFM_V2, chainSM_V2
|
Vectors of observed states for variable 2 for the first and second member. |
states |
A single integer. Currently only |
The bivariate counter currently supports states = 2 only.
Rows represent the previous dyadic states of variable 1 and variable 2.
The implementation uses the row mapping
states^2 * (states * (FM_V1,t - 1) + (SM_V1,t - 1)) +
states * (FM_V2,t - 1) + (SM_V2,t - 1) + 1. Columns correspond to
the state of the first member on variable 1 at the next time point,
.
An integer matrix with class
c("dyadic_counts", "matrix", "array") with 16 rows and 2 columns
when states = 2. It remains usable as an ordinary matrix.
chainFM_V1 <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM_V1 <- c(2L, 1L, 2L, 1L, 1L, 2L) chainFM_V2 <- c(1L, 1L, 2L, 2L, 1L, 2L) chainSM_V2 <- c(2L, 2L, 1L, 1L, 2L, 1L) emp <- countEmpBivariate( chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L ) dim(emp)chainFM_V1 <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM_V1 <- c(2L, 1L, 2L, 1L, 1L, 2L) chainFM_V2 <- c(1L, 1L, 2L, 2L, 1L, 2L) chainSM_V2 <- c(2L, 2L, 1L, 1L, 2L, 1L) emp <- countEmpBivariate( chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L ) dim(emp)
A synthetic bivariate dyadic sequence with 90 observations, designed for package workflow examples.
dyadic_bivariate_exampledyadic_bivariate_example
A data frame with 90 rows and 5 columns:
Index of the measurement occasion.
Integer variable 1 state for the first member, taking values 1 or 2.
Integer variable 1 state for the second member, taking values 1 or 2.
Integer variable 2 state for the first member, taking values 1 or 2.
Integer variable 2 state for the second member, taking values 1 or 2.
The bivariate workflow classifies this example as complete
using bivariateCase with alpha = 0.05. The complete
bivariate pattern selected by completePattern is D2.
A synthetic dyadic sequence with 90 observations, designed for package workflow examples.
dyadic_univariate_exampledyadic_univariate_example
A data frame with 90 rows and 3 columns:
Index of the measurement occasion.
Integer state for the first member, taking values 1 or 2.
Integer state for the second member, taking values 1 or 2.
The package workflow classifies this example as PM (A3)
using univariatePattern with states = 2.
Estimates transition probabilities by maximum likelihood from an empirical
count matrix returned by countEmp or
countEmpBivariate.
mleEstimation(empirical)mleEstimation(empirical)
empirical |
An empirical count matrix. |
Each row of empirical is normalized independently. Rows with
zero total count are assigned a uniform probability vector, so each row of
the returned matrix sums to one.
A numeric matrix with class
c("dyadic_mle", "matrix", "array")
containing estimated transition probabilities with the same dimensions as
empirical. It remains usable as an ordinary matrix.
chainFM <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM <- c(2L, 1L, 2L, 1L, 1L, 2L) emp <- countEmp(chainFM, chainSM, states = 2L) mleEstimation(emp)chainFM <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM <- c(2L, 1L, 2L, 1L, 1L, 2L) emp <- countEmp(chainFM, chainSM, states = 2L) mleEstimation(emp)
Compares the partial bivariate patterns B1, B2, and B3 using AIC and returns the selected pattern.
partialPattern(empirical)partialPattern(empirical)
empirical |
An empirical bivariate count matrix with 16 rows and 2
columns, as returned by |
Conditional on the partial bivariate case, AIC is used to select among the B1, B2, and B3 structures.
A list with class c("dyadic_pattern", "list") containing
components aic (a data frame with candidate patterns and AIC
values), pattern (the selected pattern label), and call. It
remains usable as an ordinary list.
chainFM_V1 <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM_V1 <- c(2L, 1L, 2L, 1L, 1L, 2L) chainFM_V2 <- c(1L, 1L, 2L, 2L, 1L, 2L) chainSM_V2 <- c(2L, 2L, 1L, 1L, 2L, 1L) emp <- countEmpBivariate( chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L ) partialPattern(emp)chainFM_V1 <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM_V1 <- c(2L, 1L, 2L, 1L, 1L, 2L) chainFM_V2 <- c(1L, 1L, 2L, 2L, 1L, 2L) chainSM_V2 <- c(2L, 2L, 1L, 1L, 2L, 1L) emp <- countEmpBivariate( chainFM_V1, chainSM_V1, chainFM_V2, chainSM_V2, states = 2L ) partialPattern(emp)
Computes empirical transition counts, estimates transition probabilities by maximum likelihood, and performs likelihood-ratio tests against the actor-only and partner-only constrained models to identify the univariate pattern of interaction.
univariatePattern(chainFM, chainSM, states, alpha = 0.05)univariatePattern(chainFM, chainSM, states, alpha = 0.05)
chainFM |
Vector of observed states for the first member (FM). |
chainSM |
Vector of observed states for the second member (SM). |
states |
A single integer >= 2 giving the number of states. |
alpha |
A single number in (0, 1) giving the significance level. Default is 0.05. |
Pattern labels summarize which structure is retained by the tests:
IM (A0) denotes an independence pattern, APM (A1) an
actor-partner pattern, AM (A2) an actor-only pattern, and
PM (A3) a partner-only pattern.
A list with class c("dyadic_pattern", "list") containing two
htest objects (TEST.AM, TEST.PM), a string
pattern, and metadata fields alpha, states, and
call. It remains usable as an ordinary list.
chainFM <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM <- c(2L, 1L, 2L, 1L, 1L, 2L) univariatePattern(chainFM, chainSM, states = 2L, alpha = 0.05)chainFM <- c(1L, 2L, 1L, 2L, 2L, 1L) chainSM <- c(2L, 1L, 2L, 1L, 1L, 2L) univariatePattern(chainFM, chainSM, states = 2L, alpha = 0.05)