Note that the written report should have the style of a research paper. That means that there needs to be a continuing storyline. Do not include the questions, just your answers to them. Do not use bullet points. Have connective narratives between the sentences.

Introduction

For my research question I wanted to ask whether there was any association between exercise and mood. More specifically I wanted to see the whether a happy mood would be related to an individual’s exercise over a long term period of time.

The parameter I was interested in was if long term exercise could lead to a happier mood and I wanted to generalize this information to all inhabitants of the Islands.

The literature that inspired me to conduct this study is “Spark” by John J. Ratey. The book is a collection of information relating exercise to the human brain. It brings up a myriad of studies and tests that were conducted showing that there is a link between exercise and brain health.

I suspected that the number of Islanders who exercised and were happy would be higher than those who did not exercise, based not only on the literature I reference but also my own personal experience and beliefs.

Data Collection Methods

What were the observational units? How was the variable measured? Did anything go wrong during the course of the study? Note: You can never give me too much detail in this section! In particular, there should be enough information that someone else could replicate your study on their own based only on your description. You are describing your study protocol where someone else could mimic exactly the same study that you carried out. Discuss any potential sources of sampling or non-sampling errors. For example: What was the response rate? How often did you have to make repeat visits in order to obtain the observational units initially selected?

The observational units of the study were simply the number of Islanders who participated in the survey I put out. I measured their responses in the form of binary categorical variables, the explanatory was whether they had exercised that week and the response was whether they were unhappy or not. Nothing went wrong when taking the data and I got all of the answers quickly and efficiently as the survey was only two questions. I only had to ask them to partake in the survey once as the survey was quick. I used random-sampling via a random number generator in order to ensure that there was no bias in my data.

Descriptive Statistics

Numerical and visual summaries that are appropriate for your data.

For two categorical variables in your data set, describe them, and include a two-way table, and discuss any relevant proportions. Does there appear to be an association between the two variables?

library(readr)
Final_Poject_Data_Collection <- 
  read_csv("Islanders.csv")
library(ISIwithR)
data(Final_Poject_Data_Collection)
tally(Response ~ Exercise, data = Final_Poject_Data_Collection, format = "count", margin = TRUE)
##          Exercise
## Response  No Yes
##   Happy   20  12
##   Unhappy 51   7
##   Total   71  19

While I expected that there would be a higher proportion of those who were happy and exercised, it was very unexpected at how radical the differences were between the two values. From the data there is definitely association.

Analysis of Results

In carrying out a test of significance and a confidence interval about your population parameter(s), make sure you:

  1. Define the population(s) and parameter(s) (again) in words

The population is the 90 Islanders that consented to my survey and the parameter is whether there is any association between those who exercised the week of and were happy and those who did not exercise.

  1. State the null and alternative hypotheses in symbols and in words

H_0: \(\pi_{exercise}=\pi_{didnotexercise}\) H_A: \(\pi_{exercise} \ does\ not\ equal\ pi_{didnotexercise}\)

The null hypothesis states that the proportion of those who exercise and are happy is the same as those who do not exercise and are happy The alternative hypothesis states that the proportion of those who exercise and are happy is greater than that of those who do not exercise and are happy.

  1. State what a type I and a type II error would represent in this setting

A type 1 error would mean that there is no association between the proportions but it would be read as though there is an association between happy exercisers and happy non-exercisers.

A type 2 error would mean there is association it would be read as though there is no association between the two proportions.

  1. Discuss/justify whether or not your measurements can reasonably be considered a representative sample from the population(s) of interest

Yes they can be as they were randomly selected via a random number generator and there was no bias in the selection of Islanders for the survey.

  1. Use a theory-based approach and appropriate R code to
  1. Find an appropriate standardized statistic and comment on appropriate validity conditions. Be specific
# creating a 5000 repetitions of shuffles
set.seed(28373)
Islanders.null <-do(5000) * diffprop(shuffle(Response) ~ Exercise, success = "Happy",
data = Final_Poject_Data_Collection)
head(Islanders.null, 2)
-diffprop(Response ~ Exercise, success = "Happy", data = Final_Poject_Data_Collection)
##   diffprop 
## -0.3498888
round(favstats(~diffprop, data = Islanders.null)[c("mean","sd")],3)
diffprop=-0.3498 
z<-diffprop/0.123
z
## [1] -2.843902

The z-statistic is -2.84 which makes it strong evidence against the null hypothesis, however, it is important to not that validity conditions are not met because there is not at least ten observations in each variable.

  1. Find the p-value corresponding to your alternative hypothesis and provide a one-sentence interpretation of the p-value in context (use the definition of the p-value: i.e. probability of observing … assuming … is true)
#sample sizes
n.Happy<- 32
n.Unhappy<- 58 

