Estimating means

In the example that is going to span this entire chapter, we are going to be examining how we would estimate the mean height of all US women using only samples. Specifically, we will be estimating the population parameters using samples means as an estimator.

I am going to use the vector all.us.women to represent the population. For simplicity's sake, let's say there are only 10,000 US women:

 > # setting seed will make random number generation reproducible 
 > set.seed(1) 
 > all.us.women <- rnorm(10000, mean=65, sd=3.5) 

We have just created a vector of 10,000 normally distributed random variables with the same parameters as our population of interest using the rnorm function. Of course, at this point, we can just call mean ...

Get Data Analysis with R - Second 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.