The files contained in this project were used for the analyses in the article "Does Intra-household Contagion Cause an Increase in Prescription Opioid Use?", published in the American Sociological Review. The data used in the paper (Massachussets All Payer Claims Database [MA APCD] R4.0) were provided by the Center for Health Information and Analysis (CHIA). Due to legal restrictions, we are not allowed to share the data in the APCD. This means that the full set of analyses cannot be reproduced without securing access to the data from CHIA first. We do, however, include the code we used to set up the raw data so after securing access to the data, the exact estimates in the paper can be obtained. The code files contain both SQL and R-scripts and they are ordered by numbers and letters. The order is important because subsequent files rely on data created by previous files. In addition to indicating order, file numbers bin together related files. Files with the same number and letter can be run in any order. Below is a short description for each set of files: - 0 scripts -- These files set up the medical claims, the pharmacy claims, the member eligibility file and the NPPES data (which contain provider specialty data). - 1 -- These files sample the ED physicians and they transform CHIA's provider specific linkage IDs to NPIs. - 2 -- These files select and subset the main medical claims data and they generate many of the variables. - 3 -- These files create the outcome variables (opioid use). - 4 -- These files generate other control variables including benzodiazepine consumption and the elixhauser index. - 5 -- These files work in the family structures, the IV (physician specific opioid prescription rate), and start sampling (plus describing the sampling). - 6 -- These files run all the main regressions. - 7 -- These files run post-hoc analyses.