srm_run: Run the Social Relations Model Using Multilevel Modeling

View source: R/srm_run.R

srm_runR Documentation

Run the Social Relations Model Using Multilevel Modeling

Description

A wrapper function that fits the Social Relations Model (SRM) on a directed dyadic dataset using restricted maximum likelihood via lme. The function creates the necessary actor and partner dummy variables, constructs the SRM covariance structure using pdSRM, and returns both the raw lme output and a formatted variance decomposition table.

Usage

srm_run(dv, group_id, act_id, part_id, fe_vars = NULL, data)

Arguments

dv

string; name of the directed dyadic criterion (outcome) variable

group_id

string; name of the group identifier variable

act_id

string; name of the actor identifier variable

part_id

string; name of the partner identifier variable

fe_vars

character vector of fixed-effect predictor variable names, or NULL (default) for an intercept-only null model

data

a data.frame at the directed dyad level

Value

a named list with two elements:

lme.output

the full lme model object

srm.output

a data.frame from srm_var_pct giving variances, percentages, and reciprocity correlations

References

Knight, A. P., & Humphrey, S. E. (2019). Dyadic data analysis. In S. E. Humphrey & J. M. LeBreton (Eds.), The Handbook for Multilevel Theory, Measurement, and Analysis (pp. 423–447). American Psychological Association. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1037/0000115-019")}

Snijders, T. A. B., & Kenny, D. A. (1999). The social relations model for family data: A multilevel approach. Personal Relationships, 6, 471–486. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/j.1475-6811.1999.tb00204.x")}

Examples

o <- srm_run(
  dv       = "liking",
  group_id = "groupId",
  act_id   = "actId",
  part_id  = "partId",
  fe_vars  = c("actEx", "partEx", "contact"),
  data     = sampleDyadData[sampleDyadData$timeId == 1, ]
)
o$srm.output

roundRobinR documentation built on Sept. 18, 2026, 1:06 a.m.