# Statistics and Statistical Programming (Winter 2021)/Problem set 9

## Programming Challenges[edit]

Although these will certainly involve programming, I think you'll find that they are thinly disguised Statistical Questions.

This week the programming challenges will focus on the full population ("Seattle bikeshare") dataset from which I drew the 20 group samples you analyzed in Statistics and Statistical Programming (Winter 2021)/Problem set 3 and Statistics and Statistical Programming (Winter 2021)/Problem set 5.

With the exception of the final question, nothing here should require anything totally new to you in R. Instead, a lot of the focus is on illustrating statistical concepts using relatively simple code. The emphasis is on material covered in *OpenIntro* §5 and, for PC6, programming material introduced in this week's R tutorial.

### PC1. Import the data[edit]

The dataset for this week is available in yet another plain text format: a "tab-delimited" (a.k.a., tab-separated or TSV) file. You can find it in the `datasets/problem_set_9`

subdirectory in the course Dropbox folder. Go ahead and inspect the data and load it into R (*Hint:* `read.delim()`

is probably a good place to start).

You'll also want to make sure you have the data (and especially your friendly `x`

variable) from Statistics and Statistical Programming (Winter 2021)/Problem set 5 handy once again.

### PC2. Compare the means[edit]

Calculate the mean of the variable `x`

in the aggregate (this week's) dataset. Go back to Statistics and Statistical Programming (Winter 2021)/Problem set 5 and revisit the mean you calculated for `x`

.

#### Interpret the comparison[edit]

The data that you analyzed in problem set 5 was a random 5% sample from the dataset distributed for the present problem set. Knowing that, explain the *conceptual* relationship of these two means to each other.

### PC3. Confidence interval of a mean[edit]

Again, using the variable `x`

from your problem set 5 data, compute the 95% confidence interval for the mean of this vector "by hand" (i.e., in R) using the normal formula for the standard error of a mean: , where is the standard deviation of the sample and is the number of observations (*Bonus:* Do this by writing a function.).

#### Compare and explain[edit]

Compare the mean of `x`

from your problem set 5 data—and your confidence interval from PC3—to the mean of `x`

in the dataset for the present Problem Set. Is the mean for the aggregate dataset (this week's data) within the confidence interval for your problem set 5 data? Do you find this surprising? Why or why not? Explain the conceptual relationship of these values to each other.

### PC4. Compare distributions[edit]

Let's go beyond the mean. Compare the distribution from your problem set 5 `x`

vector to the aggregate version of `x`

in this week's data. Draw histograms (or density plots) and compute other descriptive and summary statistics.

#### Interpret the comparison[edit]

What do you notice? Identify (and interpret) any differences.

### PC5. Standard deviation of conditional means[edit]

Calculate the mean of `x`

for each of the groups in the dataset for this week (within each `group`

in the aggregate dataset) and the standard deviation of this distribution of means.

#### Compare and explain[edit]

Compare the standard deviation of the means across all groups that you just calculated to the standard error you calculated in PC3 above. Discuss and explain the relationship between these values.

### PC6. A simulation[edit]

Let's conduct a simulation that demonstrates a fundamental principle of statistics. Please see the today's R tutorial for useful examples that can help you do this.

- (a) Create a vector of 10,000 randomly generated numbers that are uniformly distributed between 0 and 9.
- (b) Calculate the mean of the vector you just created. Plot a histogram of the distribution.
- (c) Create 100 random samples of 2 items each from your randomly generated data and take the mean of each sample. Create a new vector that contains those means. Describe/display the distribution of those means.
- (d) Do (c) except make the items 10 items in each sample instead of 2. Then do (c) again except with 100 items. Be ready to describe how the histogram changes as the sample size increases. (
*Bonus challenge:*Write a function to complete this part.)

#### Compare and explain the simulation[edit]

Compare the results from PC6 with those in the example simulation from today's R tutorial. What fundamental statistical principle is illustrated by these simulations? Why is this an important simulation for thinking about hypothesis testing?

## Reading Questions[edit]

### RQ1. Confidence intervals vs. p-values[edit]

Reinhart (§1) argues that confidence intervals are preferable to p-values. Be prepared to explain, support and/or refute Reinhart's argument in your own words.

### RQ2. Emotional contagion[edit]

Let's talk about the short emotional contagion paper:

- Kramer, Adam D. I., Jamie E. Guillory, and Jeffrey T. Hancock. 2014. Experimental Evidence of Massive-Scale Emotional Contagion through Social Networks.
*Proceedings of the National Academy of Sciences*111(24):8788–90.*[Available from UW libraries]*

Come to class prepared to discuss your answers to the following questions.

#### RQ2a. Hypotheses[edit]

Write down, in your own words, the key pairs of null/alternative hypotheses tested in the paper (hint: the four pairs that correspond to the main effects represented in the figure).

#### RQ2b. Describe the effects[edit]

Describe, in your own words, the main effects estimated in the paper for these four key pairs of hypotheses.

#### RQ2c. Statistical vs. practical significance[edit]

The authors report *Cohen's d* along with their regression estimates of the main effects. Look up the formula for *Cohen's d.* Discuss the *substantive* or *practical* significance of the estimates given the magnitudes of the *d* values reported.