## Hypothesis Testing in Healthcare: Drug Safety

A pharmaceutical company GlobalXYZ has just completed a randomized controlled drug trial. To promote transparency and reproducibility of the drug's outcome, they (GlobalXYZ) have presented the dataset to your organization, a non-profit that focuses primarily on drug safety.

The dataset provided contained five adverse effects, demographic data, vital signs, etc. Your organization is primarily interested in the drug's adverse reactions. It wants to know if the adverse reactions, if any, are of significant proportions. It has asked you to explore and answer some questions from the data.

The dataset `drug_safety.csv`

was obtained from Hbiostat courtesy of the Vanderbilt University Department of Biostatistics. It contained five adverse effects: headache, abdominal pain, dyspepsia, upper respiratory infection, chronic obstructive airway disease (COAD), demographic data, vital signs, lab measures, etc. The ratio of drug observations to placebo observations is 2 to 1.

For this project, the dataset has been modified to reflect the presence and absence of adverse effects `adverse_effects`

and the number of adverse effects in a single individual `num_effects`

.

The columns in the modified dataset are:

Column | Description |
---|---|

`sex` | The gender of the individual |

`age` | The age of the individual |

`week` | The week of the drug testing |

`trx` | The treatment (Drug) and control (Placebo) groups |

`wbc` | The count of white blood cells |

`rbc` | The count of red blood cells |

`adverse_effects` | The presence of at least a single adverse effect |

`num_effects` | The number of adverse effects experienced by a single individual |

The original dataset can be found here

```
# Import packages
import numpy as np
import pandas as pd
from scipy.stats import norm
from statsmodels.stats.proportion import proportions_ztest
import pingouin
import seaborn as sns
import matplotlib.pyplot as plt
# Load the dataset
drug_safety = pd.read_csv("drug_safety.csv")
```

```
display(drug_safety)
display(drug_safety.info())
```

```
plot_num_eff = sns.countplot(data=drug_safety,x='num_effects',hue='trx')
plt.xlabel("Number of Adverse Effects")
plt.title("Distribution of the Number of Adverse Effects between the Groups")
```

```
trx_by_adverse_effects = drug_safety.groupby('trx')['adverse_effects'].value_counts()
yeses = [trx_by_adverse_effects[('Drug','Yes')], trx_by_adverse_effects[('Placebo','Yes')]]
nobs = drug_safety.groupby('trx')['num_effects'].count()
two_samp_z_stat, two_samp_z_p_value = proportions_ztest(yeses,nobs,alternative='two-sided')
two_samp_z_stat = round(two_samp_z_stat,3)
two_samp_z_p_value = round(two_samp_z_p_value,3)
print('z-stat:',two_samp_z_stat,'\np-value:', two_samp_z_p_value)
```

```
expected, observed, stats = pingouin.chi2_independence(data=drug_safety,
x='num_effects',y='trx')
pearson_num_effect_trx = stats[stats['test'] == 'pearson'].round(3)
print(pearson_num_effect_trx)
```

`plot_age = sns.kdeplot(data=drug_safety,x='age',hue='trx')`

```
drugs = drug_safety.loc[drug_safety['trx']=='Drug','age']
placebo = drug_safety.loc[drug_safety['trx']=='Placebo','age']
two_ind_ttest_results = pingouin.ttest(drugs,placebo,paired=False).round(3)
display(two_ind_ttest_results)
two_ind_samp_results = pingouin.mwu(drugs,placebo).round(3)
display(two_ind_samp_results)
```