Basic Inference Methods

Basic inferential methods for proportions and means are illustrated using R.

  • PDF / 256,001 Bytes
  • 20 Pages / 439.37 x 666.14 pts Page_size
  • 101 Downloads / 207 Views

DOWNLOAD

REPORT


Basic Inference Methods

6.1 Introduction Example 6.1 (Sleeping patterns of college students). To illustrate some basic inferential methods, suppose a college instructor is interested in the sleeping patterns of students in a particular mathematics class. He has read that the recommended hours of sleep for a teenager is nine hours each night. That raises several questions: ˆ Is the median sleeping time for students in this course nine hours? ˆ If the answer to the first question is no, what proportion of students do get at least nine hours of sleep in a particular night? ˆ What is a reasonable estimate of the average number of hours these math students get per night?

The instructor decides to collect some data from one representative class to answer these questions. Each student is asked what time he or she got to bed the previous night, and what time he or she woke up the next morning. Based on the answers to these questions, the instructor computes the number of hours of sleep for each of 24 students in his class. The sleeping times are placed in the vector sleep. > sleep = c(7.75, 8.5, 8, 6, 8, 6.33, 8.17, 7.75, + 7, 6.5, 8.75, 8, 7.5, 3, 6.25, 8.5, 9, 6.5, + 9, 9.5, 9, 8, 8, 9.5)

In the next sections, this data is analyzed to investigate the sleeping patterns of students.

J. Albert and M. Rizzo, R by Example, Use R, DOI 10.1007/978-1-4614-1365-3__6, © Springer Science+Business Media, LLC 2012

153

154

6 Basic Inference Methods

6.2 Learning About a Proportion 6.2.1 Testing and estimation problems Let M denote the median hours of sleep for the population of students who take this math course. We are interested in testing the hypothesis H that M = 9 hours. This testing problem can be restated as a test of a population proportion. Let p denote the proportion of students who get at least nine hours of sleep on a particular night. If the population median is M = 9 hours, then the proportion p = 0.5. So we are interested in testing the hypothesis H : p = 0.5. In the event that H is rejected, one typically is interested in learning about the location of the proportion, and one constructs an interval estimate that contains p with a given confidence.

6.2.2 Creating group variables by the ifelse function The relevant data for this hypothesis test is the sample size and the number of students in the sample who get at least nine hours of sleep. Using the ifelse function, we define a new variable nine.hours that records for each observation if the student got at least nine hours of sleep (“yes”) or didn’t (“no”). Then we tabulate this “yes, no” data by the table function. > nine.hours = ifelse(sleep >= 9, "yes", "no") > table(nine.hours) nine.hours no yes 19 5

Only five out of 24 students indicated that they had at least nine hours of sleep. If H is true, the number of yes’s has a binomial(n = 24, p = 0.5) distribution with mean np and variance np(1 − p). In addition, if n is large, this variable is approximately normally distributed.

6.2.3 Large-sample test and estimation methods The traditional test for a proportion