10.07.2015 Views

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Univariate data 43compare different data sets quantitatively. In this section we cover central tendency; inthe next we cover measures of spread.The most familiar notion of the center of a numeric data set is the average value of thenumbers. In statistics, the average of a data set is called the sample mean and is denotedbyThe sample meanThe sample mean of the numeric data set, x 1 , x 2 , …, x n , is(2.1)The mean() function will compute the sample mean <strong>for</strong> a data vector. Additionalarguments include trim= to per<strong>for</strong>m a trimmed mean and na.rm= <strong>for</strong> removal of missingdata.The mean can be found directly from the <strong>for</strong>mula, as in> x = scan()1:2 3 16 23 14 12 4 13 2 0 0 0 6 28 31 14 4 8 2 521:Read 20 items> sum(x)/length(x)[1] 9.35<strong>Using</strong> the mean() function is preferable, though:> mean(x)[1] 9.35The mean is the most familiar notion of center, but there are times when it isn’t the best.Consider, <strong>for</strong> example, the average wealth of the patrons of a bar be<strong>for</strong>e and afterMicrosoft co-founder Bill Gates steps in. Really large values can skew the average,making a misleading measure of center.The medianA more resistant measure of the center is the sample median, which is the “middle”value of a distribution of numbers. Arrange the data from smallest to biggest. When thereis an odd number of data points, the median is the middle one; when there is an evennumber of data points, the median is the average of the two middle ones.The sample medianThe sample median, m, of x 1 , x 2 ,…,x n is the middle value of the sorted values. Let thesorted data be denoted by x (1) ≤ x (2) ≤ …≤x (n) . Then

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!