Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Confidence Interval for Proportion


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   RE: st: Confidence Interval for Proportion
Date   Tue, 11 Mar 2008 20:58:22 +0100

Indeed, this do-file illustrates the problem for all five categories

************************
sysuse auto, clear
qui{
proportion rep78
matrix define A=e(b)
count if rep78!=.
forv i=1/5{
local stderr`i'= sqrt(A[1,`i']*(1-A[1,`i'])/`=`r(N)'-1')
noi di in red "Standard Error for `i':" _column(27)  as result `stderr`i''  
noi di in red "Lower Bound for `i':" _column(27)  as result
A[1,`i']-invnormal(1-0.05/2)*`stderr`i''  
noi di in red "Upper Bound for `i':" _column(27)  as result
A[1,`i']+invnormal(1-0.05/2)*`stderr`i''  _newline 
}
}
*For Comparison
proportion rep78
************************



Martin Weiss
_________________________________________________________________

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen
Germany

Fon: 0049-7071-2978184

Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130

Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131

SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jeff Pitblado,
StataCorp LP
Sent: Tuesday, March 11, 2008 7:08 PM
To: [email protected]
Subject: Re: st: Confidence Interval for Proportion

Martin Weiss <[email protected]> is using the -proportion-
command
and has a question about how standard errors are computed:

> Dear Statalisters,
> 
> try this in Stata:
> 
> ************************
> sysuse auto, clear
> proportion rep78
> matrix define A=e(b)
> matrix define B=e(V)
> count if rep78!=.
> *Upper/Lower Bound for proportion of "1"
> di A[1,1]+invnormal(1-0.05/2)*sqrt(A[1,1]*(1-A[1,1])/`r(N)')
> di A[1,1]-invnormal(1-0.05/2)*sqrt(A[1,1]*(1-A[1,1])/`r(N)')
> *Standard Error for "1"
> *Mistake obviously there...
> di sqrt(A[1,1]*(1-A[1,1])/`r(N)')
> ************************
> 
> Then let me know: why do I not hit the correct CI for the proportion of
"1"
> in the repair record? Something`s wrong with the standard error, I do not
> know what, though...

Using Martin's example Stata code, -proportion- effectively computes the
standard error via

	sqrt(A[1,1]*(1-A[1,1])/(r(N)-1))

This is explained (rather tersely, I'll admit) in the 'Methods and Formulas'
section of -[R] proportion-.

	"Proportions are means of indicator variables; see -[R] mean-."




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index