{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework_02_Solutions

Homework_02_Solutions - 1 Simple Random Samples(a Step 1...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1. Simple Random Samples (a) Step 1: give each pet an identification number, i.e. 1, 2, ..., 1000. Step 2: choose a random sample of 10 numbers from these 1000 numbers. Step 3: pick those pets with the id numbers that correspond to Step 2. (b) Use R code: > mysample <- sample(1:10000,10) > mysample [1] 3539 4789 9286 7808 7219 8911 5620 8184 9627 4058 > obesity[mysample, 4] # or obesity[mysample, ’name’] [1] Nicole I. Lacey S. Jamie O. Jamie X. Ana J. Jamie C. [7] Cara O. Valerie U. Jon Q. Julian I. Note: obesity is the name for the data set; variable name is the 4th column of the data set so obesity[mysample, 4] is to choose those entries of specified rows and the 4th column. (c) > obesity[mysample, 5] # or: obesity[mysample, ’obese’] ) [1] YES YES YES YES YES NO YES YES YES NO The percentage of obesity for this sample=8/10=80%. We could also use the R-function table() : > table(obesity[mysample, 5]) (d) the population percentage of obesity is estimated to be 80%. (e) It is not accurate due to a small sample size so the variability of the estimate is large. (though it is a random sample). (Later we will learn that the sample size affects the ‘accuracy’ of the estimates. . . ). Try another sample: > mysample2 <- sample(1:10000,10) > mysample2 [1] 2779 9359 9103 7160 1684 7024 2201 6633 2855 1405 > obesity[mysample2, 5] [1] YES NO NO NO YES NO YES YES NO YES in this case, the sample percentage=5/10=50%.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
(f) Increase the sample size (g) 62.74% (R commander: Statistics–Summaries–active data set)
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern