What to do when the parallel trends assumption is violated in a difference-in-differences framework?

Background

Rather than provide a tutorial, I’m going to introduce an interesting topic for this month’s blog.

In difference-in-differences (DID) estimation, one of the key assumptions is this idea of parallel trends. More specifically, the trends between the treatment group and control group should be parallel prior the period when the intervention occurs (“index period”). When the parallel trends assumption holds, then we can make causal claims that any change in the treatment group after the index period is due to the intervention and not to the secular effects of time.

The figure below illustrates the parallel trends between the treatment and control groups prior to the index period.

However, where the parallel trends assumption does not hold, then any changes observed in the treatment group is really difficult to attribute to the intervention that occurred at the index period.

When this occurs does it mean that your DID estimation is wrong?

Maybe.

But how wrong?

That’s what Ashesh Rambachan and Jonathan Roth set out to figure out with their recent paper, “A More Credible Approach to Parallel Trends.”[1]  

“Honest” DID

Initially called the “honest” DID, Rambachan and Roth provided a way for us to estimate the magnitude of impact that violation of the parallel trends would have on our DID estimate.[1] As I have interpreted their paper, they wanted to provide a way to show how “honest” the DID estimate is when there is a violation in parallel trends.

Their paper provides an innovative approach to relax the parallel trends assumption and seeing how this impacts the DID estimations. They do this by setting the post-treatment difference based on the pre-treatment differences. The pre-treatment differences are extrapolated into the post-treatment period to see how much the differences would have been observed.

They argue that you can use an interval of differences in trends to see when the pre-treatment violations lead to post-treatment violations of the parallel trends.

Current status

I’m still going through this myself, so I plan to provide a follow-up on this. Right now, this is pretty exciting stuff, and I’m looking forward to seeing how I can apply this to some work that I’m currently doing where we have a violation in the parallel trends prior to the index period.

So stay tuned for more updates.

 

References

Here is the citation for their paper on “honest” DID:

1. Rambachan A, Roth J. A More Credible Approach to Parallel Trends. Rev Econ Stud. 2023;90(5):2555-2591. doi:10.1093/restud/rdad018

Here is the GitHub site for the “honest” DID packages in R and Stata:

https://github.com/asheshrambachan/HonestDiD

 

Here is Jonathan Roth’s page with more on DID:

https://www.jonathandroth.com/did-resources/

 

Performing inflation adjustment with price indices in economic analysis

Introduction

Generally, when I use cost data from the past, I tend to perform some kind of inflation adjustment. That’s because the value of $1 is not the same today as it was a year ago. Therefore, we need an approach to adjust the value of past costs into today’s terms. We think of past costs as nominal (or unadjusted) costs. To express these costs into today’s value, we need to perform an inflation adjustment.

Recently, I was working with my students, and they had pulled cost data from the Agency for Healthcare Research and Quality (AHRQ) Medical Expenditure Panel Survey (MEPS). MEPS provides healthcare expenditure data on a number of categories (e.g., total, outpatient, inpatient, and pharmacy). Once can download and use the MEPS data to study the trends in healthcare costs over time. However, the past healthcare costs are not adjusted for time and will require some application of a price index.

Depending on your needs, MEPS provides recommendations on what kind of price index to use. The most common price index is the Consumer Price Index (CPI). The United States (US) Bureau of Labor and Statistics (BLS) provides data on the CPI, which can be accessed on their website (link).  According to the BLS site, “The Consumer Price Index (CPI) is a measure of the average change over time in the prices paid by urban consumers for a market basket of consumer goods and services.”

The BLS also has a CPI calculator where you can enter the dollar amount at a specific month and year to estimate its inflation adjusted amount.

However, if you want to use the actual CPI data, you can download these from the BLS website (link).

 

Consumer Price Index Example

Here is a short tutorial on how to download the CPI data and perform an inflation adjustment.

Step 1. Download the CPI data from the BLS website.

Navigate to the BLS website (link). Click on “Tables.” This will bring you to the BLS CPI database page.

You see links to archived CPI releases. There is a lot of data on this site. To make things easier, we’ll focus on the annual CPI numbers.

