Agriculture Reference
In-Depth Information
The resulting value, 2.4685464, will be displayed in the Results
window. The sqrt() function is one of many functions built into
Stata that can be used in an immediate mode, such as we have done
here. Typing help functions in a Viewer window will bring up a
Help screen with a list of many types of functions.
Another example of using these saved values is to calculate confi-
dence intervals. Confidence intervals indicate with a certain level of
probability that the mean will fall in the confidence interval range. In
this case, we know the mean (93.8) from the summarize command
and we know the standard error of the mean (2.47) from our previous
displayed calculation.
Confidence intervals are calculated from the mean plus or minus
tabular t times the standard error of the mean ( y ± ts y ). Tabular t
can be found in the back of most statistics texts in a t table. Stata
has a function that can calculate this value for you, which is the
invttail( n,p ) where n is the degrees of freedom (one less than the
number of observations) and p is the inverse probability. If we wish
to see the 95% confidence limit, we would enter for p , 0.05. Actually,
Stata only calculates the larger positive value with this function rather
than the larger numeric value, so p should be 0.025 (half of 0.05) to
be correct. Therefore, enter the following command:
display r(mean) " +/- " sqrt( r(Var)/r(N) )*invttail (r(N)-1,0.025)
This command will display the mean plus or minus the confidence
interval. To see what exactly the lower and upper confidence intervals
are, enter
display r(mean - sqrt (r(Var)/r(N))* invttail (r(N)-1,0.025)
display r(mean + sqrt (r(Var)/r(N))* invttail (r(N)-1,0.025)
Of course, Stata has a command that will calculate the confidence
interval for you:
ci [ varlist ] [ if ] [ in ] [ weight ] [, options ]
The advantage of calculating this value yourself, as with other pos-
sible calculations, is that you can control the output as well as what
combination of values you wish to display together.
Search WWH ::




Custom Search