To pass this information to prop.test, we now need x to have two entries (the number of “successes” in 20) and n also needs to have two entries (the sample size in each group). For example, to find a 95% CI for the difference in proportion Sheffield sites with robin song in 2005 vs 2006, we can examine the data: tally(~DaySong | Year, data=robins) # Year It is possible to compute a CI for a difference in two proportions using prop.test with summary information. Since the p-value is large, we can not reject \(H_0\) - based on these data it is reasonable to believe that elephant density is high in no more than half of sites. # alternative hypothesis: true p is greater than 0.5 Note we can now leave out conf.level as we are trying to obtain a p-value, not a CI. alternative, which can be either ‘two.sided’ (the default if you leave this input out), ‘greater’ (one-sided test with \(>\)), or ‘less’ (one-sided test with \(p, the null hypothesis proportion (here 0.5).To carry out the test with prop.test, we need to specify just two more input arguments: \ \ The sample data indicate: tally(~HighDensity, data=elephants) # HighDensity Imagine Tanzania set a goal to keep elephant density low at at least half of sites is this goal being met?Let \(p\) be the proportion sites with HighDensity TRUE in Tanzania we want to test: Some elephant management plans have set a goal to keep elephant density low (less than 1 animal per \(km^2\)) to prevent vegetation damage and habitat change. To carry out a test instead of computing a CI, we just have to specify our hypotheses. We are 99% confident that the true proportion elephant survey sites that are protected is between 0.378 and 0.767. # alternative hypothesis: true p is not equal to 0.5 # 1-sample proportions test with continuity correction This input is optional if you leave it out, it will default to 0.95.įor example, prop.test(x=24, n=41, conf.level=0.99) # conf.level, the desired confidence level as a proportion (so for 95% confidence, we would use conf.level=0.95).Here we consider a “success” a site that is protected, so there are 24 such sites We need to provide 2 or 3 inputs to prop.test() to obtain a CI: What if we want to use prop.test() to find a confidence interval for the proportion elephant survey sites that are protected, using the summary information we just computed? tally(~Protected, data=elephants) # Protected
0 Comments
Leave a Reply. |