create_dummies: Create Dummy Variables for the Social Relations Model

View source: R/create_dummies.R

create_dummiesR Documentation

Create Dummy Variables for the Social Relations Model

Description

Generates the actor and partner dummy variables required to fit the Social Relations Model (SRM) using multilevel modeling, following the approach of Snijders and Kenny (1999). The function produces N actor dummies and N partner dummies, where N is the maximum group size in the dataset.

Usage

create_dummies(
  group_id,
  act_id,
  part_id,
  data,
  include_self = FALSE,
  merge_original = FALSE
)

Arguments

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

data

a data.frame structured in directed dyadic long-form, with one row per ordered (actor, partner) pair

include_self

logical; if TRUE self-ratings (actor == partner) are retained. Default is FALSE

merge_original

logical; if TRUE the generated identifiers and dummy variables are merged back onto the original dataset and returned together. Default is FALSE

Value

a data.frame containing:

pdSRM_act_id

integer internal actor identifier

pdSRM_part_id

integer internal partner identifier

pdSRM_act_num

integer actor slot number within group

pdSRM_part_num

integer partner slot number within group

pdSRM_dyad_id

integer undirected dyad identifier

a1, a2, ...

actor dummy variables

p1, p2, ...

partner dummy variables

If merge_original = TRUE, all original variables are appended.

References

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

d_out <- create_dummies(
  group_id = "groupId",
  act_id   = "actId",
  part_id  = "partId",
  data     = sampleDyadData
)
head(d_out)

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