fit_srm_rsa: Fit Response Surface Analysis Paths

Description Usage Arguments Details Value Examples

View source: R/core_functions.R

Description

This function fits the social relations models response surface analysis. It requires a dataframe that contains columns for percever, target, and group ID variables and rating variables for the X, Y, Z variables for a response surface analysis (Z ~ X * Y). The Z variable will be treated as the rating in the social relations model, and the response surface analysis will be conducted on the relationship effect of that rating (i.e., after partialling out target, perceiver, and group effects).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fit_srm_rsa(
  data,
  perceiver_id,
  target_id,
  group_id,
  rating_x,
  rating_y,
  rating_z,
  design = NULL,
  ...
)

Arguments

data

The dataframe. It must contain columns for percever, target, and group ID variables and X, Y, and Z rating variables. Note that X and Y can be the same variable. It should be in long format such that each row is a rating by a perceiver for a given target in a given group.

perceiver_id

A quoted string with the name of the column containing perceiver IDs. Perceiver IDs should be recycled across groups (i.e., each group should have perceiver 1 to i where i is the number of participants per group). Perceiver and Target id should match such that perceiver i is target i and vice versa. It can either be a number of a character string.

target_id

A quoted string with the name of the column containing target IDs. target IDs should be recycled across groups (i.e., each group should have target 1 to i where i is the number of participants per group). Perceiver and Target id should match such that perceiver i is target i and vice versa. It can either be a number of a character string.

group_id

A quoted string with the name of the column containing group IDs.It can either be a number of a character string.

rating_x

A quoted string with the name of the column that contains ratings for the x variable in the RSA.

rating_y

A quoted string with the name of the column that contains ratings for the y variable in the RSA. Note that this can be the same variable as x as long as design is not pxp.

rating_z

A quoted string with the name of the column that contains ratings for the z variable (the outcome/DV) in the RSA.

design

A quoted string specifying the design of the RSA. Valid entries include:

reciprocal

X and Y are reciprocal ratings for each dyad; this can be on the same variable (e.g., A(B) Liking & B(A) Liking) or on different variables (e.g., A(B) Liking & B(A) Meta-Liking)

pxp

X and Y are two ratings from the same perceiver rating the same target (e.g., A(B) Liking and A(B) Meta-Liking). These have to be different variables.

pxps

X is a perceiver's rating of a target and y is the perceivers' self-report. This can be on the same or different variables.

pxts

X is a perceiver's rating of a target and y is the targets' self-report. This can be on the same or different variables.

psxts

X is a perceiver's self-report and y is the targets' self-report. This can be on the same or different variables.

...

Optional additional arguments passed directly to lavaan as it fits each model. For example, it can be used to specify bootstrapped or robust standard errors. Note this will affect all three of the fitted models.

Details

This function will mean-center the X and Y variables for you before it runs the analyses. It also creates the cross-products for you based on the rating variables and design specified. It will then fit 3 models:

Social Relations Model

This is a basic Social Relations model Estimating Target, Perceiver, Relationship effects, and the Target-Perceiver and relationship Covariances

SRM RSA Null Model

This is the SRM RSA model where slopes for the interation and polynomial terms are set to zero, to test whether and RSA is appropriate.

SRM RSA

This is the full SRM RSA model with b1 through b5 and surface parameters a1 through a5

For each model, it returns a string for the model (as lavaan syntax), fitted lavaan models, and a model comparison table comparing model 2 to 3.

Value

The function returns a list containing the following elements:

srm_model

string. SRM model in lavaan syntax treating z as rating.

rsa_paths

string. regression paths, intercepts, and variances for rsa in lavaan syntax.

srm_rsa_model

string. SRM RSA model in lavaan syntax.

srm_fit

fitted lavaan model. Contains basic SRM (on Z variable).

srm_rsa_null_fit

fitted lavaan model. Contains SRM RSA Null model where interaction and polynomial are set to zero. Preimarily used for model comparison.

srm_rsa_fit

fitted lavaan model. Contains full SRM RSA Model including surface parameters.

srm_rsa_model_comp

a tibble. Contains the model comparison results from comparing the SRM RSA Null model to the full SRM RSA model.

wide_df

a tibble. Contains the wide version of the data created by the fit_srm_rsa function. It should be a row for each group, and a column for every rating in the format rating_perceiverid_targetid; squared terms are in the format rating_sq_perceiverid_targetid; interaction terms when x and y are the same variable (with different perceiver-target combos) are in the format rating_perceiverid_targetid_x_perceiverid_targetid; interaction terms when x and y are different variables are in the format ratingx_perceiverid_targetid_x_ratingy_perceiverid_targetid.

Examples

1
#NEED TO SIMULATE DATA

Coryc3133/srmRsa documentation built on Dec. 31, 2020, 11:51 a.m.