Exercises: Binomial Inference

  1. For males in a certain age group, the overall rate of coronary heart disease (CHD) is 10 percent. We have a sample of n=44 subjects, from the Framingham longitudinal study, who have both high cholesterol levels and high blood pressure. In this sample, 11 of the subjects have CHD.

    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).

    1. Let X be the number of CHD cases in our sample of 44 subjects. Explain briefly why it is reasonable to suppose that, if the null hypothesis were true, then X would have a Binomial(44,1/10) distribution.
    2. If we choose as the rejection region the set of values R = {0,9,10,...,44}, that is {0} on one end and {9:44} on the other, what is the significance level of the test? Why is this a reasonable choice for the rejection region for this null hypothesis?
    3. Compute the p-value for the observed data.
    4. Compute the power for the alternative hypothesis "p=1/4". Plot the power curve. For what values of p is the power at least 1/2? For what vlaues of p is the power the smallest? Why? Note: you can add a horizontal line to an existing plot with the command:
      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.
    5. Compute both the exact and approximate 95% confidence intervals for the proportion with CHD. Is the approximate confidence interval accurate enough for us to use? How can we test the null hypothesis that p=1/10 based on our confidence interval?


  2. The Shoshoni decorated their clothes and other items with small leather rectangles embroidered with beadwork. An anthropologist has collected measurements of the ratio of width to length for 20 of these decorations, and thinks that they approximate the "golden ratio" of
                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.

    1. Use the sign test to test the Null Hypothesis that the median ratio is the "golden ratio". Hint: if the median is .61803, then half the observations should be larger and half smaller than that value.
    2. What assumptions about the data are we making when we use this test?


  3. Five experiments were conducted independently by five different investigators to test the null hypothesis that a given treatment was no better than a placebo. All the experiments were well designed, randomized double-blind with pairs of subjects matched for relevant factors such as age, sex, and severity of disease. Each pair of subjects was evaluated, and a "success" was recorded if the treatment subject was responding better than the control subject within each pair. The results were:
    1. 10 successes in 15 trials.
    2. 14 successes in 22 trials.
    3. 21 successes in 38 trials.
    4. 10 successes in 18 trials.
    5. 16 successes in 25 trials.
    Note that in none of the experiments was the null hypothesis rejected at the 5% significance level. Ordinarily it is a bad idea to interpret a failure to reject the null hypothesis as proof that the null hypothesis is true. Here we have repeated failures to reject the null hypothesis. Does the repeated failure to detect a statistically significant difference provide strong evidence that the null hypothesis is in fact true? Explain your reasoning.

    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 endpoints    
    
    You 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).

  4. What is the effect of rejecting a null hypothesis?
    Imagine that we have done an experiment with n=51 trials, that is we have X ~ Binomial(51,p). Suppose we test the null hypothesis that p=.5 when the true p is .6. What is the distribution of estimates for p (ie X/n)?
    1. Do a simulation: generate 1000 replicates of the experiment:
      	Y <- rbinom(1000,51,.6)
      	     
      Each value in Y is a copy of X ~ Binomial(51,.6).
    2. Compute the average value of p-hat=X/n. In R, that's just mean(Y/51).
    3. Let your rejection region be X < 19 and X > 32. Verify that the significance level is approximately .05:
      	RR <- c(0:18,33:51)
      	sum(dbinom(RR,51,.5))
      	      
    4. Compute the average value of p-hat for cases for which we reject the null hypothesis. You can select those cases using
      	Y %in% RR
            
      Compare 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?
    5. Some people like to compute something they call "observed power", that is a power computation using the estimated paramter value after doing the experiment. Compute the power for the alternative hypothesis p=.6 (sum(dbinom(RR,51,.6)). Now compute the observed power for each replicate that rejected the null hypothesis. What is the average observed power? Plot a histogram or scatterplot to look at the distribution of observed power, conditional on rejecting H0.


  5. Bayesian Hypothesis testing: Suppose we do an experiment yielding a random variable X which has a Binomial(25,p) distribution. We wish to test the null hypothesis that p=1/2 agianst the alternative that p=9/10. We observe X=18.

    1. Compute the p-value for the null hypothesis p=.5. Does the p-value indicate that we should reject H0 in favor of the alternative?
    2. Suppose that we have reason to believe that Pr(p=.5) is .6, and Pr(p=.9) is .4. Apply Bayes' Theorem to compute the posterior probability Pr(p=.5|X=18).


Hypothesis Tests

Inference for the Binomial


Math 141 Index
Introduction to S

Albyn Jones
August 2004