Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Statistical Inference: Hypothesis Testing and Confidence Intervals - Prof. Kobi Abayomi, Study notes of Data Analysis & Statistical Methods

Various methods for statistical inference, including hypothesis testing and confidence intervals. Topics include testing for population means, the chi-square test for goodness of fit, the t-distribution, and tests for differences in proportions and variances. The document also includes examples and calculations using r.

Typology: Study notes

Pre 2010

Uploaded on 08/04/2009

koofers-user-7q0-2
koofers-user-7q0-2 🇺🇸

10 documents

1 / 12

Toggle sidebar

Related documents


Partial preview of the text

Download Statistical Inference: Hypothesis Testing and Confidence Intervals - Prof. Kobi Abayomi and more Study notes Data Analysis & Statistical Methods in PDF only on Docsity! ISYE 2028 A and B Lecture 12 Confidence Intervals and Hypothesis Testing ’cont. Dr. Kobi Abayomi March 25, 2009 We have looked at hypothesis testing generally, but we have used only the specific example of a test for the population mean. For instance, if X ∼ µ, σ2 is a random variable [model], and we collect some data x = ∑n i xi. Then, the hypotheses H0 : µ = µ0 vs. Ha : µ 6= µ0 we use in a two sided test of the population mean. You will recall that we use the sampling distribution x ∼ N(µ, σ2/n) to construct the test statistic: Z = x− µ0√ σ2/n which has the standard normal distribution N(0, 1). This setup is often sufficient: the Z statistic is the deviation of the data from the null hypothesis, over its standard deviation. In words: Z ≡ obs− exp S.D(obs) is the statistic we want to use if we want to test the proportion of people who vote for Pedro, the mean income of Njoroge’s in Kisumu, if the sample mean is representative of our population mean. 1 Situations often arise where the sample mean cannot sufficiently describe, or test for, im- portant hypothetical differences in populations. We must appeal to other distributions, to other quantifications of difference, to test other hypothesis. A useful alternative is... 1 The Chi Squared Distribution and associated Hy- potheses Tests Recall this example from Lecture 10: Say we are interested in the fairness of a die. Here is the observed distribution after 120 tosses: Die Face 1 2 3 4 5 6 Obs. Count 30 17 15 23 24 21 The appropriate test statistic here is the Chi-square. 1.1 The Chi-Square test for Goodness of Fit Formally, here, we are going to test H0 : The die is fair vs. Ha : The die is not fair In general the hypotheses tests are H0 : πi = ni n , for all i vs. Ha : πi 6= ni n , for at least 1 i Remember here, our observed test statistic is χ2o = (25−20)2 20 + · · · + (16−20) 2 20 = 18.00. The number of degrees of freedom n − 1, here 6 − 1 = 5. Notice that the total number of 2 2.1 Scenario 1: Two sample proportions Say we wish to gain inference on the support for election reform in California and Georgia. Let p1 ≡ the proportion who support in Georgia and p2 ≡ the proportion who support in California. We estimate these, in the usual way, p̂1 = x1 n1 , p̂2 = x2 n2 : the sample proportions of voters who supported the reform over total voters, for each state. We know from the sampling distribution of p̂: E(p̂1) = p1, E(p̂2) = p2 and V ar(p̂1) = p1q1 n1 , V ar(p̂2) = p2q2 n2 . The difference p1 − p2 is distributed: p1 − p2 ∼ N(p1 − p2, p1q1 n1 + p2q2 n2 ) This is the sampling distribution for the difference in proportions. The appropriate rescaled statistic is: Z = p̂1 − p̂2 − (p1 − p2) S.D.(p̂1 − p̂2) and it will have a standard normal distribution. Thus, a confidence interval for the difference in two proportions is: p̂1 − p̂2 ± Zα/2 √ p̂1q̂1 n1 + p̂2q̂2 n2 For the two tailed hypothesis test H0 : p1 = p2 vs. p1 6= p2 we exploit the fact p1 = p2 implies p1 − p2 = 0 and write p̂pooled = p̂p = x1 + x2 n1 + n2 to pool the estimate of the population proportion, since, under the null, here, p1 = p2. Then our test statistic is 5 zo = p̂1 − p̂2√ p̂pq̂p( 1 n1 + 1 n2 ) 2.2 Scenario 2: Two samples, in general In general if we have data coming from two samples X1 ∼ µ, s12 and X2 ∼ µ, s22 and we cannot assume knowledge of the variances we get a sampling distribution for the difference in the population mean µ1 − µ2 as x1 − x2 ∼ µ1 − µ2, s1 2 n1 + s2 2 n2 which we approximate with a t-distribution with n1 + n2 − 2 degrees of freedom.2 Thus the confidence interval is x1 − x2 ± tα/2,n1+n2−2 ∗ √ s12 n1 + s22 n2 The two sided hypotheses test for differences in the population mean H0 : µ1 − µ2 = ∆0 vs. Ha : µ1 − µ2 6= ∆0 would use this test statistic: t0 = x1 − x2 −∆0√ s12 n1 + s2 2 n2 Of course one sided tests are the usual variations on this. If you are willing to assume that s1 = s2 then you can pool the variance estimates with Sp 2 = (n1 − 1)s12 + (n2 − 1)s22 n1 + n2 − 2 and use this test statistic: 2The exact calculation for degrees of freedom here is more involved. Using n1 + n2 − 2 is good 6 t0 = x1 − x2 −∆0√ Sp 2( 1 n1 + 1 n2 ) 2.3 Scenario 3: Two samples, ”dependent” In many cases it is not reasonable to assume that your two samples have arrived indepen- dently. We call data paired when it is natural to think of each sample as bivariate. Like errors while playing piano with the right hand versus the left hand. In these cases, we believe that the samples come from one element, perhaps, but two separate samplings. Let D = X1 −X2 thus di = xi1 − xi2 and D = (X11 −X12) + · · ·+ (Xn1 −Xn2) n Here we have taken the differences in each observation, and then computed the average difference. A sampling distribution for D is D ∼ µ1 − µ2, SD2/n where SD 2 = 1 n− 1 n∑ i (di − d) We again approximate with the t-distribution. Here the degrees of freedom are the number of pairs minus 1 df = n− 1 The confidence interval for paired differences of the population mean is then: 7 ( s22F1−α/2,ν1,ν2 s21 , s22Fα/2,ν1,ν2 s21 ) (5) as a 1− α percent confidence interval for the ratio σ22/σ21. 4 R example continued from lecture 11 4.1 part b Here we are comparing costs of accidents in the non-ABS year 1991 and the ABS year 1992. We can treat the cost as a continuous non-proportion variable. Remember the data from lecture 4. A hypothesis test: H0 : ∆µ = µNoABS − µABS = 0 vs. H1 : ∆µ = µNoABS − µABS > 0 The variances are unknown - so we know we need to use a t-test. But can we assume they are equal and use a pooled variance estimator? First things first: this data has missing values: mean(data) #Cost1991 Cost1992 2074.952 NA #we could also use data[37:42,] mean(data,na.rm=T) #Cost1991 Cost1992 2074.952 1714.474 #here we have removed the missing values 10 # var(data,na.rm=T) #Cost1991 Cost1992 Cost1991 441529.218 #-7008.193 Cost1992 -7008.193 390409.445 #this is the covariance matrix, for now we only need the diagonal #elements We should do an F-test for equality of variances (I’ll skip the hypothesis notation for this intermediate test) to know which form of the t-test to apply. > data[1,1]/data[2,2] [1] 1.233898 #our observed value of the f-statistic pf(data[1,1]/data[2,2],41,37,lower.tail=FALSE) [1] 0.2597970 #the p-value for our (inherently) two tailed test We can assume that the variances are equal, so our test statistic is: t = (xNoABS − xABS)− 0√ s2p(n −1 NoABS + n −1 ABS) where s2p = (n1 − 1)s21 + (n2 − 1)s22 n1 + n2 − 2 The calculations in R: > mean(data[,1],na.rm=T)-mean(data[,2],na.rm=T) [1] 360.4787 %the difference in the sample means > s1squared<-var(data,na.rm=T)[1,1] > s2squared<-var(data,na.rm=T)[2,2] > spsquared<-((42-1)*s1squared +(38-1)*s2squared)/(42+38-2) > spsquared 11 [1] 417280.1 %the sample variances, and pooled sample variance > tstat<-(mean(data[,1],na.rm=T)-mean(data[,2],na.rm=T))/sqrt(spsquared*(1/42 +1/38)) > tstat [1] 2.492512 %the calculated value for the t-statistic > pt(2.49,df=(42+38-2),lower.tail=FALSE) [1] 0.007450517 % the p-value for the observed t-statistic The difference in sample variation between non-ABS and ABS equipped cars was statistically insignificant at the .05 level. A test for equality of means of cost of repairs was statistically significant at the same level - we reject the null hypothesis. Translated into the narrative: There is enough evidence at the .05 level to conclude that the cost of repairs for non-ABS equipped cars is higher than that of ABS cars. We could perhaps conjecture that ABS equipped cars help the driver lessen the severity of an accident. 4.2 part c In R the confidence limits are: > mean(data[,1],na.rm=T)-mean(data[,2],na.rm=T)-qt(.975,(42+38-2)) *sqrt(spsquared*(1/42 +1/38)) [1] 72.5531 > mean(data[,1],na.rm=T)-mean(data[,2],na.rm=T)+qt(.975,(42+38-2)) *sqrt(spsquared*(1/42 +1/38)) [1] 648.4043 5 Exercises • Look at the chart on page 351. I wouldn’t commit it to memory (you can always derive the appropriate test statistics by reasoning!)- it is a nice summary though. • Do exercises 10.30, 10.35, 10.42, 10.52 on pages 358-361/ • Do exercise 10.72(b), Do exercise 10.67. Both on page 370. • Do exercise 10.73 on page 370. • Exercises 10.79, 10.83, 10.90, 10.93 on page 383-384. • Exercises 10.106-10.109 on page 386. 12
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved