Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



4 Commits

Repository files navigation

Perspective-taking to Reduce Affective Polarization on Social Media

Martin Saveski*, Nabeel Gillani*, Ann Yuan, Prashanth Vijayaraghavan, and Deb Roy.

This repository contains supplementary material and code for replicating the analysis in the paper "Perspective-taking to Reduce Affective Polarization on Social Media" published in the proceedings of International AAAI Conference on Web and Social Media (ICWSM '22).

Supplementary material

The supplementary materials can be found in supplementary-material.pdf.

It contains the following:

  • A description and justification of the mixed-effects linear models used for the main analyses,
  • Checks for the robustness of results across different model specifications,
  • Checks for covariate balance to ensure randomized treatment assignment worked as intended,
  • An analysis of results accounting for selective attrition in post-survey completions.

Code guide

  • models_simple.R: Fits lmer and brms models, using the two treatments (feed=opposite and prompt=empathic) with and without an interaction term.
  • models_w_covs.R: Similar as above but the models also include interactions with each of the treatments and the covariates (days_active, num_statuses, num_favorites, num_followers, num_friends).
  • plots.R: Generates Figures 2 (main effects) and 3 (interaction effects) of the paper based on the brms models with covariates as fitted in models_w_covs.R.
  • robustness_plot.R: Generates a robustness plot showing the coefficients of the treatments across different models specifications (shown in Appendix).
  • robustness_tables.R: Generates tables for the different models (shown in Appendix).
  • balance_reg.R: Runs covariate balance checks for both treatments, regressing the treatment on the covariates (detailed results shown in Appendix).
  • balance_ri.R: Runs covariate balance checks using randomization inference (detailed results shown in Appendix).
  • attrition.R: Tests the effects of attrition using monotonicity bounds for users who were shown the survey but did not complete some questions (detailed results shown in Appendix).
  • load_data.R: Loads and joins the key data files. Used in most of the other analyses scripts.
  • utils.R: Contains a function for generating tables from brms models.


Feel free to email us (msaveski [AT] / ngillani [AT] to request an anonymized version of the data.


  title={Perspective-taking to Reduce Affective Polarization on Social Media},
  author={Saveski, Martin and Gillani, Nabeel and Yuan, Ann and Vijayaraghavan, Prashanth and Roy, Deb},
  booktitle={Proceedings of the International AAAI Conference on Web and Social Media},


This code is licensed under the MIT license found in the LICENSE file.


Replication code for "Perspective-taking to Reduce Affective Polarization on Social Media" (ICWSM'22)







No releases published


No packages published