Step 2. Select the Historical CPI-U, which contains all the annual CPI from its inception in the United States. This will be helpful in converting any dollar year into the inflation-adjusted dollar.

Note: We use the CPI-U because it includes all urban consumers, which represents over 90% of the total US population. There are other types of CPI calculations that you can use based on your needs. I encourage you to explore these.

Once you have downloaded the Historical CPI-U file. Open it and review the columns. The column that we are interested in is the “Annual” column, which contains the annual CPI for that year.  

Step 3: Let’s suppose that we were interested in performing an inflation adjustment for $100 in 2028 to 2025 value. We take the CPI for 2025, which is 321.943 and divide this by the CPI from 2008, which is 215.303.

Step 4: Once we have the inflation adjustment ratio, we can multiply this by $100 from 2008 to get the 2025 inflation-adjusted value.

Therefore, $100 in 2008 is worth $149.53 in 2025.

Personal Consumption Expenditures Example

But what if you wanted to use the Personal Consumption Expenditures (PCE) Price Index instead of CPI? MEPS recommends we use the PCE Price Index when we pool data from multiple years or evaluate trends across multiple years.

The PCE Price Index is available from the US Department of Commerce Bureau of Economic Analysis (BEA)website (link).

According to the Bureau of Economic Analysis, the PCE Price Index measures the “prices that people living in the United States, or those buying on their behalf, pay for goods and services.”

To get the PCE Price Index, you will need to do the following:

Step 1: Go to the BEA’s PCE Price Index website (link). Select Tools > Interactive Data. From there Select “Gross Domestic Product / Personal Income.” This will take you to another page where you can finally select “Interactive Data Tables.”

Step 2: In the interaction data tables page, Select “Section 2 – Personal Income and Outlays.” This will expand the field. Scroll down and Select “Table 2.5.4. Price Indexes for Personal Consumption Expenditures by Function (A).” The (A) indicates “Annual.” This opens the Interaction table where you can Modify the date range. By default, it will give you the most recent year and the last several years.

Step 3: Use the “Modify” option to change the time range.

Change the “First Year” to “2008 A,” This will expand the PCE Price Index time year from 2008 to 2024.

Notice that we don’t have 2025 on this Interactive table. The 2025 annual PCE Price Index is available, but you will have to do a little more digging.

Step 4: Go back to the National Income and Products Account and Select Table 2.8.4. Price Indexes for Personal Consumption Expenditures by Major Type of Product, Monthly (M).

Copy the PCE Price Index for the months of January all the way to December for 2025.

Paste this into Excel and average the PCE Price Index for all twelve months. This will give you the PCE Price Index for 2025.

Step 5: Now that we have the PCE Price Index for 2025, we can return to our previous example and perform an inflation adjustment of $100 from 2008 to its inflation-adjustment 2025 value.
We take the PCE Price Index for 2025, which is 126.919 and divide this by the PCE Price Index from 2008, which is 89.197.

Step 6: Once we have the inflation adjustment ratio, we can multiply this by $100 from 2008 to get the 2025 inflation-adjusted value.

Therefore, $100 in 2008 is worth $142.29 in 2025.

 

Conclusions

Adjusting past costs to current value is an important part of performing economic analyses, particularly when we are looking at the trends. If we don’t make this adjustment, our analysis will be incorrect and will generate the wrong conclusions. In this article, I reviewed two types of price indices, but there are others. MEPS provides a nice guideline on which ones to use on their website (link), and I encourage you to explore these.

 

Disclosures

This is a work in progress and subject to future changes.

This is for educational purposes only.

 

Impact of X-waiver policies on buprenorphine prescribing for opioid use disorder in the United States, 2019-2025

This is part of a working paper on the impact of X-waiver policy changes on buprenorphine prescribing for treatment of opioid use disorder in the United States. I presented our preliminary findings at the Society for Medical Decision Making (SMDM) Annual Meeting in Oslo, Norway on 29 June 2026.

(Updates are expected)


Objectives

The primary objective evaluated the impact of X-waiver policies on the number and period prevalence of individuals with OUD who were prescribed buprenorphine from 2019 to 2025.

The secondary objective evaluated the impact of X-waiver policies on buprenorphine prescribing across social vulnerability index (SVI) quantiles from 2019 to 2025.

 

