# From your file menu (at the top of R-Studio) select:# "Session -> Set working directory -> To source file location"# Then play this chunk to get the data into R.library(mosaic)library(car)library(DT)library(pander)library(readr)library(plotly)food <-read_csv("../../data/food.csv") #food.csv is in the Data folder...
As an avid gym-goer, I wanted to see how exercise can affect the weight of an individual. Is weight affected by the number of days spent at the gym? Let’s look at the weight differences in the groups that work out everyday, two or three times a week, and once a week.
Here is the data table with the selected options for your viewing pleasure. I only have the 3 options of gender, weight, and exercise selected.
H_0: \text{All samples represent a sample of data from the same distribution.}
H_a: \text{At least one distribution is stochastically different than the others.}
Signifigance is
\alpha = 0.05
Show the code
plot_ly(data = foodE, type ="box") %>%add_trace(y =~weight[exercise =="1"], name ="Everyday", color =I("indianred1") ) %>%add_trace(y =~weight[exercise =="2"],name ="2 or 3 Times a Week", color =I("dodgerblue1") ) %>%add_trace(y =~weight[exercise =="3"], name ="Once a Week", color =I("darkgoldenrod1") ) %>%layout(title ="Exercise or Extra Fries?",yaxis =list(title ="Weight (lbs)"),xaxis =list(title ="Days Exercised") )
We can see the the variation in weight between the everyday people and the 2 or 3 times a week to be roughly the same. The once a week group has much more variation and appears to be about the same. We will need to take a look at the Kruskal-Wallis Rank Sum test to be sure.
Show the code
favstats(as.numeric(weight) ~ exercise, data = foodE)%>%pander()
exercise
min
Q1
median
Q3
max
mean
sd
n
missing
1
110
140
160
180
260
160.7
27.91
57
0
2
112
130
150
170
210
153.9
26.76
41
3
3
128
145
167.5
188.8
264
173.7
39.77
10
1
Group 1 is everyday, group 2 is two or three times a week, and group 3 is
We see that the once a week group does have the higher average weight at 173.7 but there are only 10 individuals represented. 2 or 3 times a week had 41 individuals and the lowest average of 153.9 pounds. Finally, the everyday group has an average weight of 160.7 for 57 individuals.
The Kruskal-Wallis test compares the ranks of all of the people in each group, and makes it possible to study more than 2 ranked groups. This test orders each value from lowest to smallest, adds up the total ranks in each group and divides by each group’s total values.
We can see that the p-value is not significant \alpha > 0.1859. All groups show a similar enough average to not be significant. We fail to reject the null hypothesis
Interpretation / Conclusion
We failed to reject the null with p-value 0.1859 > \alpha. The difference in weights across the exercise quantity groups was not significant. All samples can be assumed to be from the same distribution, exercise amounts has no clear effect on weight.
Although once a week had the highest average weight at 173.7 pounds, and all other numbers in the 5-number summary being the highest of the 3 groups, the Kruskal-Wallis test did not find significance.
There is little variation between the everyday and two or three times a week groups. The averages are only 7.2 pounds off and their sample sizes are relatively similar.
While I call for a more scientific test to view the weights of individuals based on their exercise, I do not know the intensity of their workouts, and I did not separate by gender. If we separated the groups by gender I’m sure we would find a much more significant result. I would also prefer to look at more accurate information such as body mass index but more especially muscle mass, bone density, and body fat percentages.
For the purposes of this study we see there is no significant weight difference in those who work out once a week, two or three times a week, or everyday.