Non-Opioid Analgesics - Web Scraping for Market Analysis

Posted on Aug 12, 2018


With the opioid crisis in full swing, the pharmaceutical industry has been under pressure to bring non-opioid pain medications to the market. As of August 2018, there are 17 drugs in late-stage clinical development and 40 drugs in early-stage development. While there is clearly a need for non-addictive pain analgesics, since both chronic and acute pain patients are left without effective pain management alternatives, pharmaceutical companies are rushing to get new drugs to market. Even though the current and most popular pain medications on the market are effective as reducing pain, medical research has shown that these prescriptions are a direct cause of the rapidly increasing number of drug overdose deaths from opioids in the U.S., which rose to almost 50,000 people in 2017.

Yet pain accounts for a greater amount of U.S. healthcare costs compared to diseases such as cancer and diabetes, and as such, the pharmaceutical industry has a huge market opportunity for new, non-opioid pain killers due the crackdown on prescriptions for these analgesics as a result of the opioid abuse public health crisis. However, the biggest mistake that a pharmaceutical company can make when developing a new drug is not to analyze the current market, which risks wasting money and time in research and development on a drug that is not marketable, regardless of its effectiveness. In an attempt to describe the current market outlook for prescription pain medications in the U.S., I web scraped over 10,000 patient reviews of the top six most-reviewed pain medications on WebMD.

Using Python's Scrapy framework, I developed a spider that extracted the following data from the WebMD drug reviews: drug, condition treated, the reviewer's age range, gender, length of treatment, and their comments, as well as their ratings on a scale of 1 - 5 on the drug's effectiveness, ease of use, and their satisfaction with the drug. My scrapy code and resulting data analysis can be found on my Github. The drug reviews I scraped were for the generic drugs tramadol, oxycodone, morphine, and methadone, as well as the brand-name drugs OxyContin and Opana ER.  I then conducted exploratory data analysis in an attempt to answer the following standard pharmaceutical marketing questions:

  1. Who are the customers?
  2. What are their expectations for treatment?
  3. What market segments should be high priority?
  4. What is the competitive target?
  5. What messages should be used to launch the product?

Who are the Customers?

First, I identified the customers of interest. I used the package to visualize the data. I looked at the breakdown of the patients by sex, age group, and treatment length.





The first plot, showing the breakdown of drug use by gender, demonstrates that the difference in usage by gender only significantly varies with tramadol. One possible explanation for this is that tramadol might often be prescribed to mothers after they have given birth, although I have yet to find evidence to support that claim. The breakdown by age group shows that the patients most frequently prescribed these opioid pain killers are in the age range of 45-54, followed by the ranges of 55-64 and 35-44. Interestingly enough, the third plot shows that for OxyContin, oxycodone, and methadone, patients most frequently are using the drugs for 2 to 5 years, which most likely indicated these drugs are being used to treat chronic pain. Tramadol is prescribed to a significant amount of people for 0 to 6 months, and in these cases is probably being used to treat pain post-surgery, birth, or after a physically traumatic incident. However, the next most frequent group is using tramadol for 2 to 5 years, consistent with the others. At this point, it seems as though opioids are often used to treat long-term or chronic pain, which might indicate doctors failing to talk to their patients about expected opioid use duration after surgery or trauma. It does not seem beneficial to expect patients to take opioids until their pain resolves, as studies show that can turn into a long-term dependence on these highly addictive drugs.

What is the Competitive Target?

