| cpsrm | R Documentation |
cpsrm() is a friendly, tidyverse-style entry point for the
Co-Partner SRM. Give it raw long-format data and the names of the
outcome, actor, and group columns; it builds the actor/partner dummy
matrices with create_cp_dummies and fits the model with
cpsrm_run. Use cpsrm_run directly when you
need to supply your own dummy matrices (e.g. dummies built once and
reused across several model calls).
cpsrm(
data,
dv,
actor_id,
group_id,
location_id = NULL,
weight_partners = TRUE,
...
)
data |
a |
dv |
character; column name of the outcome variable |
actor_id |
character; column name of the actor/person identifier |
group_id |
character; column name of the group identifier |
location_id |
character or |
weight_partners |
logical; passed to both
|
... |
additional arguments passed through to
|
an object of class "cpsrm"; see cpsrm_run
for the full return value. The dummy-construction output from
create_cp_dummies is attached as $dummies for
reference (e.g. to inspect $dummies$group_size_table).
cpsrm_run for the full-control interface,
create_cp_dummies for the dummy-matrix construction this
wrapper calls internally
# cpsrm() expects one row per PERSON per GROUP, with every other group
# member treated as a simultaneous co-partner (e.g. one row per player
# per team, as in three-person golf teams). sampleDyadData is a
# round-robin/directed-dyad dataset (multiple rows per actor per group,
# one per rated partner) and is NOT the right shape for this function --
# see create_dummies()/srm_run() for that design instead. This example
# simulates a small, correctly-shaped dataset: 30 three-person teams
# drawn from a pool of 90 players.
set.seed(1)
team_dat <- do.call(rbind, lapply(1:30, function(g) {
data.frame(player = sample(1:90, 3), team = g)
}))
team_dat$score <- rnorm(nrow(team_dat), mean = 70, sd = 3)
fit <- cpsrm(
data = team_dat,
dv = "score",
actor_id = "player",
group_id = "team",
zero_rho = TRUE, # keep the toy example fast/well-behaved
se_method = "none",
stage1_maxit = 100,
stage2_maxit = 100
)
print(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.