12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

esult.prop result.prop2-sample test for equality of proportions with continuity correctiondata: survivorsX-squared = 24.3328, df = 1, p-value = 8.105e-07alternative hypothesis: two.sided95 percent confidence interval:-0.05400606 -0.02382527sample estimates:prop 1 prop 20.9295407 0.9684564This test report is almost identical to the one from t.test() and containsessentially the same information. At the bottom, R prints for you the proportion ofpeople who died in each group. The p-value tells you how likely it is that both theproportions are equal. So, you see that the chance of dying in a hospital after acrash is lower if you’re wearing a seat belt at the time of the crash. R also reportsthe confidence interval of the difference between the proportions.Analyzing tablesYou can use the prop.test() function for matrices and tables. Forprop.test(), these tables need to have two columns with the number of counts forthe two possible outcomes like the matrix survivors from the previous section.Testing contingency of tablesAlternatively, you can use the chisq.test() function to analyze tables with achi-squared (χ 2 ) contingency test. To do this on the matrix with the seat-belt data,you simply do the following:> chisq.test(survivors)

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

Saved successfully!

Ooh no, something went wrong!