# Precept Week 01

Software Setup and Randomization Tests

POL346
2021-04-19

### Have you knit an R Markdown document?

• No? See Handouts $$\rightarrow$$ Setup Instructions at http://pol346.com/setup_instructions.html

• To test that it is working, create a new R Markdown document in RStudio, and see if can knit

• If you can’t complete installation, follow-up with instructors

### All set-up? Analyze Chapter 1: Creativity study

• Teresa Amabile ran an experiment on effects of intrinsic and extrinsic motivation on creativity

• Subjects with creative writing experience randomly assigned: 24 to “Intrinsic,” 23 to “Extrinsic”

• Poems submitted to 12 poets, who rated them on 40-point scale of creativity

• Score is average of 12 judges

### Exercise: Assess whether observed difference in means is extreme with a randomization test

• If treatment had no effect, then observed outcomes are unrelated to whether subject was assigned to treatment or control group

• Under assumption of “null hypothesis” or that treatment had no effect, we could shuffle all treatment and control assignments and recalculate difference-in-means

• These simulated results allow us to see if our observed result is extreme compared to other plausible treatment and control groups

• Each randomization is like a possible parallel universe (under assumption of no effect of treatment)

### Question: Does the mean level of creativity differ between the intrinsic treatment group and the control group?

1. With Base R t.test(), calculate whether there is a significant difference-in-means

2. Randomize treatment assignment and calculate a new difference-in-means. See Chapter 1 supplement at http://pol346.com/chapter1.html

3. Now, repeat Step 2 ten times. How do these results compare to observed difference-in-means?

4. Randomize treatment assignment and calculate difference-in-means 1,000 times, plot histogram of differences

5. With infer calculate randomization distribution and plot histogram of differences. For more about infer, see https://moderndive.com

### Coding help: load packages & data

# load packages
suppressMessages(library(dplyr))
suppressMessages(library(janitor))
library(infer)