Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 37 ยท Projects and Practice

Practice Set: Regression and Inference

Practice correlation, least-squares regression, confidence intervals and hypothesis tests with eight problems and runnable code to check your answers.

Here are eight problems on correlation, regression, sampling and inference. Attempt each by hand (a calculator is fine), then run the checker code. Relevant lessons: Pearson correlation, regression, residuals, sampling distributions, confidence intervals and hypothesis tests.

Problems

Regression

  1. Data for 6 cyclists: training hours per week x = 2, 4, 5, 7, 8, 10 and 5 km time in minutes y = 30, 27, 26, 23, 22, 19. Compute r and the least-squares line, and describe the relationship.
  2. Using your line from problem 1, predict the time for 6 hours of training. Would a prediction for 20 hours be trustworthy? Why not?
  3. Find the residuals for the six cyclists and the value of Rยฒ.

Sampling and intervals

  1. A population has standard deviation 20. What sample size gives a standard error of 2?
  2. A sample of 64 plants has mean height 31.5 cm and standard deviation 6 cm. Find a 95% confidence interval for the true mean.
  3. In a survey of 400 people, 168 say they bike to work. Find a 95% confidence interval for the proportion.

Testing

  1. A website claims that 50% of visitors click a banner. In a sample of 200, 116 click. Test Hโ‚€: p = 0.5 against Hโ‚: p โ‰  0.5 using a normal approximation (z-test for a proportion).
  2. A drug is said to lower mean blood pressure by exactly 0 units (Hโ‚€: ฮผ = 0). In 36 patients the mean change is -2.4 with standard deviation 6. Test at the 5% level using a z-test with s in place of ฯƒ.

Checker 1: regression

Python Answers for problems 1 to 3

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Checker 2: inference

Python Answers for problems 4 to 8

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Writing your conclusions

Numbers are not an answer by themselves. Practice finishing each problem with a sentence in context:

  • Regression: "For each extra hour of weekly training, the predicted 5 km time falls by about ... minutes."
  • Interval: "We are 95% confident that the true mean height is between ... and ... cm."
  • Test: "Since the p-value is ... which is (less / greater) than 0.05, we (reject / fail to reject) Hโ‚€. There is (some / not enough) evidence that..."

Problem 7 uses the null proportion 0.5 in the standard error, because a test assumes Hโ‚€ is true. A confidence interval uses the sample proportion instead.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. In a z-test for a proportion with Hโ‚€: p = 0.5, which standard error is correct?

    A test assumes Hโ‚€ is true, so the standard error uses pโ‚€ = 0.5.
  2. 2. A regression is fitted using x values between 2 and 10. Predicting at x = 20 is...

    It lies far outside the observed range, so the linear pattern may not hold.
  3. 3. To make a standard error four times smaller, the sample size must be...

    SE โˆ 1/โˆšn, so you need โˆšn four times larger, i.e. n sixteen times larger.

Summary

  • Pair every calculation with an interpretation in context.
  • Tests use the null value in the standard error; intervals use the sample estimate.
  • Check regression predictions are inside the data range.
  • Use code as a checker, not a replacement for working it out.

Next: Mini-Project: Analyze a Dataset