R Markdown Exercise: Multi-Sample Tests and Randomization Test

Please use this template (Right click and choose Save Link As...) for this RMarkdown exercise.

In this problem, you will analyze the Stat 100 survey 3 data in Fall 2015. The csv file can be downloaded here. The column variables are described on this webpage. The purpose of this exercise is to find out if there is any association between happiness (a person's subjective well-being) and a person's temperament (introvert/extrovert/ambirvert).

  1. (2 points) Create box plots of 'happiness' for the introverts, extroverts and ambiverts. Add the group means to the box plots.
  2. (3 points) Perform an F-test to determine if there are any significant differences on the reported scale of happiness among introverts, extroverts and ambiverts. Report the p-value and state your conclusion.
  3. (4 points) Perform pairwise t-tests with Bonferroni correction to adjust the p-values. Determine from the adjusted p-values which pairs of groups show significant differences at the 5% level.
  4. (5 points) Perform a randomization test by scrambling the 'happiness' variable and calculate the values of R2 of the scrambled data. Repeat the experiment at least 5000 times. Make a histogram of these R = √R2 and indicate the position of the original R (from the unscrambled data).
    Note: The result of your randomization test must be reproducible. Therefore, you must set a seed number before calling any function involving random numbers. Use set.seed(your UIN) to set the seed. You can simply follow the procedure in this week's notes. You are not required to optimize the code.
  5. (3 points) Use the result of (d) to estimate the p-value. How does this estimated p-value compare to the one computed in part (b)?

Guidelines


Solution