srm_pseudo_rsq: Calculate Pseudo R-Squared Values for the Social Relations...

View source: R/srm_pseudo_rsq.R

srm_pseudo_rsqR Documentation

Calculate Pseudo R-Squared Values for the Social Relations Model

Description

Computes pseudo R-squared values for each SRM variance component by comparing a null model (intercept only) with a predictor model (with fixed effects). The pseudo R-squared for each component is (null - predicted) / null, reflecting the proportion of each variance component explained by the fixed effects.

Usage

srm_pseudo_rsq(null_model, predict_model)

Arguments

null_model

an lme object fitted with pdSRM and no fixed-effect predictors (intercept only)

predict_model

an lme object fitted with pdSRM and one or more fixed-effect predictors; must use the same dataset and random effects structure as null_model

Value

a data.frame with three columns and four rows (Group, Actor, Partner, Dyad):

null

variance component from the null model

predict

variance component from the predictor model

pseudoR2

pseudo R-squared: (null - predict) / null

Examples


d <- create_dummies(
  group_id = "groupId", act_id = "actId", part_id = "partId",
  data = sampleDyadData[sampleDyadData$timeId == 1, ],
  merge_original = TRUE
)
null_mod <- nlme::lme(
  liking ~ 1,
  random = list(groupId = nlme::pdBlocked(list(
    nlme::pdIdent(~1),
    pdSRM(~ -1 + a1 + a2 + a3 + a4 + p1 + p2 + p3 + p4)
  ))),
  correlation = nlme::corCompSymm(form = ~1 | groupId / pdSRM_dyad_id),
  data = d,
  na.action = stats::na.omit
)
pred_mod <- nlme::lme(
  liking ~ actEx + partEx + contact,
  random = list(groupId = nlme::pdBlocked(list(
    nlme::pdIdent(~1),
    pdSRM(~ -1 + a1 + a2 + a3 + a4 + p1 + p2 + p3 + p4)
  ))),
  correlation = nlme::corCompSymm(form = ~1 | groupId / pdSRM_dyad_id),
  data = d,
  na.action = stats::na.omit
)
srm_pseudo_rsq(null_model = null_mod, predict_model = pred_mod)


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