--- title: "One-with-many (OWM) Tutorial" output: rmdformats::robobook: html_document: default word_document: default editor_options: chunk_output_type: console --- # Overview The one-with-many (OWM) model (Kenny & Winquist, 2001; Kenny, Kashy, & Cook, 2006, Chapter 10) is a dyadic analytic technique that exists in the middle ground between the standard (APIM-type; [QuantDev APIM Tutorial](https://quantdev.ssri.psu.edu/tutorials/actor-partner-interdependence-model-apim-basic-dyadicbivariate-analysis)) dyadic model and the social relations (round robin-type) model. The OWM model was specifically constructed for and is used to examine features of multiple dyadic relationships a set of focal persons (e.g., therapists, physicians) has with others (e.g., multiple clients, patients). While this model was originally designed for and applied to cross-sectional data, the model can be extended to accommodate and may be particularly useful for the analysis of intensive repeated measures data now being obtained through experience sampling and social media. A more in-depth description and illustration of this model can be found in Brinberg, Ram, Conroy, Pincus, and Gerstorf (2022). In this tutorial, we will walk through two- and three-level OWM models using the AMIB dataset - an experience sampling study of daily social interactions, emotions, and behaviors from *N* = 190 college students. In addition, the accompanying "OWM_Tutorial_2022August20.rmd" file contains all of the code presented in this tutorial and can be opened in RStudio (a somewhat more friendly user interface to R). To read more about the three-level OWM see: Brinberg, M., Ram, N., Conroy, D.E., Pincus, A.L., & Gerstorf, D. (2022). Dyadic analysis and the reciprocal one-with-many model: Extending the study of interpersonal processes with intensive longitudinal data. *Psychological Methods.* [doi: 10.1037/met0000380](https://pubmed.ncbi.nlm.nih.gov/33475420/) # Outline In this tutorial, we'll cover... * Introduction to the Research Questions and Data. * Descriptives, Data Preparation, and Plotting. * Two-level OWM model. * Three-level OWM model. * Cautions and Conclusion. # Introduction to the Research Questions and Data. ## The Research Questions. We are going to address: * In the two-level model: + Is focal person extraversion associated with focal persons' or partners' reports of communion? This will be addressed by examining the fixed effects. + How much variability in communion (i.e., interpersonal warmth) reported after a social interaction is due to differences (1) between dyads within focal persons and (2) between focal persons? Stated differently, do focal persons view communion with their partners similarly and do partners view communion with their focal person similarly? These questions will be addressed by examining the random effects of the model. + Are there unique relationship effects between focal persons and partners - i.e., are there components of the relationship not accounted for by how the focal person views all of their partners and how all of the partners view the focal person? This will be addressed by examining the residual terms. * In the three-level model: + Is perceived partner dominance during an interaction associated with focal persons' or partners' reports of communion? This will be addressed by examining the fixed effects. + Is focal person extraversion associated with focal persons' or partners' reports of communion? Furthermore, does focal person extraversion moderate the association between perceptions of communion and dominance during a social interaction? This will be addressed by examining the fixed effects. + How much variability in communion (i.e., interpersonal warmth) reported after a social interaction is due to differences (1) within dyads, (2) between dyads within focal persons, and (3) between focal persons? Stated differently, do focal persons view communion with their partners similarly and do partners view communion with their focal person similarly? These questions will be addressed by examining the random effects of the model. + Are there unique relationship effects between focal persons and partners - i.e., are there components of the relationship not accounted for by how the focal person views all of their partners and how all of the partners view the focal person? This will be addressed by examining the residual terms. ## The Data. **Let's read the data into R.** We are working with two data sets in this tutorial. One data set contains repeated measures ("AMIBshare_interaction_2019_0501"), specifically the assessments of each interaction from each individual within the study. The other data set contains time-invariant data ("AMIBshare_persons_2019_0501"), such as individuals' self-reported extraversion. Both data sets are stored as .csv files (comma-separated values file, which can be created by saving an Excel file as a csv document) on my computer's desktop. ```{r} # Set working directory (i.e., where your data file is stored) # This can be done by going to the top bar of RStudio and selecting # "Session" --> "Set Working Directory" --> "Choose Directory" --> # finding the location of your file setwd("~/Desktop")# Note: You can skip this line if you have # the data file and this .rmd file stored in the same directory # Read in the repeated measures data amib_interaction <- read.csv(file = "AMIBshare_interaction_2019_0501.csv", head = TRUE, sep = ",") # View the first 10 rows of the repeated measures data head(amib_interaction, 10) # Read in the person-level data amib_persons <- read.csv(file = "AMIBshare_persons_2019_0501.csv", head = TRUE, sep = ",") # View the first 10 rows of the persons data head(amib_persons, 10) # Merge daily and person-level data amib <- merge(amib_persons, amib_interaction, by = "id") # View the first 10 rows of the merged data head(amib, 10) # Subset the data to select the variables we need amib <- amib[ , c("id", "day", "interaction", "partner_status", "igaff", "igdom", "sbi_commun", "bfi_e")] # View the first 10 rows of the subset data head(amib, 10) ``` The data are organized as follows: * We have one data set that contains person-level information collected at the baseline of the study. Since there are *N* (number of individuals) = 190 individuals, this data set will be 190 rows long. * We have another data set that contains interaction-level information. Each individual in the study reported on every interaction that lasted greater than five minutes, so we expect a varying number of reports per individual. In total, we have 7,568 rows of data. The data sets have additional columns we will not use, so we will subset to only the variables we need. Specifically... * Participant ID (`id`) * Day (i.e., day in study; `day`) * Interaction (i.e., interaction number; `interaction`) * Partner type (i.e., categorical label for interaction partner, including friends, strangers, etc.; `partner_status`) * Big Five Inventory: Extraversion (`bfi_e`) * Partner communion (`igaff`) * Partner dominance (`igdom`) * Focal person communion (`sbi_commun`) After merging, we have a data set with 7,568 rows and 8 columns of data, with person-level (i.e., time invariant) information attached to all measurement occasions. **Load the R packages we need.** Packages in R are a collection of functions (and their documentation/explanations) that enable us to conduct particular tasks, such as plotting or fitting a statistical model. ```{r, warning = FALSE, message = FALSE} # install.packages("devtools") # Install package if you have never used it before require(devtools) # For version control # install.packages("dplyr") # Install package if you have never used it before library(dplyr) # For data manipulation # install.packages("fastDummies") # Install package if you have never used it before library(fastDummies) # For creating dummy codes # install.packages("ggplot2") # Install package if you have never used it before library(ggplot2) # For plotting # install.packages("nlme") # Install package if you have never used it before library(nlme) # For multilevel modeling analysis # install.packages("psych") # Install package if you have never used it before library(psych) # For descriptive statistics # install.packages("reshape2") # Install package if you have never used it before library(reshape2) # For data manipulation ``` Create a variable within each partner type that counts the number of interactions with that partner type. ```{r} amib <- # Select data set amib %>% # Select grouping variable, in this case, # focal person (id) and partner type within focal person (partner_status) group_by(id, partner_status) %>% # Create new variable ("int_count") that # counts the rows 1 by 1, starting from 1 mutate(int_count = 1:(n())) %>% # Save the data as a data.frame as.data.frame() # View the first 10 rows of the data head(amib) ``` # Descriptives, Data Preparation, and Plotting. ### Descriptives. Before beginning our analyses, it is useful to get a feel for the data we are working with. So, we start by describing the number of social interactions for each participant and the number of social interactions per day for each participant. Number of social interactions per participant. ```{r} int_count <- # Select data set amib %>% # Select grouping variable, in this case, focal person (id) group_by(id) %>% # Create new variable ("num_interactions") that # counts the number of social interactions per focal person summarise(num_interactions = length(interaction)) %>% # Save the data as a data.frame as.data.frame() # Describe the average number of social interactions per focal person describe(int_count$num_interactions) ``` On average, each participant had a total of 41.13 social interactions (*SD* = 13.62) over the course of the eight-day study, ranging from a minimum of 10 social interactions to a maximum of 56 social interactions that lasted over five minutes. Number of social interactions per person per day. ```{r} int_count_day <- # Select data set amib %>% # Select grouping variable, in this case, # focal person (id) and day within focal person (day) group_by(id, day) %>% # Create new variable ("num_interactions") that # counts the number of social interactions per focal person summarise(num_interactions = length(interaction)) %>% # Save the data as a data.frame as.data.frame() # Here, you may see a message related to the grouping approach used by the summarise() function # Examine the int_count_day data frame to verify that both id and day were used to group interaction count data # View the first 10 rows of the count data head(int_count_day) # Describe the average number of social interactions per focal person within a day describe(int_count_day$num_interactions) ``` On average, each participant had a total of 6.03 social interactions (*SD* = 2.12) each day over the course of the eight-day study, ranging from a minimum of 1 social interaction to a maximum of 8 social interactions each day that lasted over five minutes. Next, let's examine our outcome (*focal person communion* = `sbi_commun`; *partner communion* = `igaff`) and predictor (*focal person extraversion* = `bfi_e`; *partner dominance* = `igdom`) variables. Above the two partner-related variables, you will see a warning about rows being removed. In this case, it is due to missing values in the data set, but it is always a good idea to examine your data to identify reasons for warning messages. ```{r} # Describe focal person reports of communion describe(amib$sbi_commun) # Plot distribution of focal person communion ggplot(# Select data set, value on x-axis data = amib, aes(x = sbi_commun)) + # Select width of histogram bars geom_histogram(binwidth = 0.5) + # Label for x-axis xlab("Focal Person Communion") + # Plot aesthetics theme_classic() # Describe partner reports of communion describe(amib$igaff) ggplot(# Select data set, value on x-axis data = amib, aes(x = igaff)) + # Select width of histogram bars geom_histogram(binwidth = 0.5) + # Label for x-axis xlab("Partner Communion") + # Plot aesthetics theme_classic() # Describe focal person extraversion describe(amib$bfi_e) ggplot(# Select data set, value on x-axis data = amib, aes(x = bfi_e)) + # Select width of histogram bars geom_histogram(binwidth = 0.25) + # Label for x-axis xlab("Focal Person Extraversion") + # Plot aesthetics theme_classic() # Describe partner dominance describe(amib$igdom) ggplot(# Select data set, value on x-axis data = amib, aes(x = igdom)) + # Select width of histogram bars geom_histogram(binwidth = 0.5) + # Label for x-axis xlab("Partner Dominance") + # Plot aesthetics theme_classic() ``` ### Data Preparation. Currently, our data are in a "long" format (i.e., there is a single row for each occasion in the data set). Because this data set was not originally structured as a study of dyads, we are going to manipulate our data in order to mimic dyadic data. First, let's double check the structure of our variables. We want to make sure the "partner_status" variable is a factor variable. ```{r} str(amib) ``` We need to change "partner_status" to a factor variable to recognize that the numerical values in this column denote types of relationships. This will make sure R treats partner_status as a categorical variable. ```{r} amib$partner_status <- as.factor(amib$partner_status) ``` We also create dummy codes for the "partner_status" variable, which we will use in the three-level OWM model. ```{r} amib <- dummy_cols(amib, select_columns = c("partner_status")) ``` For the sake of this tutorial, remove rows in which information about the partner is missing. ```{r} amib <- amib[complete.cases(amib[ , "partner_status"]),] ``` Then, we have to re-do the interaction count (`int_count`) variable to re-count the interactions now that we removed the missing data. ```{r} amib <- # Select data set amib %>% # Select grouping variable, in this case, # focal person (id) group_by(id) %>% # Create new variable ("interaction") that # counts each row 1 by 1, starting from 1 mutate(interaction = 1:length(interaction)) %>% # Save the data as a data.frame as.data.frame() ``` Next, we're going to do a bit of data management and "fudge" the data in a way so it is dyadic. Repeat each row twice, so we can have a row for each member of the "dyad" at each interaction. ```{r} amib <- amib[rep(seq_len(nrow(amib)), # Repeat the length of each row # in the amib data set each=2), ] # Repeat each row twice ``` Create variables to indicate whether the row is a focal person or partner. Specifically: * focalcode = 1 if data are from the focal person and 0 if the data are from partner * partcode = 1 if data are from partner and 0 if data are from the focal person ```{r} # Identify even and odd rows in the data set even_indexes <- seq(2, nrow(amib), 2) odd_indexes <- seq(1, nrow(amib) - 1, 2) # Focal person dummy code amib$focalcode <- 0 amib[odd_indexes, "focalcode"] <- 1 # Partner dummy code amib$partcode <- 1 amib[odd_indexes, "partcode"] <- 0 # View the first 10 rows of the data head(amib, 10) ``` Self and partner communion are on different scales, so we will standardize these for the sake of interpretation. ```{r} amib$self_comm <- scale(amib$igaff) amib$partner_comm <- scale(amib$sbi_commun) ``` Extraversion (`bfi_e`) should be also centered before analysis so that the intercept terms indicate expected value for an average person rather than for a person with bfi_e = 0 (who does not exist in the data). ```{r} amib$bfi_e_c <- scale(amib$bfi_e, center = TRUE, scale = FALSE) ``` Create a new outcome variable for communion, such that one column alternates between self and partner reports of commuion. Make sure that self communion reports are in rows where the focal person dummy variable (`focalcode`) is equal to one, and that the partner communion reports are in rows where the partner person dummy variable (`partcode`) is equal to one. ```{r} amib$communion[amib$focalcode == 1] <- amib$self_comm[amib$focalcode == 1] amib$communion[amib$partcode == 1] <- amib$partner_comm[amib$partcode == 1] # View the first 10 rows of the data head(amib, 10) ``` The data are now ready for modeling! ### Plotting. Before modeling, it can be helpful to plot the data to understand between- and within-individual differences. For a subset of participants, plot focal persons' and partners' reports of communion over time across partner types. ```{r} ggplot() + geom_rect(# Create rectangles that indicate the type of # interaction partner # Select a subset of focal persons data = amib[which(amib$id < 111), ], # Set width of rectangles aes(xmin = interaction - .5, xmax = interaction + .5, # Set height of rectangles ymin = -5, ymax = 5, # Set color of rectangles to indicate # interaction partner type fill = as.factor(partner_status))) + # Create line that plots partners' ratings of communion geom_line(# Select a subset of focal persons data = amib[which(amib$id < 111), ], # Set time variable on x-axis (interaction), # Set partners' communion (partner_comm) on y-axis # Set size of line aes(x = interaction, y = partner_comm), size = 1) + # Create line that plots focal persons' ratings of communion geom_line(# Select a subset of focal persons data = amib[which(amib$id < 111), ], # Set time variable on x-axis (interaction), # Set focal persons' communion (self_comm) on y-axis # Set size of line aes(x = interaction, y = self_comm), color = "white", size = 1) + # Label for x-axis xlab("Interaction Number") + # Label for y-axis ylab("Partner Reports of Communion = Black\nFocal Person Reports of Communion = White") + # Create a plot for each focal person facet_wrap( ~ id) + # Set title for legend of rectangle color (interaction partners) scale_fill_discrete(name = "Partner Type") + # Additional plot aesthetics theme_classic() + theme(axis.text.y=element_blank()) ``` In this plot, we can see differences in the number of interactions these 9 participants had, how self and partner reports of communion were (both within and across individuals), and differences in who these participants were interacting with (through the background color). # Two-level OWM model. We'll first construct a model examining differences in partners' and focal persons' reports of communion (`communion`) by focal person extraversion (`bfi_e`) - *not* distinguishing by partner type. We use the two dummy variables (`focalcode` and `partcode`) to turn on and off the parameters. The parameters invoked with $focalcode$ are associated with the focal persons' reports of communion, and parameters invoked with $partcode$ are associated with the partners' reports of communion. Level 1 of the multilevel model is as follows: $$Communion_{di} = \gamma_{0Fi}Focal_{di} + \gamma_{0Pi}Partner_{di} + e_{Fdi} +e_{Pdi}$$ And Level 2 of the multilevel model: $$\gamma_{0Fi} = \pi_{00F} + \pi_{01F}FocalExtraversion_{i} + v_{0Fi} \\ \gamma_{0Pi} = \pi_{00P} + \pi_{01P}FocalExtraversion_{i} + v_{0Pi}$$ Noting that our random effect matrices also expand, $$\mathbf{R} = \left[\begin{array} & \sigma^2_{eFdi} & \sigma_{eFdiePdi} \\ \sigma_{eFdiePdi} & \sigma^2_{ePdi} \end{array}\right]$$ where $\sigma_{eFdiePdi}$ is the residual covariance between focal person and partner communion. and $$\left[\begin{array} {rrrr} \sigma^{2}_{v0Fi} & \sigma_{v0Fiv0Pi} \\ \sigma_{v0Fiv0Pi} & \sigma^{2}_{v0Pi} \\ \end{array}\right]$$ where the matrix is blocks of between-focal person associations. *These are sample-level, between-dyad relations, and should be interpreted appropriately.* We are going to take a subset of our data to make cross-sectional data. So, we'll select the first social interaction with each partner type for each participant. ```{r} two_level <- # Select data set amib %>% # Select grouping variable, in this case, # focal person (id) and interaction partner (partner_status) group_by(id, partner_status) %>% # Keep first and second row within each group filter(row_number() == 1 | row_number() == 2) %>% # Reset grouping variable to focal person (id) only group_by(id) %>% # Create new variable (measurement) that # counts each interaction 1 by 1, starting from 1 # but since there are two measurements per interaction, # each value needs to be repeated for two rows mutate(measurement = rep(1:(n()/2), each = 2)) %>% # Save the data as a data.frame as.data.frame() # View the first 10 rows of the data head(two_level, 10) ``` Now, we run our model of interest: examining differences in partners' and focal persons' reports of communion (`communion`) by focal person extraversion (`bfi_e`) - *not* distinguishing by partner type. ```{r} # Set optimizer to be used in model ctrl <- lmeControl(opt='optim') model_2level <- lme(# The outcome variable (communion) is regressed onto # no intercept (-1) since we separately estimate intercepts # for the dyad members with dummy coded variables, specifically # focalcode and partcode, and # extraversion's impact on the focal person and partner # using interaction terms fixed = communion ~ -1 + focalcode + partcode + focalcode:bfi_e_c + partcode:bfi_e_c, # Allow for random intercepts for focal persons and partners # within each focal person (id) # The -1 makes sure no intercept is estimated random = ~ -1 + focalcode + partcode | id, # Set the weights of the variances, # allowing for differences between # focal persons and partners weights = varIdent(form = ~1 | focalcode), # Set correlation structure, in this case, # compound symmetry within each dyad member (focal person/partner) # within each focal person corr = corCompSymm(form = ~as.numeric(focalcode) | id/focalcode), # Set optimizer control = ctrl, # Select data set data = two_level, # Exclude rows with missing data na.action = na.exclude) # Examine the model summary summary(model_2level) ``` #### Brief Interpretation of the Results Going back to the original research questions outlined at the beginning of the tutorial... * Is focal person extraversion associated with focal persons' or partners' reports of communion? + The association between focal persons' extraversion and focal person reports of communion ($\pi_{01F}$) is -0.01 and is not significantly different from zero. Furthermore, the association between focal persons' extraversion and partner reports of communion ($\pi_{01P}$) is -0.01 and is not significantly different from zero. * How much variability in communion (i.e., interpersonal warmth) reported after a social interaction is due to differences (1) between dyads within focal persons and (2) between focal persons? Stated differently, do focal persons view communion with their partners similarly and do partners view communion with their focal person similarly? + The standard deviation around focal person ($\sigma_{v0Fi}$) and partners ($\sigma_{v0Pi}$) reports of communion is 0.32 and 0.27, respectively. Additionally, focal person and partners reports of communion are correlated 0.41, indicating that members of the same dyad often have relatively similar reports of communion. * Are there unique relationship effects between focal persons and partners - i.e., are there components of the relationship not accounted for by how the focal person views all of their partners and how all of the partners view the focal person? + The standard deviation around the focal person residual ($\sigma_{eF}$) is 0.95 and the standard deviation around the partner residual ($\sigma_{eP}$) is 1.04 (0.949 * 1.099), indicating unique relationship effects. #### Plotting the results. Calculate estimates for focal persons and partners at +/- 1SD for centered extraversion for focal persons and partners. ```{r} # Find -1 and +1 SD of extraversion describe(amib$bfi_e_c) # Points at which to estimate communion extraversion <- c(-0.97, 0, 0.97) # Calculate communion for each focal person and partner +/- 1SD extraversion fp_est <- -0.12 + -0.01*extraversion p_est <- 0.02 + -0.01*extraversion # Combine all of these into one vector fit_estimates <- c(fp_est, p_est) ``` Build a data set that contains the predicted values. ```{r} # Focal person / partner label focal_partner <- rep(c("Focal Person", "Partner"), each = 3) # Extraversion levels extraversion_repeat <- rep(c(-0.97, 0, 0.97), 2) plot_data <- data.frame(focal_partner = focal_partner, extraversion = extraversion_repeat, fit_estimates) ``` Plot. ```{r} ggplot(# Select data set plot_data, # Select value on x-axis (extraversion) and # value on y-axis (predicted values) # Set color of line depending on dyad member aes(x = extraversion, y = fit_estimates, color = focal_partner, group = focal_partner)) + # Set size of line geom_line(size = 1) + # Label axes and legend labs(title = "Extraversion-Communion Association", x = "Extraversion", y = "Communion", color = "Person", fill = "Person", size = 12) + # Set limits of y-axis ylim(-2, 2) + # Plot aesthetics theme_classic() + theme(text=element_text(size=12)) + theme(plot.title = element_text(hjust = 0.5)) ``` # Three-level OWM model. Next, we are going to run the three-level OWM model which incorporates the repeated measures for each partner type and allows us to examine within-dyad processes. Specifically, we'll construct a model examining the focal person, partner, and relationship effects of communion during social interactions with different types of partners (`partner_status`), and whether the perceived partner dominance during the interaction (`igdom`) or the extraversion of the focal person (`bfi_e`) were associated with reports of communion (`communion`). We use the two dummy variables (`focalcode` and `partcode`) to turn on and off the parameters. The parameters invoked with $focalcode$ are associated with the focal persons' reports of communion, and parameters invoked with $partcode$ are associated with the partners' reports of communion. We also recast `partner_status` as a set of 8 dummy variables (`partner_status_2` through `partner_status_9`). The `partner_status` equal to 1 was used as the reference category, and the model parameters associated with the 8 dummy variables represent deviations for each partner type from the `partner_status` equal to 1 type. Level 1 of the multilevel model is as follows: $$Communion_{tdi} = \beta_{0Fdi}Focal_{tdi} + \beta_{0Pdi}Partner_{tdi} + \\ \beta_{1Fdi}Focal_{tdi}*PartnerDominance_{tdi} + \beta_{1Pdi}Partner_{tdi}*PartnerDominance_{tdi} + \\ e_{Ftdi} +e_{Ptdi}$$ And Level 2 of the multilevel model: $$\beta_{0Fdi} = \gamma_{00Fi} + \gamma_{01Fi}Partner2_{di} + ... + \gamma_{08Fi}Partner9_{di} + u_{0Fdi} \\ \beta_{0Pdi} = \gamma_{00Pi} + \gamma_{01Pi}Partner2_{di} + ... + \gamma_{08Pi}Partner9_{di} + u_{0Pdi} \\ \beta_{1Fdi} = \gamma_{10Fi} + \gamma_{11Fi}Partner2_{di} + ... + \gamma_{18Fi}Partner9_{di} + u_{1Fdi} \\ \beta_{1Pdi} = \gamma_{10Pi} + \gamma_{11Pi}Partner2_{di} + ... + \gamma_{18Pi}Partner9_{di} + u_{1Pdi}$$ Finally, Level 3 of the multilevel model: $$\gamma_{00Fi} = \pi_{000F} + \pi_{001F}FocalExtraversion_{i} + v_{00Fi} \\ \gamma_{01Fi} = \pi_{010F} + \pi_{011F}FocalExtraversion_{i} \\ ... \\ \gamma_{08Fi} = \pi_{080F} + \pi_{081F}FocalExtraversion_{i} \\ \gamma_{00Pi} = \pi_{000P} + \pi_{001P}FocalExtraversion_{i} + v_{00Pi} \\ \gamma_{01Pi} = \pi_{010P} + \pi_{011P}FocalExtraversion_{i} \\ ... \\ \gamma_{10Fi} = \pi_{100F} + \pi_{101F}FocalExtraversion_{i} + v_{10Fi} \\ \gamma_{11Fi} = \pi_{110F} + \pi_{111F}FocalExtraversion_{i} \\ ... \\ \gamma_{18Fi} = \pi_{180F} + \pi_{181F}FocalExtraversion_{i} \\ \gamma_{10Pi} = \pi_{100P} + \pi_{101P}FocalExtraversion_{i} + v_{10Pi} \\ \gamma_{11Pi} = \pi_{110P} + \pi_{111P}FocalExtraversion_{i} \\ ... \\ \gamma_{18Pi} = \pi_{180P} + \pi_{181P}FocalExtraversion_{i}$$ Finally, the covariance structure of the three-level OWM model follows the same pattern as the random effects structure presented for the two-level OWM model, except there is an additional 4 x 4 matrix that contains the variances and covariances of the random effects at the third level. The following model examines the focal person, partner, and relationship effects of communion during social interactions with different types of partners, and whether the perceived partner dominance during the interaction or the extraversion of the focal person were associated with reports of communion. ```{r} # Set optimizer to be used in model ctrl <- lmeControl(opt='optim') model_3level <- lme(# The outcome variable (communion) is regressed onto # no intercept (-1) since we separately estimate intercepts # for the dyad members with dummy coded variables, specifically # focalcode and partcode, and # the impact of partners' dominance on communion # using interaction terms, and # extraversion's impact on the focal person and partner # using interaction terms, and # three-way interactions between dominance and extraversion # on communion fixed = communion ~ -1 + focalcode + partcode + focalcode:igdom + partcode:igdom + focalcode:bfi_e_c + partcode:bfi_e_c + focalcode:igdom:bfi_e_c + partcode:igdom:bfi_e_c + # Estimating communion intercepts for each partner type from # both the focal person and partner perspective focalcode:partner_status_2 + partcode:partner_status_2 + focalcode:partner_status_3 + partcode:partner_status_3 + focalcode:partner_status_4 + partcode:partner_status_4 + focalcode:partner_status_5 + partcode:partner_status_5 + focalcode:partner_status_6 + partcode:partner_status_6 + focalcode:partner_status_7 + partcode:partner_status_7 + focalcode:partner_status_8 + partcode:partner_status_8 + focalcode:partner_status_9 + partcode:partner_status_9 + # Estimating impact of partner's dominance on communion for each partner type from # both the focal person and partner perspective focalcode:partner_status_2:igdom + partcode:partner_status_2:igdom + focalcode:partner_status_3:igdom + partcode:partner_status_3:igdom + focalcode:partner_status_4:igdom + partcode:partner_status_4:igdom + focalcode:partner_status_5:igdom + partcode:partner_status_5:igdom + focalcode:partner_status_6:igdom + partcode:partner_status_6:igdom + focalcode:partner_status_7:igdom + partcode:partner_status_7:igdom + focalcode:partner_status_8:igdom + partcode:partner_status_8:igdom + focalcode:partner_status_9:igdom + partcode:partner_status_9:igdom + # Estimating impact of focal person's extraversion on communion for each # partner type from both the focal person and partner perspective focalcode:partner_status_2:bfi_e_c + partcode:partner_status_2:bfi_e_c + focalcode:partner_status_3:bfi_e_c + partcode:partner_status_3:bfi_e_c + focalcode:partner_status_4:bfi_e_c + partcode:partner_status_4:bfi_e_c + focalcode:partner_status_5:bfi_e_c + partcode:partner_status_5:bfi_e_c + focalcode:partner_status_6:bfi_e_c + partcode:partner_status_6:bfi_e_c + focalcode:partner_status_7:bfi_e_c + partcode:partner_status_7:bfi_e_c + focalcode:partner_status_8:bfi_e_c + partcode:partner_status_8:bfi_e_c + focalcode:partner_status_9:bfi_e_c + partcode:partner_status_9:bfi_e_c + # Estimating impact of interaction between dominance and extraversion # on communion for each partner type # from both the focal person and partner perspective focalcode:partner_status_2:igdom:bfi_e_c + partcode:partner_status_2:igdom:bfi_e_c + focalcode:partner_status_3:igdom:bfi_e_c + partcode:partner_status_3:igdom:bfi_e_c + focalcode:partner_status_4:igdom:bfi_e_c + partcode:partner_status_4:igdom:bfi_e_c + focalcode:partner_status_5:igdom:bfi_e_c + partcode:partner_status_5:igdom:bfi_e_c + focalcode:partner_status_6:igdom:bfi_e_c + partcode:partner_status_6:igdom:bfi_e_c + focalcode:partner_status_7:igdom:bfi_e_c + partcode:partner_status_7:igdom:bfi_e_c + focalcode:partner_status_8:igdom:bfi_e_c + partcode:partner_status_8:igdom:bfi_e_c + focalcode:partner_status_9:igdom:bfi_e_c + partcode:partner_status_9:igdom:bfi_e_c, # Allow for random intercepts and slopes for focal persons and partners # within each focal person (id) and partner type (partner_status) # The -1 makes sure no intercept is estimated random = ~ -1 + focalcode + partcode + focalcode:igdom + partcode:igdom | id/partner_status, # Set the weights of the variances, # allowing for differences between # focal persons and partners weights = varIdent(form = ~1 | focalcode), # Set correlation structure, in this case, # compound symmetry within each dyad member (focal person/partner_status) # within each focal person corr = corCompSymm(form = ~as.numeric(focalcode) | id/partner_status), # Set optimizer control = ctrl, # Select data set data = amib, # Exclude rows with missing data na.action = na.exclude) #summary(model_3level) # Fixed Effects summary(model_3level)$tTable # Random Effects VarCorr(model_3level) ``` #### Brief Interpretation of the Results Going back to the original research questions outlined at the beginning of the tutorial... * Is perceived partner dominance during an interaction associated with focal persons' or partners' reports of communion? + The association between focal person communion and partner dominance during an interaction is not significant for the reference partner type, but this association varies by partner type. For some dyads, this association is significantly different than the reference category (e.g., partner type 4), whereas for other dyads, this association is not significantly different than the reference category (e.g., partner type 3). + The association between partner communion and partner dominance during an interaction is not significant for the reference partner type, but this association varies by partner type. For some dyads, this association is significantly different than the reference category (e.g., partner type 6), whereas for other dyads, this association is not significantly different than the reference category (e.g., partner type 3). * Is focal person extraversion associated with focal persons' or partners' reports of communion? Furthermore, does focal person extraversion moderate the association between perceptions of communion and dominance during a social interaction? + The association between focal person communion and focal person extraversion is not significant for the reference partner type, but this association varies by partner type. For some dyads, this association is significantly different than the reference category (e.g., partner type 3), whereas for other dyads, this association is not significantly different than the reference category (e.g., partner type 2). + The association between partner communion and focal person extraversion is not significant for the reference partner type, and this association does not significantly differ for any partner type from the reference category. + The moderation of focal person extraversion on the association between communion and focal person dominance during an interaction is not significant for the reference partner type, but this association varies by partner type. For some focal person-partner dyads, this association is significantly different than the reference category (e.g., partner type 3), whereas for other dyads, this association is not significantly different than the reference category for some partner-focal person dyads (e.g., partner type 4). * How much variability in communion (i.e., interpersonal warmth) reported after a social interaction is due to differences (1) within dyads, (2) between dyads within focal persons, and (3) between focal persons? Stated differently, do focal persons view communion with their partners similarly and do partners view communion with their focal person similarly? + The standard deviation around focal person ($\sigma_{v00Fi}$) and partners ($\sigma_{v00Pi}$) reports of communion *between focal persons* is 0.97 and 0.55, respectively. The standard deviation around focal person ($\sigma_{u0Fi}$) and partners ($\sigma_{u0Pi}$) reports of communion *between partners within focal persons* is 1.14 and 0.37, respectively. + Focal persons' and partners' reports of communion *between focal persons* are correlated 0.45, indicating that members of the same dyad often have only somewhat related reports of communion. The correlation between focal persons' and partners' reports of communion *within a focal person* is 0.79, indicating that within a focal person, focal persons in a dyad who reported higher levels of communion than average had partners who also reported higher levels of communion than average. * Are there unique relationship effects between focal persons and partners - i.e., are there components of the relationship not accounted for by how the focal person views all of their partners and how all of the partners view the focal person? + The standard deviation around the focal person residual ($\sigma_{eF}$) is 0.79 and the standard deviation around the partner residual ($\sigma_{eP}$) is 0.91 (0.786 * 1.162), indicating unique relationship effects. # Cautions and Conclusion. While our model took into account the nesting of repeated measures within partner and within focal person, we did not consider time in our model. For example, we could've allowed for auto-correlated errors between time points, as there might have been carry-over from one social interaction to the next. Furthermore, we assume that there was no change in the outcome variable (i.e., communion) over the course of the study - i.e., that there were no reactivity effects to the study. In sum, this tutorial demostrated how to run a two-level OWM model with "cross-sectional" data and extend the model to three-levels for repeated measures data. While we used data from an experience sampling study for this example, we believe this model has a wide variety of applications to various data sources, such as data collected from social media (i.e., when full network information is not available). ----- ### Additional Information We created this tutorial with a system environment and versions of R and packages that might be different from yours. If R reports errors when you attempt to run this tutorial, running the code chunk below and comparing your output and the tutorial posted on the LHAMA website may be helpful. ```{r} session_info(pkgs = c("attached")) ```