David
A. Kenny

January 5, 2017

DyadR: Web Programs

for Dyadic Data Analysis

Currently there are nine apps I have written that are available on the web for dyadic data analysis:

SRM_R (click to run): Social Relations Analysis with Multilevel Modeling (mainly for round-robin data) -- learn more

APIM_MM (click to run): Actor-Partner Interdependence Model with Multilevel Modeling (both distinguishable and indistinguishable dyads) -- learn more

APIMeM (click to run): Actor-Partner Interdependence Mediation Model with Structural Equation Modeling (indistinguishable dyads only) -- learn more

APIMoM (click to run): Actor-Partner Interdependence Moderation Model with Structural Equation Modeling (indistinguishable dyads only) -- learn more

Common_Fate (click to run): Common Fate Model with Indistinguishable Dyads -- learn more

CFA_D (click to run): Confirmatory Factor Analysis with Distinguishable Dyads (single-factor model) -- learn more

CFA_I (click to run): Confirmatory Factor Analysis with Indistinguishable Dyads (single-factor model) -- learn more

Dingy (click to run): Tests of Distinguishability and Nonindependence -- learn more

BetweenO (click to run): Model with Between-Dyads Outcome with Indistinguishable Dyads -- learn more

All of these programs are R programs, but to run them, the user need not download R nor be at all familiar with R. One simply goes to the website (click on the name above) and is prompted about the data and the analysis that is desired. The results of the analysis will appear on the screen (and we hope soon in a downloadable file). These programs were written by David A. Kenny with assistance from Thomas Ledermann, Robert Ackerman, Lara Stas, and Axel Mayer. They all use RStudio's shiny web application framework. I eagerly looking for others to help me in this endeavor. Help is need not only in writing programs, but also in creating documentation.

**T****hese programs are all very much in development and there are likely bugs and errors. Results should be carefully checked!**

**It appears the t****hese programs have difficulty with very large datasets, i.e., those with hundreds of variables. It is advisable to create a smaller dataset before running these programs.**

After the descriptions of the programs, details about the inputs and outputs to the program are presented.

To view a powerpoint, somewhat dated, that describes an application of two of the programs click here.

Other Web-based Shiny Apps

RDDD.htm (click to see these programs): Three programs written to re-structure dyadic data written by David A. Kenny and Thomas Ledermann.

APIMPowerRdis (click to run): A beta version program for power analyses for Actor-Partner Interdependence Model with both indistinguishable and indistinguishable dyads written by Rob Ackerman and David A. Kenny. Please let us know about suggestions and errors.

APIM_SEM: Actor-Partner Interdependence Model estimated by SEM written by Lara Stas of Ghent University.

General Points about These Apps

(Not all the programs are currently written this way but eventually they will all be.) The open screen contain two upper tabs. The one on the left is for the app and the one on the right called "Help and Contact" which contain brief documentation, links to documentation, and an email address for enquires.

The main page contains a set of vertical tabs on the right. The user begins by completing in order the green tabs. At the top always is the green "Select Data" tab which reads a dataset in either SPSS or csv format. One then proceeds down the green tabs completing them in order. After the green tabs is the set of black tabs are black which contain optional information. Once the run is set up, the user hits the blue tab and the blue button which says something like "Begin the Analysis" to run the analysis. Eventually, the results appear on the right side of screen and the user can select text, tables, or computer output. Some apps allow for the display of figures. Finally if one wants to save the output, the user hits the bottom purple tab of "Download Output" that saves the text, tables, computer output, and figures (if there are any) in docx, html, or pdf formats.

The apps are written to be "reactive." That is, after the run is completed and even after the files are downloaded, the user can make changes in the analysis. This feature is especially useful if the user has made an error in that the error can be corrected without having to start all over (e.g., read the dataset, enter the variables, and so on). Though not fully "idiot proofed," the programs do not always crash when the user makes an error; on the right-side of the screen a message should appear telling the user what the problem is.

