* do-file for Supplementary Exercises 6.38 and 6.39 of IPS7e version 17 /* works also with version 16 */ * using either the command or the Power and sample size menu (Confidence interval) * the ciwidth command was introduced with Stata 16 * 6.38 * for known population standard deviation ciwidth onemean, width(800) sd(9000) knownsd * for unknown and hence estimated standard deviation ciwidth onemean, probwidth(.5) width(800) sd(9000) ciwidth onemean, probwidth(.8) width(800) sd(9000) * note on Stata implementation with estimated standard deviation: Stata additionally requires specification of the "probability of achieving target CI width" (probwidth option). This is similar to the probability set for the power in sample size calculations based on power. Setting the value around 0.5 will give results similar to those obtained with t*-values instead of z*-values. This adjusts for the use of the estimated standard deviation in the calculation of the CI, but does not adjust for the variation in the estimated standard deviation: the sample estimates will not be equal to the stated value for standard deviation, and hence the actual confidence intervals will be either larger or smaller than the specified margin of error. Therefore, setting this probability at a reasonably high value (e.g. 0.8 or 0.9) will make it more likely that the CI achieves its target, but (naturally) at the cost of a larger sample size. * 6.39 * for known population standard deviation ciwidth onemean, width(1600) sd(9000) knownsd * for unknown and hence estimated standard deviation ciwidth onemean, probwidth(.5) width(1600) sd(9000) ciwidth onemean, probwidth(.8) width(1600) sd(9000)