Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Psychometrics wikipedia , lookup
Sufficient statistic wikipedia , lookup
Foundations of statistics wikipedia , lookup
Confidence interval wikipedia , lookup
Bootstrapping (statistics) wikipedia , lookup
Degrees of freedom (statistics) wikipedia , lookup
Taylor's law wikipedia , lookup
Statistical hypothesis testing wikipedia , lookup
Omnibus test wikipedia , lookup
Misuse of statistics wikipedia , lookup
Sample Size Needed to Achieve High Confidence (Means) Considering estimating X, how many observations n are needed to obtain a 95% confidence interval for a particular error tolerance? The error tolerance E is ½ the width of the confidence interval Here, is a conservative (high) estimate of the true std dev X, often gotten by doing a preliminary small sample 1.960 can be adjusted to get different confidences Derivation of Formula • E = z * std. error = z * sigma/sqrt(n) • Thus, sqrt(n) = z * sigma/E • So, n = [z * sigma/E] 2 Sample Size Needed to Achieve High Confidence (Proportions) Considering estimating pX, how many observations n are needed to obtain a 95% confidence interval for a particular error tolerance? The error tolerance E is ½ the width of the confidence interval Here, p is a conservative (closer to 0.5) estimate of the true population proportion pX, often gotten by doing a preliminary small sample 1.960 can be adjusted to get different confidences Derivation • E = z * std. error • But now, std error = sqrt[p(1-p)/n], so • E = z * sqrt[p(1-p)]/sqrt(n), and hence • Sqrt(n) = z * sqrt[p(1-p)]/E, • => n = [z *sqrt[p(1-p)]/E]2 Election Polling Example: 1500 prospective voters are surveyed. 825 say they will vote for candidate A and 675 say they will vote for B. What is your estimate of the percentage of voters who will vote for A? Construct a 95% confidence interval. ˆ 825 0.55 1500 To construct the confidence interval, use the normal approximation. 0.551 0.55 1500 0.0128 NORMINV(0.975,0.55,0.0128) = 0.575 The associated confidence interval is, therefore, 55% 2.5%. The newsmedia would report this result by stating: “The poll has a margin of error of plus or minus 2.5 percentage points”. What would happen if the 55% estimate were based on a sample of size 750? 0.551 0.55 750 0.0182 NORMINV(0.975,0.55,0.0182) = 0.586 The associated confidence interval is, therefore, 55% 3.6%. Coke vs. Pepsi Example From a sample of 500, the number who say they prefer Coke to Pepsi is 275. Your estimate of the population proportion who prefer Coke is 275/500 = 55%. Since n is large, we can apply the CLT and construct a confidence interval for the population proportion, p: ˆ Z ˆ 1 ˆ 1 2 n provides a (1-)100% confidence interval for the population proportion, p. For a 95% interval in this case, we would first determine that NORMSINV(0.975) = 1.96. We would then compute: 0.55 1.96 0.551 0.55 0.55 0.0436. 500 Hypothesis Testing • Formulate null hypothesis (action is associated with alternative) • Compute Test Statistic • Determine Acceptance Region Heart Valve Example • Original yield = 52% • Change Process (Sort in batches of 5) • Sample 100 assemblies: sample yield = 79% Heart Valve Example: Formulate Null Hypothesis • Null Hypothesis: the true process yield is 52% or less ------ Why????? • Note: Action would be associated with the alternative----adopt new process only if it really increases the yield. Heart Valve Example: Compute Test Statistic • We will use the Normal Approximation: (how many standard deviations to the right of .52 is .79?) ˆ z p (1 p ) .52(1 .52) .04996 n 100 .79 .52 .27 5.404 ˆ .04996 Heart Valve Example: Determine Acceptance Region Suppose we want to set the probability of rejecting the null hypothesis given that it is true (type 1 error) = 0.0001 Compute Z = normsinv(.9999) = 3.71947 Reject the null hypothesis if: Test statistic > 3.71947 Normal Distribution -8.00 -6.00 -4.00 -2.00 0.00 2.00 Values of Random Variable X 4.00 6.00 8.00 Heart Valve Example: conclusion • Test statistic = 5.404 • Reject null hypothesis if test statistic > 3.71947 • We should REJECT the null hypothesis Example: 2-Tailed Test on a Single Mean An auto manufacturer has an old engine that produces an average of 31.5 mpg. A new engine is believed to have the same standard deviation in mpg, 6.6, as the old engine, but it is unknown whether or not the new engine has the same average mpg. The sample mean of a random sample of 100 turns out to be 29.8. Let = 0.05. Solution: 1. Formulate Hypothesis: H0: = 31.5, H1: 31.5 2. Compute Test Statistic: z x 0 29 .8 31.5 2 .576 n 6 .6 100 3. Determine Acceptance Region: Fail to reject if NORMSINV(/2) z NORMSINV(1-/2) NORMSINV(0.025) -2.576 NORMSINV( 0.0975) -1.959 -2.576 1.959 Since the inequality fails to hold, we Reject Null Hypothesis! Our test statistic lies 2.576 standard deviations to the left of the mean of the sampling distribution. If the null hypothesis were true, we would expect to observe a test statistic this low (or lower) only about 0.4998% of the time---less than 1/2 of 1 percent. T-test Used when , the standard deviation of the underlying population is unknown. Instead of forming the test statistic with , we substitute an estimate for , namely the sample deviation: n xi x 2 S i 1 . n 1 The resulting test statistic is: t x 0 . S n T-Test The test statistic, t, has a t distribution with n-1 degrees of freedom. In comparison, the test statistic, z, formed using the population standard deviation, , has a normal distribution . The t distribution is shaped like the standard normal distribution (eg. bell-shaped. but more spread out). Its mean is 0, and its variance (whenever degrees of freedom > 2) is df/(df-2). As n (and hence df) increases, the variance approaches 1 & the t distribution approaches the standard normal distribution. When n is large, the z test is sometimes substituted (as a close approximation) for the t test. Assumptions: Either n is large enough for the central limit theorem to hold or the underlying distribution is normal. T-test & EXCEL Suppose t has a t distribution with n-1 degrees of freedom. We define t1 2 ,n 1 to be the number satisfying: P t t1 2 ,n 1 1 2 . That is, the area under the t distribution (probability) to the left of t1 2 ,n 1 is 1-/2. Note: This is the exact analogue of Z 1 2 for the standard normal distribution. To calculate the value for t1 2 ,n 1 in EXCEL, you use the TINV function: t1 2 ,n 1 TINV ( , n 1). EXAMPLE: 1-Tailed t-Test Average weekly earnings of full time employees is reported to be $344. You believe this value is too low. A random sample of 1200 employees yields a sample mean of $361 and a sample deviation of $110. Formulate the appropriate null hypothesis and analyze the data: 1. Formulate Null Hypothesis: H0: < 344, H1: > 344 2. Compute Test Statistic: t x 0 361 344 3 .353612 S n 110 1200 3. Analysis: This is an extreme value for the test statistic, more than 3 standard deviations away from the mean (if the null hypotheis were true). For = 0.001, we can calculate: t1 TINV (2 ,1199 ) TINV 0 .002 ,1199 3 .097084 . Since our test statistic is even larger, we would reject the null hypothesis at the 99.9% significance level. The p-value associated with our test statistic is given by: p-value = TDIST(3.353612, 1199, 1) = 0.000411. Thus, if the null hypothesis were true, the probability of obtaining a test statistic as large (or larger) than 3.353612 is only 0.0411%. Average weekly earnings are almost certainly larger than $344. p-Values Definition: The p-value is the smallest level of significance, , for which a null hypothesis may be rejected using the obtained value of the test statistic. The p-value is the probability of obtaining a value of the test statistic as extreme, or more extreme than, the actual test statistic, when the null hypothesis is true. Example: Your z-statistic in a z-test is 3.162. To calculate the p-value, use the EXCEL function NORMSDIST. NORMSDIST(z) is the probability of obtaining a test statistic value less than or equal to z. To be more extreme, the test statistic would have to be larger than 3.162. Thus, p-value = 1-NORMSDIST(3.162) = 10.999216 = 0.000784 Example: Your z-statistic in a z-test is -0.4. To be more extreme, the test statistic would have to be less than -0.4. Thus, p-value = NORMSDIST(-0.4) = 0.3446 Example: Your t-statistic in a t test with 15 degrees of freedom is 4.56. To calculate the p-value use the EXCEL function TDIST. TDIST(t,n-1,1) = P{test statistic value > t | null hypothesis true}. (Note the different direction of the inequality!) Hence p-value = TDIST(4.56,15,1) = 0.000188 Rules of Thumb for p-values p-value < 0.01 interpretation very significant between 0.01 & 0.05 significant between 0.05 & 0.1 marginally significant > 0.1 not significant Two-Sample Tests for Means • Used when we wish to compare the means of two populations when both means are unknown • Tools => Data Analysis => two sample test • See Two Sample Spreadsheet Two Sample Tests • Z-test: two sample for means – when std. deviations are known for both distributions • T-test: two sample assuming equal variances • T-test: two sample assuming unequal variances Usually just use unequal variance test 1.5 1.5 1.5 0.5 0.5 0.5 2.5 2.5 2.5 1.5 1.5 1.5 See spreadsheet "two sample.xls" hypothesized difference (b column - a column) = 0 Variable 1 Variable 2 Mean 1 2 Variance 0.1875 0.1875 Observations 9 9 Hypothesized Mean Difference 0 df 16 Would we reject or t Stat -4.898979486 fail to reject hypothesis P(T<=t) one-tail 8.02671E-05 that difference = 0????? t Critical one-tail 1.745884219 P(T<=t) two-tail 0.000160534 t Critical two-tail 2.119904821 t-Test: Two-Sample Assuming Unequal Variances hypothesized difference (b column - a column) = +1 Variable 1 Variable 2 Mean 2 1 Variance 0.1875 0.1875 Observations 9 9 Hypothesized Mean Difference 1 df 16 t Stat 0 P(T<=t) one-tail 0.5 t Critical one-tail 1.745884219 P(T<=t) two-tail 1 t Critical two-tail 2.119904821 Chi-Square Tests Like the T-distribution, the chi-square distribution is defined by its number of degrees of freedom. A chi-square random variable with k degrees of freedom is normally 2 denoted by the symbol k , and is defined by the equation: k k2 i2 , i 1 That is, the sum of the squares of k standard normal random variables. Since squares are always non-negative, so is their sum, and hence a chi-square random variable can only take on non-negative values. Illustrations of the PDF for 1 and 5 degrees of freedom are shown below. Probability Density Function for the Chi-Sq Distribution 1 0.050 3.841 30 25 20 15 10 5 0 Degrees of Freedom: P-Value: Chi-Sq Critical Value: Probability Density Function for the Chi-Sq Distribution 5 0.050 11.070 30 25 20 15 10 5 0 Degrees of Freedom: P-Value: Chi-Sq Critical Value: Values for the chi-square distribution can be referenced using the EXCEL functions CHIDIST and CHIINV. CHIDIST(x, k) gives the probability that a chisquare random variable with k degrees of freedom attains a value greater than or equal to x. In other words, the area under the PDF to the right of x. In the pictures above, this is reported as the p-value. CHIINV(p, k) gives the inverse, or critical value. That is, if p = CHIDIST(x, k), then CHIINV(p, k) = x. In the pictures above, this is reported as the chisq critical value. Examples: CHIDIST(5,5) = 0.41588 CHIDIST(25,5) = 0.00139 CHIINV(0.41588, 5) = 5 CHIINV(0.00139, 5) = 25 Test for Population Variance Sometimes it is of interest to draw inferences about the population variance. The distribution used is the chisquare distribution with n-1 degrees of freedom (where n = sample size), and the test statistic is given by: 2 n 1s 2 02 , where s2 is the sample variance and the denominator is the value of the variance stated in the null hypothesis. Example: Heart Valves. Without any sorting, the clearance was normally distributed with mean of 0.005 and standard deviation of 0.000283 (which implies a variance of 8 * 10-8). One key indicator of process improvement is whether or not process variability has been reduced. In this case, we would look to see if the variance of the clearance dimension has been reduced by sorting. Heart Valve Example Continued The null hypothesis in this case is that the variance has not been reduced: H0: s2 8 * 10 -8 Suppose that a random sample of size 50 (after sorting is implemented) yields a sample variance of : 2.308 * 10-9 Computing the test statistic yields: 2 n 1s 02 2 49 2.308 10 9 1.414 8 10 8 The critical value is found (for an alpha of 0.001) by: CHIINV(0.999, 49) = 23.98. We would reject the null hypothesis for any value of the test statistic less than the critical value, 23.98. Example: A machine makes small metal plates used in batteries. The plate diameter is a random variable with a mean of 5 mm. As long as the variance is at most 1.0, the production process is under control & the plates are acceptable. Otherwise, the machine must be repaired. The QC engineer wants, therefore, to test the following hypothesis: H0: s2 < 1.0 With a random sample of 31 plates, the sample variance is 1.62. Solution: Computing the test statistic, we see that: n 1s 2 30 1.62 48 .6 2 2 2 0 1.00 For a critical value of = 0.05, the critical value is found by: CHIINV(0.05, 30)=43.77. Since our test statistic lies to the right of the critical value, we would reject the null hypothesis. The p-value is given by: CHIDIST(48.6, 30) = 0.017257. Thus, we would reject the null hypothesis for any value of > 0.017257, and fail to reject the null hypothesis for smaller values. Important Note: The use of the chi-square test on variance requires that the underlying population be normally distributed. Chi-Square Test for Independence It is often useful to have a statistical test that helps us to determine whether or not two classification criteria, such as age and job performance are independent of each other. The technique uses contingency tables, which are tables with cells corresponding to cross-classifications of attributes. In marketing research, one place where the chi-square test for independence is frequently used, such tables are called cross-tabs. You will recall that we have previously used the pivot-table facility within EXCEL to produce contingency or cross-tabs tables from more unwieldy tabulations of raw data. Example: A random sample of 100 firms is taken. For each firm, we record whether the company made or lost money in its most recent fiscal year, and whether the firm is a service or non-service company. A 2 X 2 contingency table summarizes the data. Profit Loss Total Industry Type Service Non-service 42 18 6 34 48 52 Total 60 40 100 Using the information in the table, we want to investigate whether the two events: the company made a profit in its most recent fiscal year, and the company is in the service sector are independent of each other. Before stating the test, we need to develop a little bit of notation: r = number of rows in the table c = number of columns in the table Oij = observed count of elements in cell (i, j) Eij = expected count of elements in cell (i, j) assuming that the two variables are independent Ri = total count for row i Cj = total count for column j The expected number of items in a cell is equal to the sample size, n, times the probability of the event signified by the particular cell. In the context of a contingency table, the probability associated with cell (i, j) is the joint probability of occurrence of both events. That is, E n Pi j. ij From the definition of independence, it follows that E n Pi P j. ij From the row and column totals, we can estimate: Pi R , n P j C i j n Substituting in these estimates, we get: The expected count in cell (i, j) is E ij RC i n j Example: Using the data from the contingency table of the previous example, we can calculate: E RC 60 48 28.8, n 100 E RC 60 52 31.2, n 100 E RC 40 48 19.2, n 100 E RC 40 52 20.8. n 100 11 12 21 22 1 1 2 2 1 2 1 2 The resulting table of expected counts is shown below: Profit Loss Industry Type Service Non-service 28.8 31.2 19.2 20.8 Expected Counts Profit Loss Industry Type Service Nonservice 28.8 31.2 19.2 20.8 Actual Counts Profit Loss Total Industry Type Service Nonservice 42 18 6 34 48 52 Total 60 40 100 The chi-square test statistic for independence is given by: r c 2 i 1 With degrees of freedom: j 1 O ij E E ij 2 ij r 1 c 1 Note that the chi-square test statistic is always nonnegative. If the observed counts exactly equal the expected (under the hypothesis of independence) counts, then the value of the test statistic would be zero. The greater the difference between observed and expected counts, the larger the test statistic becomes. We would reject the null hypothesis (of independence) only when we obtain a sufficiently large value of the test statistic. We can compute the chi-square test statistic for our example as follows: 2 42 28.8 28.8 2 18 31.2 31.2 2 6 19.2 19.2 2 34 20.8 20.8 2 29.09 . The number of degrees of freedom is 1 degree of freedom. Using the CHIINV function to compute a critical value for = 0.01, we see that CHIINV(0.01, 1) = 6.63. The rejection region (for a confidence level of 99%) is any test statistic larger than 6.63. Since our computed value of the statistic is much larger, we would reject the null hypothesis. Alternatively, we could compute the p-value by using the CHIDIST function: CHIDIST(29.09, 1) = 6.91 * 10-8 from which we see that we would reject the null hypothesis for any reasonable value of . Using the CHITEST function: An easier way to do this is to use the EXCEL CHITEST function. To do this, you need to have two tables in your spreadsheet one containing the original contingency table data of actual observed counts, and one containing the expected counts The following spreadsheet information contains: the original counts in range A1:B2, the expected counts in range D1:E2, the chitest function formula in cell F1, and the value returned by the chitest function formula in cell F2. 42 6 18 34 2 8 .8 1 9 .2 3 1 .2 2 0 .8 = C H IT E S T (A 1 :B 2 ,D 1 :E 2 ) 6 .9 2 1 6 2 6 1 2 2 2 0 6 2 3 E -0 8 Note that the value returned by the chi-test function formula is the p-value. Chi-Test Examples • See 95 Murders.xls spreadsheet