Statistical Simulations, P-values, and Hypothesis Testing

Introduction to Statistical Simulations

  • Understanding simulations provides a foundation for grasping complex statistical concepts such as zz     statistics, pp-values, and general hypothesis testing.
  • Simulations allow for the estimation of the standard error and distribution of a test statistic without solely relying on complex formulas.

Hyperemesis Gravidarum (HG) and Preterm Delivery

  • Condition Overview: Hyperemesis Gravidarum (HG) is a rare pregnancy condition affecting approximately 1%1\% of pregnant women. It is characterized by severe nausea and vomiting, leading to a loss of at least 5%5\% of body weight instead of the expected weight gain.
  • Background Statistics: In the general population, the rate of preterm delivery is 10%10\%.
  • Sample Data: In a specific study on women with HG, the sample size was n=254n = 254. The observed preterm delivery rate in this sample was 15.34%15.34\%.
  • The Statistical Question: Is the observed rate of 15.34%15.34\% statistically significantly higher than the population rate of 10%10\%?

Key Statistical Parameters and Statistics

  • Statistic (phatp_{hat}): Any property of a sample is considered a statistic or random variable. It is often denoted by a Roman letter with a "hat" to signifies it is an estimate.
    • In this study, phat=0.1534p_{hat} = 0.1534.
    • This is the best estimate of the proportion of all women with HG who deliver preterm based on the sample.
  • Parameter (π\pi): A parameter represents the true value within the entire population.
    • Under the null hypothesis (H0H_0), it is assumed there is no relationship between HG and preterm delivery, meaning the population proportion (π\pi) for women with HG is the same as the general population: π=0.10\pi = 0.10.
  • Quantity of Interest: The difference between the observed statistic and the expected parameter.
    • 0.15340.10=0.05340.1534 - 0.10 = 0.0534 (or 5.34%5.34\%).
    • The goal is to determine if this difference of 5.34%5.34\% is larger than what would be expected to occur by chance alone under the null hypothesis.

Standard Deviation (SD) vs. Standard Error (SE)

  • Standard Deviation (SD): A measure of how much individual numbers in a dataset typically differ from their mean. It describes the spread of observations.
  • Standard Error (SE): Specifically refers to the standard deviation of a statistic (e.g., the standard deviation of the difference 5.34%5.34\%).
    • The SE measures how much a statistic would typically vary from one sample to another if the study were repeated many times.
    • While SD is an operation applied to any set of numbers, SE is a special case of SD applied to a distribution of summary statistics.

Simulating the Null Hypothesis in R

  • To estimate the SE and visualize the distribution under the null hypothesis, a computer can simulate thousands of samples of size n=254n = 254 where each person has a 10%10\% chance of preterm delivery.
  • The RUNIF Function: Generates pseudo-random numbers uniformly distributed between 0 and 1.
  • Process:
    1. Generate 254 random numbers: runif(254).
    2. Evaluate if numbers are <0.1< 0.1 (True if preterm, False if not).
    3. Store as a vector where True = 1 and False = 0.
    4. The mean of this vector represents the proportion (phatp_{hat}) of preterm births for that specific simulation.
  • Large-Scale Simulation: Performing this 10,00010,000 times creates a distribution of simulated proportions centered at 10%10\%.
  • Calculating SE via Formula:     SE=π×(1π)nSE = \sqrt{\frac{\pi \times (1 - \pi)}{n}}
    • Using the HG data: 0.10×0.902540.01882\sqrt{\frac{0.10 \times 0.90}{254}} \approx 0.01882.
    • Simulations of 10,00010,000 runs yielded an estimated SE of 0.018850.01885, demonstrating that simulations and formulas provide nearly identical results.

Understanding the pp-value

  • Definition: The pp-value is the probability, assuming the null hypothesis is true, of observing a test statistic as extreme or more extreme than the one actually observed.
  • The "As Extreme or More Extreme" Convention: Statistics does not calculate the probability of the exact observed value because that probability is often very low even for typical results.
    • Example: In 400400 coin flips, getting exactly 201201 heads has a probability of only 3.97%3.97\%, even though it is a very typical result for a fair coin.
    • By looking at the "tail" (everything as extreme or more), we get a meaningful measure of compatibility with the null hypothesis.
  • Guidelines for Interpretation:
    • p>0.10p > 0.10: Weak or no evidence against the null hypothesis.
    • 0.05<p<0.100.05 < p < 0.10: Moderate evidence (gray area).
    • 0.01<p<0.050.01 < p < 0.05: Strong evidence against the null; result is statistically significant; reject the null.
    • p<0.01p < 0.01: Very strong evidence; highly significant; reject the null.
  • HG Example Result: In the simulations, only 5151 out of 10,00010,000 samples were as extreme as the observed 15.34%15.34\%. The pp-value is approximately 0.51%0.51\%, indicating the result is highly significant.

