Exercises: Binomial Inference |
We wish to test the null hypothesis that the probability of CHD in our group of 44 subjects was equal to the overall rate (1/10).
abline(h=1/2)The locator function returns the (x,y) coordinates of any point on which you click the mouse:
locator(1)Click on the point where the horizontal line hits the power curve to get its (x,y) coordinates. The x coordinate here is a value for p, the y coordinate is the corresponding power.
2/(1+sqrt(5))or about .61803. Here are the measured ratios:
.693 .654 .749 .670 .662 .615 .672 .606 .690 .668 .628 .611 .606 .601 .609 .553 .570 .576 .844 .933
If the rectangles approximated the golden ratio, then it would be plausible to suppose that the median ratio would be the golden ratio.
It may help to construct and plot the 95% confidence intervals for each experiment. After you have computed the CI's, create 3 datasets: one for the x-axis (either experiment numbers or sample sizes), one for the left endpoints of the CI's, and one for the right endpoints. For example:
N = c(15,22,38,18,25) L = c(L1,L2,L3,L4,L5) U = c(U1,U2,U3,U4,U5)where (L1,U1) was the CI for experiment 1, (L2,U2) for #2, etc.
Then
plot(N,L,ylim=c(0,1),ylab="Confidence Interval",pch=18) points(N,U,pch=18) segments(N,L,N,U) # connect the endpointsYou could also add points at the estimated proportions:
points(N,X/N,pch=19) # where X is the observed counts (10,14,21,...)and represent the null hypothesis by a horizontal line at height 1/2 with abline(h=1/2).
Y <- rbinom(1000,51,.6)Each value in Y is a copy of X ~ Binomial(51,.6).
RR <- c(0:18,33:51) sum(dbinom(RR,51,.5))
Y %in% RRCompare the average value of p-hat, given we have rejected the null hypothesis, to the overall average. Make histograms of Y and Y[Y %in% RR]. What happened?