Answers to Selected Exercises
Exercise 2.11: One should always test R functions one has written by trying several combinations of inputs. Will your function work correctly if m > n? m < 0? Be sure to include solution messages such as
> print("m must be less than or equal to n"); break
Exercise 2.13:
Exercise 3.7:
Exercise 3.14:
Exercise 4.7:
sales=c(754,708,652,783,682,778,665,799,693,825,828,674,792,723) t.test(sales, conf.level=0.9)
Exercise 5.4: The results will have a binomial distribution with 20 trials; p will equal 0.6 under the primary hypothesis, while under the alternative p will equal 0.45.
Exercise 5.5: You may want to reread Chapter 2 if you had trouble with this exercise.
Exercise 8.2:
> imp=c(2, 4, 0.5, 1, 5.7, 7, 1.5, 2.2) > log(imp) [1] 0.6931472 1.3862944 -0.6931472 0.0000000 1.7404662 1.9459101 0.4054651 [8] 0.7884574 > t.test(log(imp)) One Sample t-test data: log(imp) t = 2.4825, df = 7, p-value = 0.04206 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.03718173 1.52946655 sample estimates: mean of x 0.7833241 ...
Get Introduction to Statistics Through Resampling Methods and R, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.