# The central line in a box plot represents the median value of the data. Since the medians of the two box plots are equal, it suggests that, on average, the values in the two sex groups are comparable. Hence, this model conveys that the number of years of headache disorder is similar between the two groups.
Create a scatter plot of Age and Chronicity to explore whether patient age predicts the number of years the patient has had chronic headaches. Add a linear regression line to the plot.
ggplot(acupuncture, aes(x=age, y=chronicity)) +geom_point() +geom_smooth(method ="lm") +theme_bw() +labs(x="Age", y="Number of Years Having Headache Disorder", title=" Scatter Plot of Age to Number of Years Having Headache Disorder")
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
# By looking at this model, we can estimate the relationship between the two quantitative variables (age and chronicity). Since the data points are following a gradual pattern up from left to right, we can see a positive association. However, we must also take into consideration how close the data points are to the line of best fit on the scatter plot. Since the majority of data points lie far away from the regression line, we can also assume a weak relationship between the two variables. Thus, we can say that this is a weak positive model, and that age slightly predicts the chronicity of the condition. Older patients seem to struggle with chronic headaches for a longer amount of time.
Create side-by-side box plots of group type and “pk5,” which is the headache severity score after 1 year.
# The reason I chose to analyze the effect of the treatment on "pk5" is because the primary outcome of this trial was the patients' headache score at the one-year follow up. Since the median of the treatment group is notably lower than that of the control group, it suggests that the treatment (acupuncture) may be an effective and safe therapy for migraine. In addition, the box plot for the treatment group is lower than that of the control group, which tells us that acupuncture therapy is helpful in reducing headache severity (as most of the values in the treatment group are lower than those in the control group). Lower values mean lower headache severity scores, which suggests that the acupuncture treatment is effective.
Create a bar chart to show the number of patients in the treatment and control groups.
acupuncture3 <- acupuncture %>%mutate(group =if_else(group >0, "treatment", "control")) %>%na.exclude()ggplot(acupuncture3, aes(x = group)) +geom_bar() +labs(x ="Type of Treatment Group", y ="Count",title ="Number of Patients in Each Treatment Group")