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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Significance tests 221Sign test <strong>for</strong> the medianAssume X 1 , X 2 , …, X n are from a continuous distribution with positive density. Asignificance test of the hypothesesH 0 :median=m, H A :medianm, or median≠m,can be per<strong>for</strong>med with test statisticT=the number of X i with X i >m.If the data has values equal to m, then delete those values from the data set. Under H 0 ,T has a Binomial(n, 1/2) distribution. Large values of T support the alternative that themedian is greater than M; small values of T support the alternative that the median issmaller than M. For two-sided alternatives, large or small values of T support H A . The p-value is calculated byIn R, the test statistic can be computed using sum(). The p-values are found usingpbinom(k). However, as P(T≥k)=1−P(T≤k−1), the p-value is is found with1−pbinom(k−1, n, 1/2).■ Example 8.6: Length of cell-phone calls Suppose a cell-phone bill contains this data<strong>for</strong> the number of minutes per call:2 1 3 3 3 3 1 3 16 2 2 12 20 31Is this consistent with an assumption that the median call length is 5 minutes, or does itindicate that the median length is less than 5?The hypothesis test isH 0 :the median =5, H A :the median < 5.The data is clearly nonnormal, so a t-test is inappropriate. A sign test can be used. Here,small values of T support the alternative.> calls = c(2, 1, 3, 3, 3, 3, 1, 3, 16, 2, 2, 12, 20,3, 1)> obs = sum(calls > 5) # find observed value ofT> n = length(calls)> n − obs[1] 12> 1 − pbinom(11,n,1/2) # we want P(T >= 12)[1] 0.01758We get a p-value of 0.0176, which leads us to believe that the median is less than 5.

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

Saved successfully!

Ooh no, something went wrong!