Methods

Study design

An interrupted time series analysis (ITSA) was used to evaluate the trends and level changes associated with X-waiver policies on buprenorphine prescribing for adults with opioid use disorder (OUD) in the United States (US). Two X-waiver policy interventions were evaluated with the X-waiver relaxation policy occurring in April 2021 (time = 29) and the X-waiver elimination policy occurring in January 2023 (time = 50). The period before the first X-waiver policy change is labelled “Segment 1,” the period after the first X-waiver policy and before the second X-waiver policy is labelled “Segment 2,” and the period after the second X-waiver policy is labelled “Segment 3.” We used 30-day time intervals instead of monthly time intervals to establish a consistent replicable dataset. Consequently, our study’s time horizon ended on 25 December 2025. The online supplement provides a visualization of the ITSA framework.

 

Sample and Social Vulnerability Index

Adults (>=18 years old) with a diagnosis of opioid use disorder were included for analysis. Individuals with opioid use disorder were categorized according to their social vulnerability index (SVI) quantiles. SVI index was based on data from the Centers for Disease Control and Prevention (CDC).[1,2] Epic Cosmos assigned SVI score to individuals using Federal Information Processing Standards (FIPS) codes. Individuals are considered least socially vulnerable if they are in the first quantile (SVI =1) and most socially vulnerable if they are in the fourth quantile (SVI = 4).

 

Data source

Epic Cosmos was used to gather data on the number of buprenorphine prescriptions prescribed to unique individuals with opioid use disorder between 01 January 2019 to 25 December 2025. Epic Cosmos is a collaborative network of health systems that aggregates data from institutions that use the Epic Electronic Health Record System for approximately more than 300 million unique individuals.[3,4] Opioid use disorder diagnosis was determined based on ICD10 codes.

 

Outcome variable

Buprenorphine prescriptions dispensed were determined using Epic Cosmos. Dispensed buprenorphine prescriptions are based on Epic’s Medication (ERX) master file, which is constructed using from third-party medication databases such as First DataBank and Medi-Span in the United States.

We opted to measure the number of individuals with OUD diagnosis prescribed buprenorphine and the period prevalence of individuals with OUD prescribed buprenorphine per 1000 persons due to the changing number of individuals with OUD in the US population.

The period prevalence (number of individuals with OUD prescribed buprenorphine per 1000 persons) was estimated as:

 

Statistical analysis

Descriptive analyses on the number of individuals with OUD prescribed buprenorphine and the number of individuals with a diagnosis of OUD was performed from 2019 to 2025.

In the primary analyses, two ITSAs were constructed using (1) the number of individuals with OUD who were prescribed buprenorphine and (2) period prevalence of individuals with OUD who were prescribe buprenorphine as outcomes.

For the first outcome, a linear mixed effects model with a random intercept was used to evaluate the number of buprenorphine prescriptions prescribed during the study time horizon and their associations with X-waiver policies changes.

For the second outcome, a negative binomial model was used to evaluate the period prevalence of buprenorphine prescriptions prescribed during the study time horizon and their associations with X-waiver policies changes. We used the log of the population size of adults with opioid use disorder as the offset term in the model.

For both models, the mean monthly changes (slopes) for each period segments and the level changes at each period when the X-waiver policies were implemented were estimated. For the primary analyses, differences between slopes between each segment were estimated. Robust standard errors were estimated for all measures except for differences in slopes, which were estimated using non-parametric bootstrap with 1000 replications. Stata does not allow for estimation of standard errors in terms of the period prevalence; hence, bootstrap methods were used. Results are presented as the mean change along with their corresponding 95% confidence intervals (CI).

For the secondary analyses, social vulnerability index (SVI) quantiles were used as the grouping variable to evaluate the impact of X-waiver policy changes on buprenorphine prescribing among adults with opioid use disorder. Interaction terms between the SVI quantiles (grouping variable) and the period when the X-waiver policy was relaxed (time = 29) and eliminated (time = 50) were used to compare the differences in buprenorphine prescribing between individuals in different SVI quantiles. Similar approaches were applied to the SVI quantiles analyses as in the primary analyses.

