* do-file for Supplementary Exercises 6.13 and 6.14 of IPS7e version 17 /* works also with versions 14-16, see below for version 13 and earlier */ import delimited "R:\Chapter 6\ex06_013.csv" summarize yield * 6.13 ztest yield=0, sd(10) level(90) ztest yield=0, sd(10) level(95) ztest yield=0, sd(10) level(99) * the ztest command offers inference for a normal distribution with known sigma * the hypothesized mean (for a test) is required, but we if we're not interested * in a test, we can set it at any value and ignore the result * note: the default confidence level is 95, so the option "level(95)" is not needed * 6.14 ztesti 50 123.8 10 0, level(95) * note: we don't have data for this situation, so we use the ztesti command instead * where the relevant statistics are typed directly ************************************************************************** * Stata 13 (and earlier) code * Stata 13 does not offer confidence intervals with KNOWN sigma. * One way to trick the program is to pretend the dataset to be huge; * below we assume 10000 times as many observations, and a standard deviation * 100 (=sqrt(10000)) times as large, so that the standard deviation of * the mean is the same. cii 150000 123.8 1000, level(90) cii 150000 123.8 1000, level(95) cii 150000 123.8 1000, level(99) * As you'll have guessed by now, the cii command with parameters * n, mu and sigma, gives a confidence interval for a sample of size n * from a normal distribution with mean mu and standard deviation sigma. * Other variants of the command give confidence intervals for other * situations (later in course). * 6.14 cii 500000 123.8 1000, level(95)