Fitting probability models to frequency data
Review - proportions Data: discrete nominal variable with two states (“success” and “failure”) You can do two things: –Estimate a parameter with confidence interval –Test a hypothesis
Estimating a proportion
Confidence interval for a proportion* where Z = 1.96 for a 95% confidence interval * The Agresti-Couli method
Hypothesis testing Want to know something about a population Take a sample from that population Measure the sample What would you expect the sample to look like under the null hypothesis? Compare the actual sample to this expectation
weird not so weird
Sample Test statistic Null hypothesis Null distribution compare How unusual is this test statistic? P < 0.05 P > 0.05 Reject H o Fail to reject H o
Binomial test
Test statistic For the binomial test, the test statistic is the number of successes
Binomial test
The binomial distribution
Binomial distribution, n = 20, p = 0.5 x
x Test statistic
P-value P-value - the probability of obtaining the data* if the null hypothesis were true *as great or greater difference from the null hypothesis
P-value Add up the probabilities from the null distribution Start at the test statistic, and go towards the tail Multiply by 2 = two tailed test
Binomial distribution, n = 20, p = 0.5 x P = 2*(Pr[16]+Pr[17]+Pr[18] +Pr[19]+Pr[20])
Sample Test statistic Null hypothesis Null distribution compare How unusual is this test statistic? P < 0.05 P > 0.05 Reject H o Fail to reject H o
N =20, p 0 =0.5 This is a pain….
Calculating P-values By hand Use computer software like jmp, excel Use tables
Sample Test statistic Null hypothesis Null distribution compare How unusual is this test statistic? P < 0.05 P > 0.05 Reject H o Fail to reject H o
Discrete distribution A probability distribution describing a discrete numerical random variable
Discrete distribution A probability distribution describing a discrete numerical random variable Examples: –Number of heads from 10 flips of a coin –Number of flowers in a square meter –Number of disease outbreaks in a year
2 Goodness-of-fit test Compares counts to a discrete probability distribution
Hypotheses for 2 test
Test statistic for 2 test
Hypotheses for day of birth example
DaySun.Mon.Tues.WedThu.Fri.Sat.Total Obs Exp
The calculation for Sunday
The sampling distribution of 2 by simulation Frequency 22
Sampling distribution of 2 by the 2 distribution
Degrees of freedom The number of degrees of freedom specifies which of a family of distributions to use as the sampling distribution
Degrees of freedom for 2 test df = Number of categories (Number of parameters estimated from the data)
Degrees of freedom for day of birth df = = 6
Finding the P-value
Critical value The value of the test statistic where P = .
12.59
P<0.05, so we can reject the null hypothesis Babies in the US are not born randomly with respect to the day of the week.
Assumptions of 2 test No more than 20% of categories have Expected<5 No category with Expected 1
2 test as approximation of binomial test If the number of data points is large, then a 2 goodness-of-fit test can be used in place of a binomial test. See text for an example.
The Poisson distribution Another discrete probability distribution Describes the number of successes in blocks of time or space, when successes happen independently of each other and occur with equal probability at every point in time or space
Poisson distribution
Example: Number of goals per side in World Cup Soccer Q: Is the outcome of a soccer game (at this level) random? In other words, is the number of goals per team distributed as expected by pure chance?
World Cup 2002 scores
Number of goals for a team (World Cup 2002)
What’s the mean, ?
Poisson with = 1.26 XPr[X] 88 0
Finding the Expected XPr[X]Expected 8 } Too small!
Calculating 2 XExpectedObserved
Degrees of freedom for poisson df = Number of categories (Number of parameters estimated from the data)
Degrees of freedom for poisson df = Number of categories (Number of parameters estimated from the data) Estimated one parameter,
Degrees of freedom for poisson df = Number of categories (Number of parameters estimated from the data) = = 3
Critical value
Comparing 2 to the critical value So we cannot reject the null hypothesis. There is no evidence that the score of a World Cup Soccer game is not Poisson distributed.