Class 5: Statistical Inference
Slides
The slides are available online as an HTML file. You can also download them in a static PDF (for printing or storing for later). You can also click in the slides below and navigate through them with your left and right arrow keys.
Readings
Assignment
Before starting this exercise, make sure you read the guide on simulations.
- Fill out this spreadsheet with your name, distance to school, and whether you prefer cats or dogs
Be very careful in how you fill out the sheet as in the first example row (otherwise it will be a point to analyze later for everyone).
- distance to school: use the exact value in kilometers, with decimals indicated by
.
- preference for cats/dogs: write either “cats” or “dogs”, nothing else (got to make a choice, sorry)
Are people who prefer cats living further away from University? This will be your research question for the assignment.
Once everyone has filled out the spreadsheet, download the data and read it into R. As always, make a new or use an existing R Studio project for your assignment.
Complete the following steps
Step 1: Calculate an estimate based on your sample
Step 2: Use simulation to invent a world where the true effect is null.
- Simulate 1000 samples with the same sample size that your estimate is based on. Store the estimates of this simulation in a vector called
sampling_distribution
.
- Simulate 1000 samples with the same sample size that your estimate is based on. Store the estimates of this simulation in a vector called
Step 3: Plot how well this estimate fits into your null world.
Step 4: Calculate the probability that your estimate could exist in the null world.
Use the standard deviation of yoursampling_distribution
to transform your initial estimate in a z-value. Based on this, calculate the p-value.Step 5: Decide if your estimate is statistically significant.
Use a significance threshold (the value at which you consider your estimate sufficiently unlikely to have occurred in the Null World) of 0.05
- Is this result surprising to you or not? Explain.