library(tidyverse)
library(patchwork)
library(plotly)
setwd("~/Library/Mobile Documents/com~apple~CloudDocs/Data110")
acupuncture <- read_csv("acupuncture.csv")Project 2 (Acupuncture)
Essay Analysis
This dataset explores the effects of acupuncture therapy in treating migraines and tension-type headaches. The authors of this datset are Dr. Steven C. Grambow, Director, Duke Clinical Research Training Program and Assistant Professor, Duke University. The categorical variables included are sex (comparing the results of males with females), the group (comparing the test and the control), migraine diagnosis (tension-type headaches or migraines). The numerical variables included the acupuncturist, the frequency, severity score. I was interested in working with this dataset because I experience chronic migraines, and have tried various treatments for myself. I have no prior knowledge about acupuncture therapy, so I was highly curious to see its results.
The Chinese practice of acupuncture therapy is a medical method where needles are inserted into specific locations in the body, often used for chronic pain or illness. The concept of a person’s “chi”, and “yin and yang” balance is what guides acupuncture and its complex needle palcement locations (Urits, Patel, Putz, Monteferrante, Nguyen, An, Cornett, Hasoon, Kaye, Viswanath). NIH claims evidence of lowered pain duration and frequency in chronic and episodic migraine patients after acupuncture treatment, however, this dataset I explored reveals otherwise.
The results in this dataset suggests that acupuncture treatment for chronic migraines in males and females had no effect, or a worsening effect. Very few in the experimental or control group showed positive results of lower frequency and severity. There is almost no identifiable pattern comparing the control group to the experimental group, indicating that the study had little impact on migraines. There was also no visible pattern difference between the reaction of males compared to females, but this variable is not highly reliable due to the sex imbalance of test subjects. Although a majority of the migraine patients experienced an increase in frequency and severity after one year on the trial, it can not be indicated that the acupuncture was a factor in this, other uncontrollable variables were also involved such as time, chronicity, environment, physical health, etc.
http://pmc.ncbi.nlm.nih.gov/articles/PMC7606388/
Manipulate the data and create new columns
Filter for the headache type to just be migraines. Mutate to create the new variables “sex1” to change the sex from 0’s and 1’s to “male” and “female”. Mutate to create the new variables that compare the difference between baseline frequency/severity to the results after 1 year. Also filter to only focus on the baseline, and 1 year frequencies and severity scores.
migraine <- acupuncture|>
filter(migraine==1)|>
mutate(sex1=ifelse(sex==1,"Female", "Male")) |>
mutate(severitydiff=pk5-pk1)|>
mutate(freqdiff=f5-f1)|>
mutate(group1=ifelse(group==1, "Treatment", "Control"))|>
filter(!is.na(pk1) & !is.na(pk5))Compare individual frequency to severity at baseline
p1 <- ggplot(data = migraine, aes(x=pk1, y=f1, color=age))+
geom_point()
p1Compare the frequency and severity after one year of treatment
p2 <- ggplot(data = migraine, aes(x=pk5, y=f5, color=age))+
geom_point()
p2p3 <- ggplot(data = migraine, aes(x=severitydiff, y=freqdiff, color=group1))+
geom_point()+
geom_vline(xintercept = 0)+
geom_hline(yintercept = 0)
p3migraine1 <- migraine |>
mutate(change = ifelse(severitydiff <=0 & freqdiff <= 0, "improvement", "no improvement" ))|>
mutate(change_value = severitydiff + freqdiff)Perform a linear regression
fit1 <- lm(data = migraine1, change_value ~ age + sex + group + chronicity + practice_id)
summary(fit1)
Call:
lm(formula = change_value ~ age + sex + group + chronicity +
practice_id, data = migraine1)
Residuals:
Min 1Q Median 3Q Max
-56.484 -8.110 0.783 9.745 52.858
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -17.104774 5.830260 -2.934 0.00363 **
age 0.256046 0.107054 2.392 0.01743 *
sex -1.514660 2.731198 -0.555 0.57963
group -5.950639 1.951625 -3.049 0.00252 **
chronicity 0.001945 0.080135 0.024 0.98065
practice_id -0.020816 0.086603 -0.240 0.81023
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 16.37 on 278 degrees of freedom
Multiple R-squared: 0.05756, Adjusted R-squared: 0.04061
F-statistic: 3.396 on 5 and 278 DF, p-value: 0.005393
fit2 <- lm(data = migraine1, change_value ~ age + sex + group)
summary(fit2)
Call:
lm(formula = change_value ~ age + sex + group, data = migraine1)
Residuals:
Min 1Q Median 3Q Max
-56.166 -8.140 0.726 9.811 52.413
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -17.80485 5.02911 -3.540 0.000468 ***
age 0.25951 0.09214 2.817 0.005200 **
sex -1.44085 2.70078 -0.533 0.594115
group -5.94033 1.94180 -3.059 0.002434 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 16.31 on 280 degrees of freedom
Multiple R-squared: 0.05736, Adjusted R-squared: 0.04726
F-statistic: 5.68 on 3 and 280 DF, p-value: 0.000866
plot(fit2)Model analysis
- The age and group were meaningful when predicting the change in severity and frequency after 1 year of treatment
- The practice ID (the acupuncturist), and chronicity (the number of years of migraine experience) were not meaningful variables
- The adjusted R-squared was 4.7%, meaning that only 4.7% variations in the observations were represented in the model.
- The residual plots looked goo, and showed variation, but the QQ plots showed extreme outliers.
First visualization
p3 <- ggplot(data = migraine, aes(x=severitydiff, y=freqdiff, color=group1))+
geom_point()+
geom_vline(xintercept = 0)+
geom_hline(yintercept = 0)
p3labels <- tribble(
~severitydiff, ~freqdiff, ~label,
-50, -5, "Worse \n Condition",
10, 13, "Improved \n Condition")
labels# A tibble: 2 × 3
severitydiff freqdiff label
<dbl> <dbl> <chr>
1 -50 -5 "Worse \n Condition"
2 10 13 "Improved \n Condition"
Facet the data into two groups (“Male and Female”) for comparison
p4 <- ggplot(data = migraine, aes(x=severitydiff, y=freqdiff, color=group1))+
geom_point()+
geom_vline(xintercept = 0, linetype = "dotdash", color = "darkgrey")+
geom_hline(yintercept = 0, linetype = "dotdash", color = "darkgrey")+
facet_grid(~sex1) +
theme_linedraw()+
labs(title= "Male vs. Female Migraine Frequency and Severity Development in the Control \n and Treatment Groups",
x="Severity Difference", y= "Frequency Difference",
caption = "Source: Steven C. Grambow, “Acupuncture Dataset”, TSHS Resources Portal (2015)")
p4 #geom_text(data = labels, aes(severitydiff, freqdiff, label = label, color = "dodgerblue")) +
#labs(color = "")Graph the plot using Plotly for the interactive feature
ggplotly(p4)