Statalist The Stata Listserver


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

RE: Re: st: To: statalist@hsphsun2.harvard.edu


From   "b. water" <barleywater@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: Re: st: To: statalist@hsphsun2.harvard.edu
Date   Wed, 3 May 2006 17:30:54 +0000

Lieu,

would appreciate it if you could put appropriate subject matter on the subject heading of your posting. it would help the list to help you and any future searches to the list.

regards,
bw

----------------------------------------
> Date: Wed, 3 May 2006 18:16:11 +0100
> From: heu034@googlemail.com
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: To: statalist@hsphsun2.harvard.edu
> 
> I'm not familar with the routine.  But I'll try to answer your
> questions based on what I know.
> 
> (1) yes - if the local is being evaluated, e.g. if you're calculating
> something with it, or generating a new local with it, or whatever. 
> For better explanation (and more information) please read:
> 
> "A little bit of Stata programming goes a long way.." by Christopher F. Baum
> 
> Downloadable from here:
> http://ideas.repec.org/p/boc/bocoec/612.html
> 
> 
> (2) I don't think the semicolon is necessary.  I have never written a
> loop with one.  May be you'd need them if you're doing something more
> sophisticated than I have attempted, I don't know.
> 
> (3) the -forval- command should work, as you said, if you replace
> `nparam' with 6.  So may be there are something wrong inside the
> loop??  Sorry I'm not of more help.
> 
> Hope this helps.
> 
> Cheers,
> Ada
> 
> 
> On 5/3/06, Lieu.N.Hazelwood@frb.gov <Lieu.N.Hazelwood@frb.gov> wrote:
> > I am trying to insert this code:
> > forvalues i=1/`nparam' {
> >             qui sum est if dumyid == `i'
> >             local avest = r(mean)
> >             local between = r(Var)
> >             qui sum `v' if dumyid == `i'
> >             local m=r(N)
> >             local within = r(mean)
> >             local totalv = `within' + ( 1 + 1/`m' )*`between'
> >             if `between'==0 {
> >                 global mi_combine3 F
> >             }
> >             if `between'&lt;=0 {
> >                 local dof .
> >                 local ii=`i'*$mimps
> >                 local lb=lb in `ii'
> >                 local ub=ub in `ii'
> >                 local riv=0
> >             }
> >             else {
> >                 local dof = ( 1 + 1/`m' )*`between'
> >                 local riv = `dof'/`within'
> >                 local dof = (`m'-1)*(1 + 1/`riv')^2
> >                 if `dof'&gt;1e+10 { local dof=1e+10 }
> >                 local invt = invttail(`dof', (1-`level'/100)/2)
> >                 local lb = `avest' - `invt' * sqrt(`totalv')
> >                 local ub = `avest' + `invt' * sqrt(`totalv')
> >             }
> >             post  `memhold' (`i') (`avest')/*
> >                 */ (`totalv') (`dof') (`lb') (`ub') (`riv')
> >         }
> >         postclose `memhold'
> >
> > /* Merge back individual results */
> >
> >            qui use "`results'",clear
> >            qui sort dumyid
> >            qui merge dumyid using `abit'
> >
> >            keep parm est* se* lb* ub* avest totalv mi* obs*  riv
> >            order parm avest totalv mi*  riv
> >            qui compress
> >
> >            qui save `outfile', replace
> >       end
> >
> > into my program.   This is the mi_rubin.do file.
> >
> > I have three questions. 1) Is the variable `within' need to have the quotes
> > around it?
> > 2) I am using a semicolon (;) as a designation of the end of command line.
> > Do I need to have a  ; after each command withing inthe {} in the forvalues
> > statement. For example should it read: f
> >       forvalues i=1/`nparam' {;
> >             qui sum est if dumyid == `i';
> >             local avest = r(mean);
> >             local between = r(Var);
> >             qui sum `v' if dumyid == `i';
> >             local m=r(N);
> >             local within = r(mean);
> >             local totalv = `within' + ( 1 + 1/`m' )*`between';
> >             if `between'==0 {;
> >                 global mi_combine3 F;
> >             };
> > or just one ; after the close bracket(shown below)?
> > forvalues i=1/`nparam' {
> >             qui sum est if dumyid == `i'
> >             local avest = r(mean)
> >             local between = r(Var)
> >             qui sum `v' if dumyid == `i'
> >             local m=r(N)
> >             local within = r(mean)
> >             local totalv = `within' + ( 1 + 1/`m' )*`between'
> >             if `between'==0 {
> >                 global mi_combine3 F
> >             }
> > 3) in the forvalues statement, if I have i=1/6 I keep getting an invalid
> > forval error r(196).  I assumed the `nparam' meant the number of
> > parameters.
> >
> > If anyone is familiar with this rountine and can help me, I would
> > appreciate it. I am new to STATA. Thanks. Lieu
> >
> > *
> > *   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/
> >
> 
> 
> --
> Ada Ma
> Research Fellow
> Health Economics Research Unit
> University of Aberdeen, UK.
> http://www.abdn.ac.uk/heru/
> Tel: +44 (0) 1224 553863
> Fax: +44 (0) 1224 550926
> 
> *
> *   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/

_________________________________________________________________
Enter the Windows Live Mail beta sweepstakes
http://www.imagine-msn.com/minisites/sweepstakes/mail/register.aspx
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index