RiskyBehavior

Data from a randomized trial targeting couples at high risk of HIV infection. The intervention provided counseling sessions regarding practices that could reduce their likelihood of contracting HIV. Couples were randomized either to a control group, a group in which just the woman participated, or a group in which both members of the couple participated. One of the outcomes examined after three months was “number of unprotected sex acts.”. See Chapter 15 in Regression and Other Stories.

Reference: El-Bassel, N., Witte, S. S., Gilbert, L., Wu, E., Chang, M., Hill, J., and Steinglass, P. (2003). The efficacy of a relationship-based HIV/STD prevention program for heterosexual couples. American journal of public health, 93, 963–969.

Source: RiskyBehavior/risky.Rmd.

The Python version keeps data handling explicit and uses lapylace for Stan-backed generalized linear models, so the statistical model can be read from a formula rather than from handwritten Stan.

from pathlib import Path
import sys
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import lapylace as lp

sys.path.append(str(Path.cwd().parent / 'python'))
from data import ros_path

Data

risky = pd.read_csv(ros_path('RiskyBehavior/data', 'risky.csv'))
risky.head()
sex couples women_alone bs_hiv bupacts fupacts
0 woman 0 1 negative 7 32.0
1 woman 0 0 negative 2 5.0
2 woman 0 0 positive 0 15.0
3 woman 0 0 negative 24 9.0
4 woman 1 0 negative 2 2.0

Notes

  • Source computation blocks represented: 2.
  • Data paths are expressed through the shared ros_path() helper.
  • Formula-based Bayesian regressions are routed through lapylace.stan_glm().
  • Plotting and simulation work uses NumPy, pandas, matplotlib idioms.