This notebook demonstrates how to use Python and its statistical libraries to construct confidence intervals for proportions and means. We will also cover some important points relating to the properties of confidence intervals, and discuss how to use and interpret confidence intervals in practice. We will use the 2015-2016 wave of the NHANES data for all the analyses below.
It is important to note that the NHANES data are a "complex survey". The data are not an independent and representative sample from the target population. Proper analysis of complex survey data should make use of additional information about the manner in which the data were collected. Since complex survey analysis is a somewhat specialized topic, we ignore this aspect of the data here, and analyze the NHANES data as if it were an independent and identically distributed sample from a population.