Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: gen vars from ci or cii commands


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: gen vars from ci or cii commands
Date   Thu, 12 Aug 2004 22:38:01 +0100

You have identified the wrong problem. The problem is 
that -cii- requires actual numbers of observations
and successes, so your syntax is illegal. There 
is no problem in applying -ci- with -if-. 

Is -treat- a string variable? Even if it is, 

if treat = "`group'"

needs == not =. 

A program -ciplot- from SSC does something 
which sounds similar to your problem. If 
you want something different, the code
can probably be cannibalised for your 
problem. 

Nick 
[email protected] 

Douglas Crawford
 
> In preparation for using rcap I want to create two variables: 
> upper and
> lower confidence intervals for a proportion in my data.  I 
> have already
> collapsed the data set.  I know that I can use 
> 
> cii obs successes, binomial
> 
> to generate the appropriate information.  My question is, Is 
> there a way of
> generating a variable = to the r(ub) and r(lb)?
> 
> I tried the following without success:
> 
> levels treat, local(groups)
> gen pct_bag_ub 	= .
> gen pct_bag_lb 	= .
> gen pct_bag_se 	= .
> gen pct_bag_mn 	= .
> gen N			= .
> 
> foreach group of local groups {
> 	cii obs successes if treat = "`group'"
> 	replace pct_bag_ub	= r(ub)	if strain_treat == "`group'"
> 	replace pct_bag_lb	= r(lb)	if strain_treat == "`group'"
> 	replace pct_bag_mn	= r(mean)	if strain_treat 
> == "`group'"
> 	replace pct_bag_se	= r(se)	if strain_treat == "`group'"
> 	replace N			= r(N)	if strain_treat 
> == "`group'"
> }
> 
> But cii does not support if (nor does ci).
> 
> I also tried statsby, but ci does not appear to be supported command.
> 

*
*   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/



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