Description Usage Arguments Details Value Examples
This function builds and fits a lavaan model for asssessing individual-level moderators of hearsay accuracy across multiple groups. It requires names of columns for target self-reports, P2 reports, an Individual Difference Moderator Variable, an interaction term, and a group-level moderator variable. The baseline/default model allows all estimated parameters to differ across groups. You can set some or all parameters to be equal across some or all groups by using the groups_eql and params_eql arguments.
1 2 3 4 |
data |
The dataframe that contains the ratings, moderator variables, and the interaction term. Data should be wide, with a row for every group of participants. At a minimum, it must contain five columns: one for target self-reports, one for mean-centered P2 reports, one for the mean-centered individual-level moderator variable, one for the interaction term, and one for the group variable. |
model |
Optional. A model from the corresponding ReputationModelR model builder function. If this is supplied, no additional arguments need to be specified. |
target_self |
Quoted column names that contain target self-reports. If more than one is supplied, the order must match the other rating types. |
p2_reports |
Quoted column names that contain P2 reports, or ratings made by the person that knows the target indirectly through the corresponding P1. Ratings should be grand-mean-centered to increase the interpretibility of the model parameters. If more than one is supplied, the target-wise order must match the other rating types. |
id_mod_variable |
Quoted column names that contain the individual-level moderator of interest. If more than one is supplied from multiple exchangeable triads, the order must match the order of the ratings. Like P2-reports, the variable should be mean-centered to facilitate interpretability. |
interaction_term |
Quoted column names that contain the interaction term, or the product of the mean-centered P2-report and the mean-centered moderator variable. If more than one is supplied from multiple exchangeable triads, the target-wise order must match the order of the ratings. |
group_mod |
The quoted column name that contains a group-level categorical moderator. |
use_labs |
Logical indicating whether or not to use the group labels to create the parameter labels. If FALSE, generic labels (grp1 to grpk, where k is the number of groups) are used. |
groups_eql |
Optional. Groups that you want to constrain to be equal across some or all parameters. If you have use_labs set to TRUE, provide a vector of group labels corresponding to the groups you want to constrain to be equal. If you have use_labs set to FALSE, provide a vector of numbers corresponding to the position of the groups you want to constrain to be equal. If you provide "all", all groups will be constrained to be equal. |
params_eql |
Optional. Parameters that you want to constrain to be equal across the groups specified in groups_eql. You can provide one or more specific parameters (e.g., "hc_me" for hearsay consensus main effect), or use a built-in options including "all" which constrains all parameters to be equal across groups. |
n_triads |
The number of exchangeable triads in each group. By default, this is determined by counting the number of P1 reports. This parameter rarely needs to be changed. |
n_ts_per_p2s |
The number of targets for every P2. This defaults to 1. Currently, only values of 1 are supported. |
n_p2s_per_ts |
The number of P2s for every target;. This defaults to 1. Currently, only values of 1 are supported. |
The parameters estimated by this model are:
hearsay accuracy main effect; this should correspond to hearsay accuracy at average level of moderator variable (if data were properly mean-centered).
The meain effect of the moderator variable; it can be interpreted as the difference in target self-reports related to differences in the individual-level moderator variable.
This is the interaction term. It indicates the extent to which hearsay accuracy, depends on the moderator variable
variance for T(T)
variance for P2(T)
variance for moderator variable
variance for interaction term
intercept for T(T)
intercept for P2(T)
intercept for moderator variable
intercept for interaction term
The function can handle up to n exchangeable triads.
The function returns an object of class lavaan
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | data("rep_sim_data")
# Prepare data
moderator_data <- rep_sim_data %>%
dplyr::mutate(B_C_agreeableness_cent = scale(B_C_agreeableness, scale = FALSE),
D_A_agreeableness_cent = scale(D_A_agreeableness, scale = FALSE),
B_iri_perspective_cent = scale(B_iri_perspective, scale = FALSE),
D_iri_perspective_cent = scale(D_iri_perspective, scale = FALSE),
B_ptXagree_interaction = B_C_agreeableness_cent*B_iri_perspective_cent,
D_ptXagree_interaction = D_A_agreeableness_cent*D_iri_perspective_cent)
# Fit a model examining perspective taking moderating hearsay accuracy across two studies
# allowing estimates to differ across studies
agree_pt_mod_fit <- rep_accuracy_group_id_mods(moderator_data,
target_self = c("C_C_agreeableness", "A_A_agreeableness"),
p2_reports = c("B_C_agreeableness_cent", "D_A_agreeableness_cent"),
id_mod_variable = c("B_iri_perspective_cent", "D_iri_perspective_cent"),
interaction_term = c("B_ptXagree_interaction", "D_ptXagree_interaction"),
group_mod = "study")
# Alternatively:
agree_pt_mod_model <- rep_accuracy_group_id_mods_builder(target_self = c("C_C_agreeableness", "A_A_agreeableness"),
p2_reports = c("B_C_agreeableness_cent", "D_A_agreeableness_cent"),
id_mod_variable = c("B_iri_perspective_cent", "D_iri_perspective_cent"),
interaction_term = c("B_ptXagree_interaction", "D_ptXagree_interaction"),
groups = c("study1", "study2"))
agree_pt_mod_fit <- rep_accuracy_group_id_mods(moderator_data, model = agree_pt_mod_model, group_mod = "study")
# You could constrain all parameters to be equal across all groups
# by setting both the groups_eql and params_eql arguments to "all"
agree_pt_mod_all_eq_fit<- rep_accuracy_group_id_mods(moderator_data,
target_self = c("C_C_agreeableness", "A_A_agreeableness"),
p2_reports = c("B_C_agreeableness_cent", "D_A_agreeableness_cent"),
id_mod_variable = c("B_iri_perspective_cent", "D_iri_perspective_cent"),
interaction_term = c("B_ptXagree_interaction", "D_ptXagree_interaction"),
group_mod = "study", groups_eql = "all", params_eql = "all")
# Or you could constrain one parameter to be equal across all groups
agree_pt_mod_ha_eq_fit<- rep_accuracy_group_id_mods(moderator_data,
target_self = c("C_C_agreeableness", "A_A_agreeableness"),
p2_reports = c("B_C_agreeableness_cent", "D_A_agreeableness_cent"),
id_mod_variable = c("B_iri_perspective_cent", "D_iri_perspective_cent"),
interaction_term = c("B_ptXagree_interaction", "D_ptXagree_interaction"),
group_mod = "study", groups_eql = "all", params_eql = "ha_me")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.