**SRM_R**

This app conducts an Social Relations Analysis of directed dyadic data and estimates the fixed and random effects for that model. The code that estimates the SRM variances and covariance and creates the necessary codes for that analysis was written by Andrew Knight of Washington University (code at http:\\apknight.or\pdSRM.R). THIS PROGRAM IS EXPERIMENTAL AND ONE SHOULD BE VERY CAUTIOUS ABOUT ITS USE. The estimation algorithm is slow and has difficulty converging with small datasets, datasets with a lot of missing data, and models with small actor or partner variances or large actor-partner correlations. The hope is to improve the algorithm in the near future.

The method involves the Snijders and Kenny (1999. The social relations model for family data: A multilevel approach. *Personal Relationships, 6*, 471-486) approach which creates dummy variables for each actor and partner. The presumption is that the design is round robin, everyone paired with everyone. At least two groups are needed. There can be missing data and in fact the symmetric block design can be estimated with this this app.

The input file must be for each score or a "narrow format." For instance, if there were a round-robin with 5 persons, 20 records would be read, assuming no missing data. On the record is the outcome variable, the actor number, partner number, and group number. Note the actor and partner numbers should refer to the same person. Thus, for person 521 should have both an actor and partner number of "521." The SRM with indistinguishable dyads is discussed in Chapter 8 of *Dyadic Data Analysis,* (Kenny, Kashy, & Cook, 2006). For an webinar (small charge) introduction to the SRM view a webinar and for SRM designs view another webinar.

When SRM_R is opened, one begins by completing in order the first two green tabs on the left. At the top is the "Select Data" tab which reads a dyad dataset in either SPSS or csv format. Next one goes to green "SRM Variables and Terms" tab and gives the name from the dataset of the outcome variable, actor number, partner number, and group number (see above paragraph). SRM_R creates the necessary dummy variables for analysis. One can also change "Actor" to "Perceiver" and "Partner" to "Target" or to whatever names the user desires, e.g., "Receiver and Sender" or "Victim and Aggressor."

The next three black tabs are optional. Then first is the "Predictor Variables" which can be used to pick and name the variables for the analysis. The black "Group Effect" tab allows the user to pick how group effects are modeled. They can be treated as random as is done in TripleR, not included in the model, or fixed as is done in SOREMO which is similar to "group-mean centering" the data. The black "Miscellaneous" tab allows the user to change the alpha.

Once the run is set up, one hits on the top the blue tab labelled "Run Estimation of SRM Now." The results appear on the left side of screen and the user can select text, tables, or computer output. Finally, if one wants to save the output to file (docx, html, or pdf formats), one hits the bottom purple tab on the left labelled "Download Output" and selects the options on the left.

The program displays in text, tables, and computer output. All of the output can be saved in an output in either docx, html, or pdf formats.

This program conducts an Actor-Partner Interdependence analysis of dyadic data. Data must be in a pairwise structure. There must be a numeric dyad identification variable on each record and no more than two records can have the same score on the dyad identification variable. The program is NOT for the analysis of longitudinal dyadic analysis nor does it allow for non-normal outcomes. There is 30 pages of documentation for this program with screenshots and three examples (click here).

For details on the APIM, read Chapter 7 of Dyadic Data Analysis by Kenny, Kashy, and Cook (2006). Also webinars (small charge) on the APIM and APIM Estimated by Multilevel Modeling might be helpful. The defining feature of the APIM is measuring the effect of one mixed variable on another mixed variable: Measured is the effect of a person's own X on his or her Y (the actor effect) and the effect of a person's partner's X on his or her Y (the partner effect).

The program requires at least one predictor mixed variable and one outcome mixed variable. Multiple mixed predictors are allowed. Dyad members can be distinguishable or indistinguishable. Covariates can be included and an analysis of actor-partner interactions for each mixed variable can be estimated using either a product score or a discrepancy score. With distinguishability, pooled actor and partner effects across members are presented, as well as tests of distinguishability.

