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 224The following commands will per<strong>for</strong>m a simulation comparing the two tests on data thathas a Normal(1,2) distribution. The significance tests per<strong>for</strong>med are bothH 0 :µ=0, H A :µ>0Run the simulation. Is there a big difference between the two tests?> m = 200; n = 10> res.t = rep(0,m);res.sign = rep(0,m)> <strong>for</strong>d in 1:m) {+ x=rnorm(n, mean=1, sd=2)+ if(t.test(x,mu=0,alt = “greater")$p.value < 0.05)+ res.t[i]=1+ T = sum(x>0)+ if (1−pbinom(T−1,n,1/2) < .05)+ res.sign[i]=1+}> sum(res.t)/m # proportionrejected by t-test> sum(res.sign)/m # proportionrejected by sign-test(The notation $p. value appended to the output of t.test() retrieves just the p-value fromthe test results.)8.5 Two-sample tests of proportionIn the previous sections our tests of significance compared a sample to some assumedvalue of the population and determined whether the sample supported the null hypothesis.This assumes some specific knowledge about the population parameters. In manysituations, we’d like to compare two parameters.In this section we consider how to compare two population proportions. This can beuseful in many different contexts: comparing polling results taken over different periodsof time, surveying results after an intervention such as an advertising campaign, orcomparing attitudes among different ethnic groups.In Example 8.3, we compared the 2001 poverty rate, which was found by a sample,with the 2000 poverty rate which was known from a census. To compare the 2002 rate tothe 2001 rate, we would compare two samples. How do we handle this with asignificance test?Let be the estimated 2001 poverty rate and be the estimated 2002 poverty rate.We wish to per<strong>for</strong>m a significance test ofH 0 : p 1 =P 2 , H A :p 1

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

Saved successfully!

Ooh no, something went wrong!