R Cookbook by Teetor Paul
Author:Teetor, Paul [Paul Teetor]
Language: eng
Format: epub
Tags: COMPUTERS / Mathematical & Statistical Software
ISBN: 9781449307264
Publisher: O'Reilly Media
Published: 2011-03-02T16:00:00+00:00
9.12. Forming a Confidence Interval for a Proportion
Problem
You have a sample of values from a population consisting of successes and failures. Based on the sample data, you want to form a confidence interval for the population’s proportion of successes.
Solution
Use the prop.test function. Suppose the sample size is n and the sample contains x successes:
> prop.test(n, x)
The function output includes the confidence interval for p.
Discussion
I subscribe to a stock market newsletter that is well written for the most part but includes a section purporting to identify stocks that are likely to rise. It does this by looking for a certain pattern in the stock price. It recently reported, for example, that a certain stock was following the pattern. It also reported that the stock rose six times after the last nine times that pattern occurred. The writers concluded that the probability of the stock rising again was therefore 6/9 or 66.7%.
Using prop.test, we can obtain the confidence interval for the true proportion of times the stock rises after the pattern. Here, the number of observations is n = 9 and the number of successes is x = 6. The output shows a confidence interval of (0.309, 0.910) at the 95% confidence level:
> prop.test(6, 9) 1-sample proportions test with continuity correction data: 6 out of 9, null probability 0.5 X-squared = 0.4444, df = 1, p-value = 0.505 alternative hypothesis: true p is not equal to 0.5 95 percent confidence interval: 0.3091761 0.9095817 sample estimates: p 0.6666667
The writers are pretty foolish to say the probability of rising is 66.7%. They could be leading their readers into a very bad bet.
By default, prop.test calculates a confidence interval at the 95% confidence level. Use the conf.level argument for other confidence levels:
> prop.test(n, x, p, conf.level=0.99) # 99% confidence level
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12589)
Hello! Python by Anthony Briggs(9926)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9800)
The Mikado Method by Ola Ellnestam Daniel Brolund(9786)
Dependency Injection in .NET by Mark Seemann(9347)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8309)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7771)
Grails in Action by Glen Smith Peter Ledbrook(7704)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7566)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7153)
Microservices with Go by Alexander Shuiskov(6919)
Practical Design Patterns for Java Developers by Miroslav Wengner(6833)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6777)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6423)
Angular Projects - Third Edition by Aristeidis Bampakos(6195)
The Art of Crafting User Stories by The Art of Crafting User Stories(5713)
NetSuite for Consultants - Second Edition by Peter Ries(5643)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5455)
Kotlin in Action by Dmitry Jemerov(5073)