The errors in the outcome variable are assumed to be normally distributed, but outliers can be removed. The user can specify removing from the analysis standardized residuals values that exceed a certain value. (If am working on better measures of outliers.)

The program can be relatively easily adapted to test for between-dyads moderators of actor and partner effects. Consult the third example of the documentation.

The program displays in text, tables, computer output, and figures. All of the output can be saved in an output in either docx, html, or pdf formats.

The program conducts an APIM mediation analysis using structural equation modeling. It requires three mixed variables in a dyad dataset. One variable, X, is presumed to cause M which in turn is presumed to cause Y. Estimates and tests of direct, indirect, and total effects are estimated and tested. The structural equation modeling program lavaan is used to estimate mediation models. One can use Monte Carlo or traditional non-parametric bootstrap confidence intervals for indirect effects. The structural equation modeling program lavaan is used to estimate mediation models. Brief documentation of the program is available here.

To use APIMeM, one goes through the tabs on the left of the opening screen:

First the green "Select Data" tab is clicked. Either an SPSS or csv (comma separated variables) can be read.

Next the green "Basic Information" tab is clicked. The user names the X, Y, and M variables, as well as the the two members. The defaults can be accepted. The user also decides whether to allow for mean and variances differences between the members.

The green "Variables" tab selects the six variables for the analysis from the dataset. They are chosen from a variable list. (Sometimes one may need to click the "Check to View Variable List" box to be able to see the entire list.

The optional black tab of "Miscellaneous" allows the user to either change alpha or the bootstrapping method. Moreover, the user can set k, the ratio of the partner effect to actor effect, for both the M and Y equations to estimate a simpler model.

To begin the run, the blue "Run Analysis" tab is clicked and then the "Click Here to Begin the APIM Mediation Analysis" button. If one runs a non-parametric bootstrap, it may take several minutes before the results appear on the right.

To download the results, the text, tables, computer output, and figure(s), the user clicks the purple "Download Output" and then chooses the name of the file and its format. The output can be saved in an output in either docx, html, or pdf formats. An example of such pdf output can be viewed here.

The program is currently limited to indistinguishable dyads but the user can allow mean and variances to differ. The user can enter k values (the ratio of partner to actor effects) to test specialized models. For instance, there might be only actor effects from X to M (k_{M} = 0), and the actor and partner effects from M to Y might be equal (k_{Y} = 1).

Currently no covariates are permitted and again dyad members must be indistinguishable. THIS VERY NEW PROGRAM HAS NOT BEEN FULLY TESTED.

**APIMoM**

The program conducts an APIM moderation analysis using SEM. It requires three mixed variables in a dyad dataset. One variable, X, is presumed to cause Y and those effects are presumed to vary (i.e., to moderate) due to M. Simple effects of the effect of X on Y at various levels of M are estimated. The structural equation modeling program lavaan is used to estimate moderation models. Brief documentation of the program is available here.

The program is currently limited to indistinguishable dyads but the user can allow mean and variances to differ. The user can estimate specialized models that place constraints on the four interaction effects. The constraints involve k which is the ratio of partner to actor interaction effects. One approach is to use the k ratios from the X and M main effects to constrain the interaction effects. A second approach is to estimate the k ratios from the interaction effects. For both of these approaches, a test of the constraints is provided, as well as a Monte Carlo estimate of the confidence interval for the k's. The third approach is have the user specify the k values. (See the technical appendix of Garcia et al. for more details on k and tests of moderation.)

Currently no covariates are permitted. THIS VERY NEW PROGRAM HAS NOT BEEN FULLY TESTED.

To use APIMoM, one goes through the tabs on the left of the opening screen:

First the green "Select Data" tab is clicked. Either an SPSS or csv (comma separated variables) can be read.

Next the green "Basic Information" tab is clicked. The user names the X or the predictor, Y of the outcome , and M or the moderator variables, as well as the the two members. The defaults can be accepted. The user also decides whether to allow for mean and variances differences between the members.

The green "Variables" tab selects the six variables for the analysis from the dataset. They are chosen from a variable list. (Sometimes one may need to click the "Check to View Variable List" box to be able to see the entire list.

The optional black tab of "Miscellaneous" allows the user to change alpha. Moreover, the user can set k, the ratio of the partner to actor variables, for both the X and M variables. One can empirically estimate the k's, input a priori k values, or use the main effect k values. (See the technical appendix of Garcia et al. for more details.) A statistical test is used to evaluate whether the k's, however chosen, can explain the pattern of moderation effects. (It is advisable to only use this option if there is detectable interaction in the data.)

To begin the run, the blue "Run Analysis" tab is clicked and then the "Click Here to Begin the APIM Moderation Analysis" button.

To download the results, the text, tables, computer output, and figure(s), the user clicks the purple "Download Output" and then chooses the name of the file and its format. The output can be saved in an output in either docx, html, or pdf formats. An example of such pdf output can be viewed here.

The program is currently limited to indistinguishable dyads but the user can allow mean and variances to differ.

**Common_Fate**

The program conducts a Common Fate Analysis. The measures from the dyad members are presumed to be indicators of a latent variable. One latent variable, X, is presumed to cause the other, Y. Data must be in a dyad data structure. The errors of the X and Y are correlated across members, as assumption which is tested. To be able to estimate this model, the two X and the two Y measures must intercorrelate. A dyad dataset is entered and both X and Y must be mixed variables. Models are estimated using the structural equation modeling program lavaan.

The program is currently limited to indistinguishable dyads which yields a saturated model and so the program does not provide fit indices. The model is estimated by lavann. Currently no covariates are permitted. THIS VERY NEW PROGRAM HAS NOT BEEN FULLY TESTED.

The program displays in the text, tables, computer output, and a figure.

This program tests evaluates a confirmatory factor analysis model using lavaan for both members of dyad with members assumed to be distinguishable. THIS PROGRAM HAS NOT BEEN FULLY TESTED. A minimum of two indicators per member are needed, but three or more is recommended. A dyad dataset is read. Each indicator is assumed to load on a single factor and errors of the same indicator are allowed to be correlated across members. Two models are estimated. One is the configural model in which there are no constraints are made across members, but a single factor model is estimated. The second is a model in which constraints are made on the model. Possible constraints are equal loadings across members, equal intercepts, equal error variances, equal factor means, equal factor variances, equal slopes from the between-dyads variables (if there are any) to the latent variables, and zero correlation of errors. The user can choose a model of complete invariance which treats dyad members as indistinguishable.

The program does not currently allow for within-dyads variables. Again, it is limited to single latent variable and their can be no correlated errors within a latent variable. The app's output consists of computer output, text output, tables, and a figure of the specified model. The hope is to eventually allow the user to choose an alternative model to the specified model.

**CFA_I**

This program tests evaluates a confirmatory factor analysis model using lavaan for both members of dyad. Members are assumed to be indistinguishable. A minimum of two indicators per member are needed, but three or more is recommended. A dyad dataset is read. Each indicator is assumed to load on a single factor and loadings are set equal across the two members. Errors of the same indicator are allowed to be correlated across members.

The program allows for between-dyads variables which are assumed to cause each latent variable. The program does not currently allow for within-dyads variables. Again it is limited to single latent variable and there can be no correlated error across indicators of the same factor. The app's output consists of computer output, text output, tables, and a figure of the specified model.

The user can choose to display the model with or without correlated errors. Alternatively, the user can allow the program to pick the "better" model in terms of fit.

**DINGY**

This program tests the null hypothesis that dyad members are indistinguishable. For instance, if the dataset is for heterosexual couples, the the test is that for each mixed variable the mean and variance are the same for men and women and that correlation between any pair of variables is the same for men and women. In addition the program evaluates whether scores are correlated across members. A dyad dataset must be used as input.

The program allows for between-dyads variables and determines if the correlations of those variables are the same for the two members. The program also allows for a second within-dyads variable, besides the one used to distinguish dyad members and in tests distinguishability constrains the mean of this variable to be half of the sum of the two scores and the correlations with mixed variables to be equal but opposite sign.

The program also tests whether scores across the two members are correlated which can be useful if one wants to claim that scores are independent. Additionally, it gives the I-SAT chi square and degrees of freedom, as well as the chi square and degrees of freedom for null model.

One can download the output, the text, tables, and computer output (the indistinguishable run) to a file. An example file is contained here.

**BETWEENO**

This program estimates models with a between-dyads outcome variables. Dyad members must be indistinguishable. A dyad dataset must be used as input. The outcome must be a between-dyads variables, but must be measured at the interval level of measurement (i.e., no dichotomies).

The program is very preliminary and results should be viewed with caution. The program outputs text, tables, and computer output.

**Data Preparation**

Data must must be in the proper format. APIM_MM requires a pairwise dataset and the other programs require a dyad dataset. You may need to restructure your data before running the program. Both programs accept as input a SPSS "sav" or text file in which the data are separated by commas (a "csv" file). For the csv file variable names are in the first line of the dataset.

For APIM_MM, it is helpful (but not required) to have the first variable in the dataset be the dyad identification variable.

**Entering Parallel Lists of Variables**

Several of these programs expect parallel lists of variables: APIM_MM expects the name of actor and partner variables in the dataset and CFA_I, CFA_D, Dingy, and BetweenO expect two lists of mixed variables, one for each member. (APIMeM and Common_Fate only use the "check" option.) Three different options are offered to enter these parallel lists:

Check: This is perhaps the most familiar option. If chosen, the user is given the entire list of variables in the dataset and the user checks those that are appropriate for the set. The set of variables need not be checked in the same order for the two members, but they must be in the same order in the dataset itself. For instance for CFA_D, if the variables were HSat, WSat, HAge, and WAge (H being husband and W being wife), the user might check (in any order) HSat and HAge for husbands and then WSat and WAge for wives (again in any order). However in the dataset, if HSat comes before HAge, then WSat must also come before WAge. If this is not the case (WAge comes before WSat), this option cannot be used unless one reorders the variables in the datafile.

Lists: For this method, the user needs to type the complete names of both set of variables. So for Husband the list would be "HSat,HAge" and for Wife it would be "WSat,WAge". Order within a list does not matter, but the order needs to be the same across lists, in this case with Sat ahead of Age for both husband and wife. Variables on the list are separated by commas.

Suffix: This is least obvious but often the simplest strategy and because it the simplest, it the default option. Presume that the variables are Sat_W, Age_W,Sat_H, and Age_H. The member is designated by a suffix, H or W. With this method, the user gives a single list without the suffix of "Sat,Age" and then tells the program what suffix is, in this case "H" and "W". Note for APIM_MM the suffix defaults to "A" and "P" but there is no default for CFA_I, CFA_D, or Dingy.

The user is free to decide which option is best. It is always advisable to check in the output that the correct set of variables are chosen. Common_Fate only allows the check option.

**Program Output**

All output is to the screen, but it can be copied. Some programs do allow for the output to outputted to a file.

APIM_MM: Four different tabs are presented: Text, Tables, Computer Output, and Figures. This program does allow output to a file.

Text: If there are any warnings, they are presented first. Then a description of the sample the purpose of the study is given. Then for each mixed predictor, the actor and partner effects, and k ratios. If requested, there a test of the actor-partner interaction.

Tables: The descriptive statistics for the outcome, mixed predictors variables, and covariates are presented. Then a table of intercepts, actor and partner effects, k ratios, and effects of the covariates. For distinguishable dyads overall effect are presented as well as results of tests of distinguishability.

Computer Output: The basic gls run is presented.

Figures: The basic APIM diagram is given for up to eight predictor variables. Although different figures are given, they are all from the same analysis.

APIMeM, APIMoM & SRM_R: The output is very much like APIM_MM except that SRM_R does not provide a figure.

Common_Fate: Four different tabs are presented: Text, Tables, Computer Output, and Figure.

Text: A brief description of the sample the purpose of the study is given. The program looks for problems, such as poor loadings and a failure of discriminant validity.

Tables: There are two tables. Table gives the descriptive statistics. Table 2 provides means and variances from the analysis.

Computer Output: The lavaan output for the model with and without correlated errors is presented.

CFA_D: Four different tabs are presented: Text, Tables, Computer Output, and Figure.

Text: A description of the sample the purpose of the study is given. The fit of the configural and specified model are given. For the specified models, the results are discussed and an analysis of correlated errors and Heywood cases, if there are any, are presented.

Tables: The descriptive statistics for the indicators are presented. Next a table of fit statistics for the configural and specified model are given. Then for both members, a table of loadings, error variances, and intercepts and their p values is presented. If there are between dyads variables, their paths to the latent variables given in a fourth table.

Computer Output: For both the configural and specified models, the user is given the overall summary of the lavaan estimated model, the estimates, and the modification indices.

Figure: The figure shows up to 5 indicators but currently does show means, intercepts, and variances.

CFA_I: Four different tabs are presented: Text, Tables, Computer Output, and Figure. The figure shows up to 5 indicators.

Text: A description of the sample the purpose of the study is given. The the results of the test distinguishability, the correlation between the latent variables, and fit of various models are given. Results of the analysis of correlated errors and Heywood cases, if there are any, are presented. The user can choose to use the model with and without correlated errors across the two members.

Tables: The descriptive statistics for the indicators are presented. Then a table of loadings, error variances, and intercepts and their p values are given. If there are between dyads variables, their paths to the latent variable given in a third table.

Computer Output: The summary of lavaan model of the test of distinguishability is given. Then for the CFA, the overall summary, the estimates, and the modification indices are given for both the model with and without correlated errors.

Figure: The figure shows the loadings, standardized and unstandardized, as well as the correlated errors if there any.

Dingy: Three different tabs are presented: Text, Tables, and Computer Output. This program does allow output to a file.

Text: A description of the sample and the purpose of the analysis is given. Then the results of models which force means, variances, and correlations equal are presented. The best fitting model if there is one is suggested. Also given is the ISat chi square, df, and null model which can be useful for dyadic SEM analyses that treat dyad members as indistinguishable. If the option is chosen, an overall test of nonindependence is given, assuming both distinguishability and indistinguishability.

Tables: Up to four tables are available: Descriptive statistics for the mixed variables, Model tests, Comparisons between models, and Tests of nonindependence.

Computer Output: The lavaan output from the model that test for complete distinguishability. You may need to adjust the screen size for best viewing.

BetweenO: Three different tabs are presented: Text, Tables, and Computer Output

Text: A description of the sample and the purpose of the analysis is given. Then the results from three models: one with interactions (product), one without interactions, and one that trims out non-significant interactions.

Tables: Three table are outputted, one for each model.

Computer Output: The regression output, using the R function "lm," for each model is outputted.

**Program Defaults**

Alpha is assumed to equal of .05 in all programs, but the user can override that default. For APIM_MM, the program defaults that the first variable in the dataset is the dyad identification variable, the second variable is the outcome variable, and that the third variable is distinguishing variable (if there is one).

**Error Checks**

All the programs have error checks. Nonetheless, it is still possible to crash the program without it reporting an error. Suggestions for error checks are appreciated.

**Variable Names**

The user need not name the variables, but to make interpretation easier, it is strongly suggested that the user provide appropriate names. Some of the programs in the text give the names of the variables in the dataset that are used in the analysis.