Case Study: St. George’s Hospital Heart Transplants

  • The Incident: In 2004, mortality spiked at St. George’s Hospital in London. Out of the last 1010 heart transplants, 88 patients died within 30 days.
  • Comparison: The national mortality rate for this procedure is 15%15\%.
  • Variables:
    • Observational Unit: Each individual heart transplant.
    • Variable: Survival vs. Death (binary).
    • Parameter (π\pi): The long-term frequency of death at St. George's.
    • Statistic (phatp_{hat}): 0.800.80 (8/108/10).
  • Hypotheses:
    • H0H_0: π=0.15\pi = 0.15 (St. George's is identical to the national average).
    • HaH_a: π>0.15\pi > 0.15 (One-sided: mortality is significantly higher).
  • Simulation Results: In 1,0001,000 simulations where π=0.15\pi = 0.15, the maximum simulated death rate was 60%60\%. The probability of observing 80%80\% was 00. This is a pp-value of 00, providing overwhelming evidence to reject the null hypothesis.
  • Extended Dataset: Researchers looked at the previous 361361 transplants and found 7171 deaths (19.67%19.67\%).
    • Comparing 19.67%19.67\% to the national 15%15\%.
    • SE for this larger sample was 0.0180.018.
    • pp-value: 0.0030.003 (0.3%0.3\%). Even though the effect size decreased, the large sample size maintained strong evidence against the null.

Standardized Statistics (zz-Statistics)

  • Definition: The number of standard errors an observed statistic is above or below the mean of the null distribution.
  • Formula:     z=Observed StatisticMean of Null DistributionStandard Errorz = \frac{\text{Observed Statistic} - \text{Mean of Null Distribution}}{\text{Standard Error}}
  • Null Mean: Usually the value hypothesized in the null (e.g., 0.150.15 or 0.100.10).
  • Cut-off Value: Traditionally, a zz-statistic outside of the range [2,2][-2, 2] indicates strong evidence against the null.
    • Note: The precise mathematical cut-off for a 5%5\% significance level is actually 1.961.96.
  • Comparison of Heart Transplant Data:
    • Small sample (8/108/10): z=5.75z = 5.75.
    • Large sample (71/36171/361): z=2.61z = 2.61.
    • Both are greater than 22, but the first dataset shows even stronger evidentiary weight.

Case Study: Predicting Elections from Faces

  • Research Premise: Can voters predict election results based purely on candidate appearance?
  • Methodology: Participants were shown photos of two candidates and asked who looked more "competent."
  • Data: In the 2004 Senate races, the panel correctly identified the winner in 2323 out of 3232 races (71.9%71.9\%).
  • Testing Parameters:
    • H0H_0: π=0.50\pi = 0.50 (Random guessing).
    • HaH_a: π>0.50\pi > 0.50 (Faces have predictive power).
  • Results:
    • SE from simulation: 0.090.09.
    • zz-statistic: 2.432.43.
    • pp-value: 0.0090.009 (below 1%1\%).
    • Conclusion: Reject the null hypothesis; appearance has a statistically significant relationship with election outcomes.

Factors Influencing Strength of Evidence

  1. Effect Size: The magnitude of the difference between the observed statistic and the null hypothesis. Larger differences (e.g., 80%80\% vs 15%15\%) provide stronger evidence.
  2. Sample Size (nn): As sample size increases, the variability (Standard Error) decreases.
    • A smaller spread makes it harder for high differences to occur by chance.
    • With a larger nn, even a small effect size can be statistically significant.
  3. One-sided vs. Two-sided Tests:
    • One-sided tests only look for a difference in one direction.
    • Two-sided tests are more conservative and standard in research.
    • Switching from a one-sided to a two-sided test generally doubles the pp-value.

Experimental Design: Fluoxetine and Fibromyalgia

  • Terminology:
    • Placebo: An inactive substance (e.g., sugar pill) given to a control group.
    • Blinded: Participants do not know if they received the drug or the placebo.
    • Double-Blind: Neither the patients nor the clinicians evaluating the outcome know which group a subject belongs to. This prevents observer bias.
  • Study Overview: 4242 women were randomized to receive either 20mg20\,mg of Fluoxetine (Prozac) or a placebo.
  • Findings:
    • Placebo group showed improved self-rated anxiety at three weeks (possibly due to the placebo effect).
    • Fluoxetine group: Improvement in Beck Depression Scale was not significant (p=0.34p = 0.34).
    • At six weeks, sleep quality improvement was noted with a pp-value of 0.030.03.

Questions & Discussion

  • Direct Message (DM): What does the runif code do?
    • runif(254) generates 254254 independent random numbers between 00 and 11 that are uniformly spread.
  • DM: Is π\pi the same as pp-hat?
    • No. phatp_{hat} is the proportion in the specific sample (15.34%15.34\%). π\pi is the hypothetical population proportion under the null (10%10\%). The pp-value is the probability of the result given π\pi.
  • DM: Will we use R in exams?
    • No. Exam questions will not include R code. Simulation data and results will be provided where necessary.
  • DM: What is the difference between SD and SE?
    • SD is a general measure of spread for any list of numbers. SE is a special case of SD specifically applied to the distribution of a test statistic across repeated samples or simulations.
  • DM: What do the y-axis values on a histogram represent?
    • They represent frequency (how many times a result occurred) or the proportion of times a result occurred within the total number of simulations.
  • Direct Message (DM): Is the simulation repeating the sample or testing one sample of 1,000?
    • It is repeating the 10-observation (or whatever sample size) study 1,000 different times to see the variety of possible outcomes under the null hypothesis.