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 180> res = c()> <strong>for</strong>(i in 1:1000) res[i] = mean(sample(pop,100))From the values in res we can discern intervals where we are pretty confident will be.In particular, using the quantile () function, we have these intervals <strong>for</strong> 80%, 90%, and95% of the data (see Figure 7.2):> quantile(res,c(0.1,0.9)) # 80% of the time10% 90%0.50 0.63> quantile(res,c(0.05,0.95)) # 90% of the time5% 95%0.48 0.64> quantile (res, c (0.025,0.975)) # 95% of the time2.5% 97.5%0.47 0.66Figure 7.2 Percent of values in theindicated intervalsThese suggest the following probability statements:We interpret these by envisioning picking one of the 1,000 samples at random and askingthe probability that it is in that range. This should be close to the true probability that isin the range, as we have generated many realizations ofIn this example, we know that p=0.56. Rewriting 0.50=p−0.06, <strong>for</strong> example, the firstone becomes

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

Saved successfully!

Ooh no, something went wrong!