The commands ci and mean both compute mean values, standard errors and confidence intervals. However, when a variable is grouped, the confidence intervals are different.
In the first example all results (mean, standard error, confidence interval) are the same.
In the second example the mean values and standard errors are the same but the confidence intervals are different. How can this be explained?
In the first example all results (mean, standard error, confidence interval) are the same.
Code:
. sysuse auto, clear (1978 Automobile Data) . ci mpg Variable | Obs Mean Std. Err. [95% Conf. Interval] -------------+--------------------------------------------------------------- mpg | 74 21.2973 .6725511 19.9569 22.63769 . mean mpg Mean estimation Number of obs = 74 -------------------------------------------------------------- | Mean Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ mpg | 21.2973 .6725511 19.9569 22.63769 --------------------------------------------------------------
Code:
. bysort foreign: ci mpg ----------------------------------------------------------------------------------- -> foreign = Domestic Variable | Obs Mean Std. Err. [95% Conf. Interval] -------------+--------------------------------------------------------------- mpg | 52 19.82692 .657777 18.50638 21.14747 ----------------------------------------------------------------------------------- -> foreign = Foreign Variable | Obs Mean Std. Err. [95% Conf. Interval] -------------+--------------------------------------------------------------- mpg | 22 24.77273 1.40951 21.84149 27.70396 . mean mpg, over(foreign) Mean estimation Number of obs = 74 Domestic: foreign = Domestic Foreign: foreign = Foreign -------------------------------------------------------------- Over | Mean Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ mpg | Domestic | 19.82692 .657777 18.51598 21.13787 Foreign | 24.77273 1.40951 21.96358 27.58188 --------------------------------------------------------------
Comment