# counts
Exercised.Happy<-12
Exercised.Unhappy<- 7

#sample proportions 
p.hat.Happy <- Exercised.Happy/n.Happy 
p.hat.Unhappy <- Exercised.Unhappy/n.Unhappy  

# difference between the sample proportions of males vs females
p.hat.diff<-p.hat.Unhappy-p.hat.Happy
cat("difference in sample proportions of people who donated blood between males and females is",p.hat.diff)
## difference in sample proportions of people who donated blood between males and females is -0.2543103
# Standard error of the sampling distribution based on individual proportions

SE.diff.CI<-sqrt((p.hat.Happy*(1-p.hat.Happy))/n.Happy
              + (p.hat.Unhappy*(1-p.hat.Unhappy))/n.Unhappy)


# margin of error for 95% CI
MoE <- 1.96 * SE.diff.CI
#MoE

LB<-p.hat.diff - MoE # lower limit of 95% CI
UB<-p.hat.diff + MoE # upper limit of 95% CI
round(cbind(LB,UB),2)
##         LB    UB
## [1,] -0.44 -0.07
#Theory-based test p-value
#left.tailed.p.value<-pnorm(z, 0, 1, lower.tail = TRUE) 
right.tailed.p.value<-pnorm(z, 0, 1, lower.tail = FALSE) 
#right.tailed.p.value

#equivalently:
right.tailed.p.value2<-pnorm(p.hat.diff, 0, SE.diff.CI, lower.tail = FALSE)
#right.tailed.p.value2

two.sided.p.value<-2*right.tailed.p.value
cat("two-sided p-value is",two.sided.p.value)
## two-sided p-value is 1.995544

The p-value shows that there is a 1.99 probability that there will be no association between exercise and mood.

  1. Indicate what statistical decision this p-value leads you to draw about the null hypothesis

This p-value of 1.99 is very weak evidence against the null and leads me to believe that the null hypothesis is true.

  1. State your conclusion in the context of the problem

Overall, there is an no association between exercise and mood and those on the Islands who exercise have the same proportion of being happy than those who do not.

  1. If the validity conditions for a theory-based test are not satisfied use the simulation-based approach (or bootstrap) to perform the analysis. Compare and contrast your theory-based p-value to a simulation-based p-value.
#Calculating the p-value
p.value<-prop(~(diffprop <= -0.3498 | diffprop >= 0.3498), data = Islanders.null)
p.value
## prop_TRUE 
##    0.0082

The simulation based p-value is 0.008 much lower than the theory-based approach, this shows that if I had sufficiently met the validitity conditions perhaps I would have been able to mark this research question as success.

  1. Use R to find an appropriate confidence interval to describe the plausible values of your population parameter
# Standard error of the sampling distribution based on individual proportions

SE.diff.CI<-sqrt((p.hat.Happy*(1-p.hat.Happy))/n.Happy
              + (p.hat.Unhappy*(1-p.hat.Unhappy))/n.Unhappy)


# margin of error for 95% CI
MoE <- 1.96 * SE.diff.CI
#MoE

LB<-p.hat.diff - MoE # lower limit of 95% CI
UB<-p.hat.diff + MoE # upper limit of 95% CI
round(cbind(LB,UB),2)
##         LB    UB
## [1,] -0.44 -0.07
  1. Interpret the confidence interval in the context of the problem. Make sure to also comment on whether zero is included in the confidence interval. Compare your conclusion to the conclusion in 5d

We are 95% confident that those who exercise are -0.44 to -0.07 more likely to be happier than those who do not. This lines up with my conclusion that there is no association as 0 is not included but on the wrong side.

Conclusion

Summarize the results of your study (there will be some repetition, and you should cite your evidence). You should tell a story: What did you learn? Did the data behave as you expected? Pay particular attention to whether or not it is reasonable to generalize your sample to the larger population or process. Is there anything you would do differently next time? What similar questions might someone choose to investigate in the future to build on your results?

Overall, this study is a failure as I ultimately was not able to meet the validity conditions of a theory-based approach. I assumed there would be a more even spread among the variables and while the proportion of those who exercised and were happy were greater than those who did not, this proportion was a fluke. Next time when conducting this study I will make sure to sample a much larger population that what was previously sampled. There are also a lot of other factors to consider with mood that exercise cannot do a lot to assuage.

Bibliography: references to literature mentioned in the introduction

Use the correct citation format (Sample Citation:)

Sample Citation: John J. Ratey, Spark:The Revolutionary New Science of Exercise and the Brain, Little, Brown Spark, Chapter 5, 2013.

Presentation: Style, organization, layout, grammar, presentation of a written report, creativity. Make use to cite any work/studies you used to come up with your research question.

R code: Also, make sure that all relevant R code and output are in the body of your report.