# st: Re:using replace command and retrieving conf. intervals

 From kusi@yorku.ca To statalist@hsphsun2.harvard.edu Subject st: Re:using replace command and retrieving conf. intervals Date Tue, 23 Jul 2002 15:29:57 -0400

```while trying to figure out how the  confidence interval at 95% level is linked
to the standard error, I came up with following problem (as I tried to use the
replace command) : the parts of the command that connect are just for standard
errors 0, .25, .5 and .75 .Obviously the standard errors visible on the screen
are not perfectly consistent with what is visible plus the hidden parts
(lingering parts) .Can anyone help me with that.And while I am at it ,can
anyone tell me how to retrieve the lower boundaries  and the upper boundaries
of confidence intervals  ?

.        capture program drop lnsimvz1

.
.         program define lnsimvz1
1.                 if "`1'"=="?" {
2.                         global S_1 " pu pl p se t mean"
3.                         exit
4.                 }
5.                 drop _all
6.                 use clt
7.                 sample 4
8.                ttest a = 3
9.               return list
10.           post `1'  r(p_u) r(p_l) r(p) r(se) r(t) r(mu_1)
11.         end

.
.
end of do-file

. simul  lnsimvz1 , reps(1000)

. list in 1/5

pu         pl          p         se          t       mean
1.   .681191    .318809   .6376181   .4787135  -.5222329       2.75
2.  .7524873   .2475127   .4950253   .6454972  -.7745967        2.5
3.         .          .          .          0          .          4
4.  .7524873   .2475127   .4950253   .6454972  -.7745967        2.5
5.        .5         .5          1   .7071068          0          3

. tab se

se |      Freq.     Percent        Cum.
------------+-----------------------------------
0 |         34        3.40        3.40
.25 |        134       13.40       16.80
.2886751 |        108       10.80       27.60
.4082483 |        117       11.70       39.30
.4787135 |        232       23.20       62.50
.5 |         67        6.70       69.20
.5773503 |         52        5.20       74.40
.6291529 |         62        6.20       80.60
.6454972 |         49        4.90       85.50
.7071068 |         57        5.70       91.20
.75 |         80        8.00       99.20
.8660254 |          8        0.80      100.00
------------+-----------------------------------
Total |       1000      100.00

. do "C:\WINDOWS\TEMP\STD010000.tmp"

. gen interval = 1.837386

. replace interval  = 0 if se == 0

. replace interval = 1.591224 if se == .25

. replace interval = 1.591224  if se == .2886751

. replace interval = 2.598456 if se == .4082483

. replace interval = 3.04696 if se == .4787135

. replace interval =3.182446 if se == .5

. replace interval = 3.674772  if se == .5773503

. replace interval = 4.0044902 if se == .6291529

. replace interval = 4.1085203 if se == .6454972

. replace interval =4.5006584 if se == .7071068

. replace interval = 4.7736697 if se == .75

. replace interval = 5.5121583 if se == .8660254

.
.
end of do-file

.
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```