Next, I wanted to identify the competitive target by looking at the breakdown of different conditions being treated by drug, gender, and treatment length. Users reported a variety of conditions which their pain medications treated, with some conditions being reported , so I grouped specific conditions into broader categories for analytical clarity; those groups are: acute pain, chronic pain, neuropathic pain, pain with drug tolerance, drug abuse, severe pain (which I didn't fold into chronic or acute pain because there was no indication from the patient as to which of those categories it would fall under, so I kept it separate), anesthesia, stiff/tender/painful muscles, and other. The following plot shows the proportion of the scraped reviewed that fell under these categories.



Upon initial analysis, acute pain and chronic pain are the most prevalent conditions among reviewers. However, some interesting trends appear in the next few plots, which show more detail about the distribution of conditions treated.



This plot shows the proportion of reviews for different conditions treated by drug. The proportion is how many reviews reported that condition divided by the total amount of reviews (that reported the condition treated) for that specific drug. One thing that jumps out is that generic drugs (methadone, morphine, oxycodone, tramadol) have a significant proportion of reviews for acute pain, while brand-name drugs (OxyContin, Opana ER) have a significant proportion of reviews for chronic pain. This might indicate doctors' loyalty to those brand-name pharmaceutical companies, as their chronic pain patients will take these drugs for a longer period of time than patients with acute pain. Even though doctors cannot legally receive kickbacks from pharmaceutical companies anymore, this might indicate that there is still some sort of preferential treatment.




The plot that shows the breakdown of conditions treated by gender doesn't give much insight into the market besides the fact that it seems as though the genders are being treated for the same conditions in similar proportions. However, the plot showing the breakdown of conditions treated by treatment length gives shows a much more interesting trend. Regardless of treatment length, acute pain accounts for about 40-60% of the reviews. Yet acute pain is just that, acute. Nevertheless, patients report that they've been using these opioids to treat acute pain for up to 10 years or more. This most likely indicates that patients, who might be in severe pain, define their pain as acute when in fact it's probably chronic if they've been treating it for years. This means we cannot necessarily trust the difference in self-reported acute vs. chronic pain. Still, it's clear that a large number of patients reviewing these drugs are using them to treat pain for more than 2 years; about 1300 of these patients report acute pain and about 650 report chronic pain.

What are the Expectations of Treatment?

The next stage of analysis involved looking at reviewers' ratings on effectiveness, ease of use, and satisfaction. The following plots show the distribution by drug and by condition treated.




At first glance, these graphs don't look like they give much information. The average rating in almost all of the categories is between 3 and 4.5. I had to perform some statistical analysis to obtain more valuable information. Whether the ratings are separated by drug or by condition treated, one-way ANOVA tests reveal that there is a statistically significant difference between the average rating for effectiveness, ease of use, and satisfaction, both in the case where ratings are separated by drug and the case where they are separated by condition treated. To get more of an intuition as to what is going on, we can look at how the average ratings, either for a specific drug or a specific condition, differ from the overall average rating. First looking at effectiveness, which has an overall average rating of 3.7, the effectiveness ratings for the six different drugs are all significantly different than that mean value, with morphine, tramadol, and Opana ER having lower ratings than the average and OxyContin, oxycodone, and methadone having higher ratings than the average. However, when looking at the average effectiveness rating reported for each condition treated, only drug abuse has a statistically significantly higher average rating, and only stiff/tender/painful muscles has a significantly lower rating than the average.

The difference between ratings for ease of use is less dramatic, which makes sense because the most common method of delivery for these drugs is tablets or capsules, making the difference between the drugs less distinguishable. The average ease of use rating across the board is 4.3, and only oxycodone has a significantly higher ease of use rating, while only tramadol has a significantly lower rating. The only condition that has a significantly different ease of use rating was drug abuse, which was lower than average. This might be due to the fact that opioid drug abuse can change the way pleasure nerve receptors function in the brain, and a change in taste palette could explain reviewers not liking the taste and thus reporting a lower ease of use score.

Finally, the difference between the overall average satisfaction rating of 3.5 and the average satisfaction rating for each of the different drugs was significant. For the different conditions, drug abuse, neuropathic pain, and pain with drug abuse were the only conditions with significantly higher than average satisfaction ratings.

At this point, the only thing left to analyze is the reviewers' comments. However, valuable insight was hard to come by having only basic NLP skills at this point. The only thing I can confirm is that regardless of user rating (on a scale of 1-5) for effectiveness, ease of use, or satisfaction, there was no significant difference in positive versus negative sentiment when using TextBlob to look at polarity. Future work would be to investigate this using more robust NLP tools.


To clarify upfront, I would never recommend a pharmaceutical company to size or analyze a market based only on scraped WebMD drug reviews, because the insights are going to be inherently biased towards people who most likely feel strongly about the drug either along a positive vein or a negative one. However, this could be a good way for companies to gauge the experience of patients they normally do not have access to through clinical trials. In light of this, the key takeaways from the patient reviews are:


The most frequent reviewers are those in the 45-54 age range, followed by 35-44 and 55-64.
The most common treatment lengths for reviewers is 0-6 months and 5-10 years.


Acute pain accounts for 50% of the reviews, while chronic pain accounts for 20%. However, these are patient-defined categories, so the differences between these two categories is hard to quantify.
It seems as though chronic pain is treated more often with brand-name drugs as opposed to acute pain being treated more frequently with generic drugs.

An non-trivial insight is that the bar for efficacy, method of delivery, and patient satisfaction is very high for the current opioid analgesics on the market. If doctors and pharmaceutical companies want to break into the analgesics market with a non-opioid drug, it's going to have to be very effective, easy to take, and patients are going to want to experience similar pain relieving results as they would experience with their opioid counterparts. I believe this to be where the real challenge for pharmaceutical companies lies. Is it possible for them to make effective and safe non-opioid pain relievers that perform at the same level as opioid pain relievers? Possibly, but if they can't, then doctors won't prescribe them and patients won't be satisfied with them, and the responsibility to curb the use of prescription opioids will fall on government regulation.

About Author

Related Articles

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI