Professional Documents
Culture Documents
in Stata
Liang Wu
Liang.Wu@uth.tmc.edu
Topics
• The 𝑡 distribution
• Confidence Intervals
• Normal distribution
• Binomial distribution
• Poisson distribution
Student’s 𝒕 distribution
• Let 𝑋 be an independent random sample from a normal
distribution with known mean and unknown variance
(𝑋1 , . . , 𝑋𝑛 ~𝑁(𝜇, 𝜎 2 )). Then,
𝑥ҧ − 𝜇
𝑡= ~𝑡𝑛−1
𝑆/ 𝑛
• where S is the standard deviation of the sample. This statistic
emerge as solution of the estimation problem when the
population variance is unknown; in 1908 by Gosset better
known by his pseudonym “Student” (See Rosner page 169).
Stata commands for the
Student’s 𝒕 distribution
• The two commands that we will use to calculate
the distribution probabilities are
• ttail
• invttail
Student’s t distribution
• display ttail(n-1,t)
• It will compute the reverse cumulative
(upper tail, P(T>t)) Student’s 𝑡 distribution,
where (n-1) is the number of degrees of
freedom and 𝑡 is the test statistic.
Example 1
• Assume that a random sample of 20 people is
observed and a test statistic is computed
(t=1.645).
• What is the probability that t is greater than 1.645?
P(T≥1.645) ?
• Data: n=20, t=1.645
• display ttail(20-1,1.645)
• Answer: Because it is a continuous distribution
Pr(T>t)=Pr(T ≥ t) therefore
P(T ≥ 1.645)=0.058
Example 2
• Assume that a random sample of 20 people is
observed and a test statistic is computed
(t=1.0).
• What is the probability that T is less than or
equal to 1.0?
• Answer:
Data: n=20, t=1.0
display 1-ttail(20-1,1.0)
Pr(T≤t) = 1 - Pr(T>t) =0.835
Student’s 𝑡 distribution
• display invttail(n-1,p)
• This command, returns the inverse reverse
cumulative (upper-tail) Student's 𝑡 distribution
where 𝑛 − 1 are the degrees of freedom and 𝑝 is
the probability.
• In Stata
Confidence Intervals
calculation
• How can we determine with certainty that our results are
close to the true value?
• The statistics that we calculate can vary depending on the
sample that we obtain.
• In order to compute the Confidence Intervals (C.I.), we need
to know the probability distribution of an statistic that
involves the parameter of interest.
Confidence Intervals functions
• The two commands commands to calculate
confidence intervals in Stata are:
Variable
name
Distributions
options
Confidence Intervals
Commands
. When a data set is available
Normal distribution
Binomial distribution
Poisson distribution
-- Binomial Exact --
Variable | Obs Mean Std. Err. [95% Conf. Interval]
-------------+---------------------------------------------------------------
| 10 .6 .1549193 .2623781 .8784477
Example - binomial
-- Binomial Exact --
Variable | Obs Proportion Std. Err. [95% Conf. Interval]
-------------+---------------------------------------------------------------
| 10,000 .04 .0019596 .0362438 .044027
Poisson Confidence Interval
Calculator
• Number of exposure
• Number events or
counts
• % Confidence
Interval: 90%, 95%,
99%
-- Poisson Exact --
Variable | Exposure Mean Std. Err. [95% Conf. Interval]
-------------+---------------------------------------------------------------
| 12000 .001 .0002887 .0005167 .0017468
Confidence Intervals functions
• In addition to using commands in to calculate our confidence
intervals, we can also type in the formulas manually assuming
we know the point estimate of interest, std deviation of the
point estimate, and whether we are using the t or z
distribution.
• With known population variance
𝑋ത ± 𝑍1−𝛼/2 𝜎/ 𝑛