2024-04-06

Introduction

Greetings,

In today’s presentation, we delve into an intriguing exploration of the interrelationship between drug ratings and the number of users who found a review useful. Our investigative tools of choice are the robust statistical methods of Simple Linear Regression and Linear Correlation.

Methods

Our Objective is twofold:

1.Simple Linear Regression: We aim to construct a predictive model that estimates the number of users who find a review useful based on the drug rating. This model will enable us to quantify the impact of drug ratings on user engagement.

2.Linear Correlation: We seek to measure the strength and direction of the linear relationship between drug ratings and user engagement. This analysis will provide insights into how these two variables move together.

Data Description 1

The dataset contains the following variables

  1. ID (numerical integer):Identification

  2. drugName (categorical): name of drug

  3. condition (categorical): name of condition

  4. review (text): patient review

  5. rating (numerical): 10 star patient rating

  6. date (date): date of review entry

  7. usefulCount (numerical): number of users who found review useful

Data Description 2

## spc_tbl_ [53,766 × 7] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ ...1       : num [1:53766] 163740 206473 159672 39293 97768 ...
##  $ drugName   : chr [1:53766] "Mirtazapine" "Mesalamine" "Bactrim" "Contrave" ...
##  $ condition  : chr [1:53766] "Depression" "Crohn's Disease, Maintenance" "Urinary Tract Infection" "Weight Loss" ...
##  $ review     : chr [1:53766] "\"I've tried a few antidepressants over the years (citalopram, fluoxetine, amitriptyline), but none of tho"| __truncated__ "\"My son has Crohn's disease and has done very well on the Asacol.  He has no complaints and shows no side"| __truncated__ "\"Quick reduction of symptoms\"" "\"Contrave combines drugs that were used for alcohol, smoking, and opioid cessation. People lose weight on it b"| __truncated__ ...
##  $ rating     : num [1:53766] 10 8 9 9 9 4 6 9 7 2 ...
##  $ date       : chr [1:53766] "February 28, 2012" "May 17, 2009" "September 29, 2017" "March 5, 2017" ...
##  $ usefulCount: num [1:53766] 22 17 3 35 4 13 1 32 21 3 ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   ...1 = col_double(),
##   ..   drugName = col_character(),
##   ..   condition = col_character(),
##   ..   review = col_character(),
##   ..   rating = col_double(),
##   ..   date = col_character(),
##   ..   usefulCount = col_double()
##   .. )
##  - attr(*, "problems")=<externalptr> 
## NULL

Exploratory Data Analysis

Keep exploring

Simple Linear Regression

\[ \begin{align*} \text{Useful Count (y)} &= β₀ + β₁ \times \text{Drug Rating (x)} + ε \\ \text{Where:} \\ β₀ &= \text{intercept} \\ β₁ &= \text{slope coefficient}\\ ε & = \text{error} \end{align*} \]

Fit the linear regression model

3D Visualization

The x-axis represents drug ratings. The y-axis represents the number of useful counts. The z-axis represents drug names.

Fit the linear regression model

summary(mod)
## 
## Call:
## lm(formula = usefulCount ~ rating, data = dataset)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -35.88 -20.83  -9.22   8.12 915.73 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  9.79097    0.35578   27.52   <2e-16 ***
## rating       2.60843    0.04614   56.54   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 35.14 on 53764 degrees of freedom
## Multiple R-squared:  0.05612,    Adjusted R-squared:  0.0561 
## F-statistic:  3197 on 1 and 53764 DF,  p-value: < 2.2e-16

Linear correlation

Linear correlation, also known as Pearson’s correlation, is a measure of the strength and direction of association that exists between two continuous variables correlation coefficient \[ r = \frac{\sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum_{i=1}^{n} (x_i - \bar{x})^2 \sum_{i=1}^{n} (y_i - \bar{y})^2}} \]

\[ r = 0.24 \]

print(correlation <- cor(dataset$rating, dataset$usefulCount))
## [1] 0.2368972

Conclusion

1.Correlation coefficient of 0.23 suggests a weak positive relationship between the variables, but it is still considered a positive correlation.

2.The model predicts Useful Count (y) based on Drug Rating (x).

3.For each unit increase in Drug Rating (x), the Useful Count (y) increases by 2.60843, on average.

4.The Drug Rating (x) is a significant predictor of Useful Count (y), as indicated by the F-statistic and its associated p-value.

5.The model explains about 5.61% of the variability in Useful Count (y). (It’s important to note that a low R-squared value does not necessarily mean the model is bad,the value should be interpreted in the context.)