Statistical significance was defined as a two-tailed alpha < 0.05. All analyses were performed using Stata SE 18 (StataCorp, LLC, College Station, TX).

 

Results

By December 2025, 1,213,349 individuals had a diagnosis of OUD compared to 444,739 in January 2019—a 173% relative increase. The total number of individuals with OUD who received buprenorphine increased from 71,508 in January 2019 to 319,371 in December 2025—a 347% relative increase.

 

Primary analyses

In the primary analyses, there was a significant increase in the number of individuals with OUD who received buprenorphine from Segment 1 to Segment 2 and from Segment 2 to Segment 3 (Table 1, Figure 1A). Between Segment 1 to Segment 2, the number of individuals with OUD who received buprenorphine increased by 246 prescriptions (95% CI: 135, 357). Between Segment 2 to Segment 3, the number of individuals with OUD who received buprenorphine increased by 515 prescriptions (95% CI: 413, 617). Immediately after the X-waiver relaxation policy was implemented, there was a significant increase in the number of individuals with OUD who received buprenorphine (+1612; 95% CI: 133, 3091). Similarly, immediately after the X-waiver elimination policy was implemented, there was a significant increase in the number of individuals with OUD who received buprenorphine (+1454; 95% CI: 13, 2894).

Conversely, there was a significant decrease in the period prevalence of individuals with OUD who received buprenorphine from Segment 1 to Segment 2 and from Segment 2 to Segment 3 (Table 1, Figure 1B). Between Segment 1 to Segment 2, the number of individuals with OUD who received buprenorphine decreased by 1.60 prescriptions per 1000 persons (95% CI: (-1.68, -1.51). Between Segment 2 to Segment 3, the number of individuals with OUD who received buprenorphine decreased by 0.27 prescriptions per 1000 persons (95% CI: -0.34, -0.20). Immediately after the X-waiver relaxation policy was implemented, there was a significant decrease in the period prevalence of individuals with OUD who received buprenorphine (-2.88; 95% CI: -4.34, -1.42). However, immediately after the X-waiver elimination policy was implemented, there was a significant increase in the period prevalence of individuals with OUD who received buprenorphine (+1.21; 95% CI: 0.27, 2.15).

 

Secondary analyses

In the secondary analyses, the number of individuals with buprenorphine was greater among those with greater social vulnerability compared to those with lesser social vulnerability (Table 2, Figures 2A and 2B). Significant increases in the number of individuals with OUD who received buprenorphine were observed for all SVI quantiles (Figure 2A). Among the least vulnerable (SVI = 1) the number of individuals with buprenorphine increased from a rate of 307 per month (in Segment 1) to a rate of 361 per month (in Segment 2), a relative increase of 17.6% [(361 – 307) / 307]. Similarly, among the most vulnerable (SVI = 4), the number of individuals with buprenorphine increased from a rate of 486 per month (in Segment 1) to 526 per month (in Segment 2), a relative increase 8.3% [(526 – 486) / 486]. This pattern was observed when individuals transitioned from Segment 2 to Segment 3 (Table 2); there was a 7.8% relative increase [(389 - 361) / 361] among the least vulnerable (SVI = 1), and a 41.3% relative increase [(743 - 526) / 526] among the most vulnerable (SVI = 4).

 

However, when reporting on period prevalence outcomes, the trends were mostly reversed. Significant decreases in the period prevalence of individuals with OUD who received buprenorphine were observed for most SVI quantiles (Figure 2B). Among the least vulnerable (SVI = 1) the period prevalence of individuals with buprenorphine decreased from a monthly rate of 3.62 per 1000 persons (in Segment 1) to a monthly rate of 1.63 per 1000 persons (in Segment 2), a relative decrease of 55.0% [(1.63 – 3.62) / 3.62]. Similarly, among the most vulnerable (SVI = 4), the period prevalence of individuals with buprenorphine decreased from a monthly rate of 4.01 per 1000 persons (in Segment 1) to 1.44 per 1000 persons (in Segment 2), a relative decrease 64.1% [(1.47 – 4.01) / 4.01]. Between Segment 2 and Segment 3, there was a 41.7% relative decrease in the monthly rate among the least vulnerable individuals (SVI = 1) with OUD (Table 2). Individuals in SVI quantiles 2 and 3 followed similar patterns as individuals in SVI quantile 1. However, among the most vulnerable (SVI = 4), there was a 18.4% relative increase [(1.74 – 1.47) / 1.47] in the monthly rate when transitioning from Segment 2 to Segment 3.

 

Discussion

The impact of the X-waiver policies has had mixed effects on buprenorphine prescribing. When reporting the impact of these X-waiver policies on the number of individuals with OUD who were prescribed buprenorphine, the trends indicated that there was a significant increase. However, when reporting on the period prevalence of individuals with OUD who were prescribed buprenorphine, the trends were mostly negative. These apparent differences can be explained by the type of outcomes used in our analysis.

Period prevalence takes into consideration the population at risk, which in our case were those individuals with OUD; whereas simply relying on the number of individuals with OUD who were prescribed buprenorphine does not capture this changing trend in the population at risk. In our descriptive analysis, we reported that the population of individuals with OUD increased at a greater rate than individuals who were prescribed buprenorphine, which has had an impact the observed positive trends of the numerator. Although the number of individuals with OUD who were prescribed buprenorphine increased, this pattern reverses when the total population at risk was incorporated. Decision makers can use both outcomes to influence policy; however, caution should be exercised when the denominator undergoes substantial changes across time.

Additionally, the opioid crisis has resulted in a large number of new OUD diagnosis, which has overwhelmed the capacity of public health efforts to improve access to essential treatments such as buprenorphine.[5–7] These findings highlight the challenges in meeting the high demand of the OUD population for buprenorphine. As long as the OUD population continues to increase, any positive trends in the number of individuals with OUD who are prescribed buprenorphine will be attenuated. Therefore, it is essential that decision makers use an outcome measure that captures both the change in the number of individuals with OUD who were prescribed buprenorphine and the prevalence individuals with OUD who were prescribed buprenorphine for resource planning and understanding the burden of the disease.

In our analyses, we identified certain patterns in buprenorphine prescribing across SVI quantiles. When viewing the number of individuals with OUD who were prescribed buprenorphine, we observed that those in the lowest social vulnerability index (SVI = 1) has the least amount of buprenorphine compared to those in the highest social vulnerability index (SVI = 4). This was counter to our expectations that individuals in a socially vulnerable environment would have lower opportunities for access to medication treatment for opioid use disorder. Yang and colleagues reported that among older adults (>= 65 years), the number of individuals with OUD is greater in counties with high social vulnerability compared to counties with low social vulnerability.[8] Similarly, Joudrey and colleagues reported that counties with greater social vulnerability had limited access to buprenorphine and other medications for OUD treatment.[9] Lastly, other community-level factors such as high provider density and high mental health service availability interact with SVI to improve buprenorphine retention.[10]

Previous studies are mixed when it comes to the impact of the X-waiver policies on buprenorphine prescribing. Stone and colleagues reported that the X-waiver elimination was associated with increased clinicians prescribing buprenorphine but an overall decrease in patients receiving buprenorphine.[11] Similarly, Chua, Bohnert, and Nguyen reported a significant increase in the number of buprenorphine prescribers, but a limited impact on buprenorphine prescriptions.[12] Conversely, Tuan and colleagues reported that elimination of the X-waiver was associated with a 14% increase in the odds of buprenorphine initiation after a new OUD diagnosis.[13] We speculate that the differences in these findings may depend on the type of patients receiving buprenorphine and the specialties of their providers. For instance, Stone and colleagues reported that there was an overall decrease in buprenorphine prescribing by all physician groups after the X-waiver except for behavioral health physicians.[11]

 

Limitations

This study has several limitations. First, the number and cumulative prevalence of individuals with OUD who were prescribed buprenorphine were based on a single electronic health record system that may not be representative of the whole US population. Epic Cosmos only captures data on patients who engaged with healthcare systems that use its Epic Electronic Health Record System. Thus, it does not capture other patients outside this platform, and any findings may not be reflective of the general US population. Second, the data are an aggregate of individuals with OUD and do not include patient-level characteristics. Consequently, we were unable to control for patient-level characteristics in our models, which introduces potential confounding issues. Additionally, since the data are aggregated for the US, ecological fallacy could be present.[14,15] To address this, we grouped the data into SVI quantiles to observe any difference in community-level vulnerabilities as a secondary aim. However, this strategy only allows us to stratify the findings across SVI quantiles and does not adjust for potential confounding. Lastly, OUD diagnosis is challenging to diagnose and could lead to misclassification bias. Epic Cosmos used ICD10 diagnostic codes to capture OUD diagnosis, which has been reported to be insufficient in properly identifying OUD and could result in potential misclassification.[16]

 

Conclusions

Overall, the X-waiver policies appeared to have the intended effect of increasing buprenorphine prescribing in terms of raw numbers, but the change in the period prevalence of individuals with OUD who received buprenorphine was not a great in the periods after the X-waiver policies compared to before. Selection of outcomes can influence interpretations of findings; thus, it is recommended that presentation of findings include all outcomes.  

 

References

1.         Centers for Disease Control and Prevention and Agency for Toxic Substances and Disease Registry. CDC/ATSDR Social Vulnerability Index (CDC/ATSDR SVI). June 14, 2024. Accessed October 11, 2024. https://www.atsdr.cdc.gov/placeandhealth/svi/index.html

2.         Flanagan BE, Gregory EW, Hallisey EJ, Heitgerd JL, Lewis B. A social vulnerability index for disaster management. Journal of Homeland Security and Emergency Management. 2011;8(1). doi:10.2202/1547-7355.1792

3.         Tarabichi Y, Frees A, Honeywell S, et al. The Cosmos Collaborative: A Vendor-Facilitated Electronic Health Record Data Aggregation Platform. ACI open. 2021;5(1):e36-e46. doi:10.1055/s-0041-1731004

4.         Noel A, Bartelt K. Cosmos: Real-World Data Powered by the Healthcare Community. Journal of the Society for Clinical Data Management. 2023;3(S1). doi:10.47912/jscdm.246

5.         Lee YK, Gold MS, Blum K, Thanos PK, Hanna C, Fuehrlein BS. Opioid use disorder: current trends and potential treatments. Front Public Health. 2024;11:1274719. doi:10.3389/fpubh.2023.1274719

6.         Wang S, He Y, Huang Y. Global, regional, and national trends and burden of opioid use disorder in individuals aged 15 years and above: 1990 to 2021 and projections to 2040. Epidemiol Psychiatr Sci. 2025;34:e32. doi:10.1017/S2045796025100085

7.         Bergeria CL, Strain EC. Opioid Use Disorder: Pernicious and Persistent. Am J Psychiatry. 2022;179(10):708-714. doi:10.1176/appi.ajp.20220699

8.         Yang TC, Kim S, Matthews SA, Shoff C. Social vulnerability and the prevalence of opioid use disorder among older Medicare beneficiaries in US counties. J Gerontol B Psychol Sci Soc Sci. Published online October 3, 2023:gbad146. doi:10.1093/geronb/gbad146

9.         Joudrey PJ, Kolak M, Lin Q, Paykin S, Anguiano V Jr, Wang EA. Assessment of community-level vulnerability and access to medications for opioid use disorder. JAMA Network Open. 2022;5(4):e227028. doi:10.1001/jamanetworkopen.2022.7028

10.       Jaimes-Buitron PA, Zhang K, Gong Y, Guo Y, Bauer C, Vivas-Valencia C. Community-level factors influencing the duration of buprenorphine treatment in individuals with opioid use disorder: a cohort study using US longitudinal claims data. bmjph. 2025;3(2). doi:10.1136/bmjph-2025-003767

11.       Stone EM, Xie F, Miles J, Samples H, Olfson M, Crystal S. Buprenorphine Dispensation After X-Waiver Elimination by Clinician Specialty. American Journal of Preventive Medicine. 2025;69(5):108055. doi:10.1016/j.amepre.2025.108055

12.       Chua KP, Bicket MC, Bohnert ASB, Conti RM, Lagisetty P, Nguyen TD. Buprenorphine Dispensing after Elimination of the Waiver Requirement. New England Journal of Medicine. 2024;390(16):1530-1532. doi:10.1056/NEJMc2312906

13.       Tuan WJ, Park S, Altaf S, Zgierska AE. Assessing the Initial Impact of X-Waiver Elimination on Buprenorphine Prescribing for Opioid Use Disorder. Subst Use Addctn J. Published online January 30, 2026:29767342251414541. doi:10.1177/29767342251414541

14.       Piantadosi S, Byar DP, Green SB. The ecological fallacy. Am J Epidemiol. 1988;127(5):893-904. doi:10.1093/oxfordjournals.aje.a114892

15.       Robinson WS. Ecological Correlations and the Behavior of Individuals. American Sociological Review. 1950;15(3):351-357. doi:10.2307/2087176

16.       Lagisetty P, Garpestad C, Larkin A, et al. Identifying individuals with opioid use disorder: Validity of International Classification of Diseases diagnostic codes for opioid use, dependence and abuse. Drug Alcohol Depend. 2021;221:108583. doi:10.1016/j.drugalcdep.2021.108583

MEPS Tutorial 8: Estimating slopes from a regression model using R

In a previous tutorial, I reviewed how we can perform trend analysis using R on survey-weighted estimates. However, I neglected to discuss how to estimate the average slope across time. Rather, I focused on estimate the predicted values at each year.

In this tutorial, I show how you can use the margins command in R to estimate the survey-weighted average total healthcare expenditures across years for males and females. You can read the tutorial on my RPubs page (link).

Finance: Markowitz portfolio variance

Background

I wanted to learn about finance, so I started to take some courses in it. It’s been nearly a year, and I have learned a ton. To help reinforce what I’ve learned (and to share the knowledge), I plan to write about finance every once in a while. For this first article on finance, I wanted to write about the Markowitz portfolio variance.

In finance, one of the most important discoveries was by Harry Markowitz when he figured out how to measure the portfolio variance. It is used in modern portfolio theory to estimate the combination of investments that would reduce idiosyncratic risk, which is inherit in the asset (or a group of assets). Idiosyncratic risk is unrelated to the risk in the market. Rather, it is the risks when assets that you invest in are correlated with each other. The more correlated they are, the more risky they become.

Assets that are part of the same sector or type tend to be correlated with each other. For instance, General Motors is an automobile company, and its stock price will likely be correlated with another automobile company like Ford Motors. If you want to diversify your portfolio, investing in both General Motors and Ford Motors increases your idiosyncratic risk since both investments would be part of the same sector. If one of these firms does poorly, it is likely that the other firm will do poorly.

Markowitz was able to develop an equation that would capture the idiosyncratic risk associated with a combination of assets in an investment. His portfolio management variance calculation uses the standard deviation of one asset (Asset A) and its correlation with another asset (Asset B). In other words, Markowitz’s formula incorporates the correlation between assets. By incorporating the correlation between assets, an investor can estimate the idiosyncratic risk of their investment strategy and avoid stocks in market sectors that would potentially be a greater risk due to their correlation.

Markowitz’s portfolio variance formula for a combination of two assets (i and j) is structured as:

where:

  • sigma_p^2 is the portfolio variance

  • w_i is the weight of Asset i

  • w_j is the weight of Asset j

  • sigma_i^2 is the variance of Asset i

  • sigma_j^2 is the variance of Asset j

  • rho_{i, j} is the correlation between Assets i and j

We can simplify this expression for a two-asset portfolio as:

Motivating Example

Let’s look at an example. Suppose we have two assets (i and j) that we want to diversify our portfolio with. We’re concerned about the idiosyncratic risk between the two. We can use this formula to estimate the idiosyncratic risk. (Note: You can download the Excel exercise from my GitHub repository here.)

Here is the data for the returns for Assets i and j:

We can estimate the average returns for Assets i and j along with their standard deviations.

Then, we can estimate the covariance between the two assets’ returns.

Next, we need to apply weights to the assets. Let’s assume that we want to place more weight to Asset i compared to Asset j. The weight for Asset i will be 0.85; hence, the weight for Asset j is 0.15 (or 1 – 0.85). The sum of the asset weights need to be 1.

Once we have estimated all the parameters, we can now combine them using the Markowitz portfolio variance formula.

The idiosyncratic risk is 0.0043, which is pretty low since the correlation between Asset i and Asset j is very small (rho = -0.000156).

 

Concluding thoughts

There is more to modern portfolio management, but this is just the first part. As we continue in future lessons, we will build upon this knowledge by learning about how we can use the Markowitz portfolio variance to determine the risk and return tradeoffs.

 

Disclosure and Disclaimer

Since this is a work in progress, expect updates in the future.

Meanwhile, this is for educational purposes only

 

References

You can learn more about Harry Markowitz on Wikipedia here.

You can also learn more about portfolio variance on Investopedia here.

You can download the Excel exercise from my GitHub repository here.

Two-Part Model with Bootstrap using R

In this article, I wanted to expand on a previous post that describes using a two-part model to model cost (or total expenditure) as an outcome with data from the Agency for Healthcare Research and Quality (AHRQ) Medical Expenditure Panel Survey (MEPS). In the previous article, I used the twopartm package, which is great at leveraging the two-part model approach. However, it does not appear to handle data from complex survey designs like MEPS.

The best way to handle complex survey design data with weights using the two-part model approach is to perform the estimations for each part separately and then combine them.

With a little help from some AI chatbots, I was able to construct a viable code that not only estimates and combines both parts of the two-part model, but also allows me to bootstrap the results to generate 95% confidence intervals (CI).

The complete article on how to construct a two-part model with bootstrap using R is available on my RPubs site (link)

One-sample z-test of proportions in R

There are situations where you will be asked to compare the performance of your institution with another institution. This is commonly done with projects that I’m on where data collection occurs at a single site, and stakeholders want to compare the single site’s findings with a reference site. More commonly, stakeholders want to compare their performance to a published paper’s findings. In other words, we want to compare an observed finding to a theoretical one.

In the case of proportions, we can compare the proportion of individuals who experienced an event in single site to the proportion from a published study. To do that, we can use the one-sample z-test of proportions.

I wrote a guide on how to perform one-sample z-test of proportions to determine if the proportion of events observed is significantly different from an expected proportion, which is available on my RPubs site (link).

Literary Cafe series: Patterns and costs of GLP1-RA (Part 1) - Getting data from MEPS

In this Literary Cafe series, I attempt to reproduce the findings from Wu and colleagues’ paper, “Patterns and costs associated with glucagon-like peptide-1 receptor agonist use in US adults with type 2 diabetes“ (link).

In this first part (with subsequent parts to follow), I demonstrate how we can use the same publicly available data from the Agency of Healthcare Research and Quality (AHRQ) Medical Expenditure Panel Survey (MEPS) to reproduce the sample used by Wu and colleagues in their study (link).

I published this article in my RPubs page (link).

Literary Cafe series: Policy analysis (Part 2) - Interrupted Times Series Analysis with publicly available data

I’m back with some Literary Cafe series updates.

I have regularly informal discussions with my students about interesting papers in the biomedical sciences. Recently, we discussed a great paper by Jurecka and colleagues on the impact of a state-wide law to change the definition of fentanyl possession on opioid-related overdose death rates.

Jurecka and colleagues used publicly available data to perform their research, and I wanted to show my students how this was done using CDC WONDER data. Hence, I started this Literary Care series to document these exercises for others to learn from.

Last month, I wrote an article on how to get data from the CDC WONDER site, which you can read here. I considered this Part 1 (Getting the data).

This is the second part of a two-part series that illustrates how to use publicly available data to replicate the findings from a published study. In Part 2, I use the data from Part 1 to analyze the impact of the statwide fentanyl possession law on opioid-related overdose death rates using an interrupted time series analysis. I posted this on my RPubs site (link) along with part 1 (link).

Literary Cafe series - Policy Analysis (Part 1): Getting Data From CDC WONDER

This is Part 1 on a series of articles that I plan to write on how to perform analyses using publicly available data inspired by published studies.

Hence, I wrote an article on how to get death data from CDC WONDER, which I posted on my RPubs site here.

I’m not sure how these articles will evolve, so I’ll start with something simple like this first part, which is to gather the data to perform the analysis (Part 2 is available here).

Meanwhile, I think I’ll call these series of articles, “Literary Cafe series.” (Note: I know that this title needs work.)