Statalist The Stata Listserver


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

st: To: [email protected]


From   [email protected]
To   undisclosed-recipients: ;
Subject   st: To: [email protected]
Date   Wed, 3 May 2006 09:38:24 -0400

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'<=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'>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/



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