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.

<strong>Using</strong> R <strong>for</strong> introductory statistics 222For illustration, the p-value <strong>for</strong> the two-sided alternative can be computed as follows:> k = max(obs, n − obs)> k[1] 12> 2*(1 − pbinom(k−1 , n, 1/2))[1] 0.035168.4.2 The signed-rank testThe signed-rank test is an improvement to the sign test when the population is symmetric,but not close enough to normal to use a t-test. Assume H 0 : median =m. If X i are from acontinuous distribution with density f() that is symmetric about m, then not only is X iequally likely to be on either side of m, but the distance from m is independent of theside. Thus, if we rank all the data by its distance to m, the sum corresponding to thevalues larger than m may be viewed as a random sample of a certain size from thenumbers 1 through n. The distribution of this sum can be characterized, so the sum of theranks can be an effective test statistic.The Wilcoxon signed-rank test <strong>for</strong> the medianIf the data, X 1 , X 2 , …, X n , is an i.i.d. sample from a continuous, symmetric distribution,then a significance test of the hypothesesH 0 : the median=m, H A : medianm, or median≠mcan be per<strong>for</strong>med with test statisticUnder H 0 , the distribution of T can be calculated. Large values of T support thealternative hypothsis H A : median>m.In R, the function wilcox.test() per<strong>for</strong>ms the test aswilcox.text(x, mu=..., alt="two.sided”)The data is contained in x, the null hypothesis is specified by the argument mu=, andthe alternative is specified with the argument alt=. This argument takes a value of “less”,“greater”, or “two. sided” (the default value). If desired, the distribution of T is given bythe function psignrank().A typical application of the signed-rank test is to use it after trans<strong>for</strong>ming the data tomake it look like the parent distribution is symmetric.■ Example 8.7: Number of recruits In salmon populations, there is a relationshipbetween the number of spawners and the subsequent number of “recruits” that theyproduce. A common model involves two parameters, which describe how many recruitsthere are when there are few spawners and how many there are when there are manyspawners. The data set salmon. rate (<strong>Using</strong>R) contains simulated data on one of the

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

Saved successfully!

Ooh no, something went wrong!