Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: Looping in each of 5 imputed datasets


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Looping in each of 5 imputed datasets
Date   Sat, 6 Feb 2010 22:57:47 +0100

<>

My code may disappoint b/c Outlook spell-corrected -vers- to -Vers-. You
want to undo this before running it. 

I suspect this chain of event also led to "r(Var)" being capitalized in the
r-returns after -summarize- (hard to find bug when you are time
constrained...)


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Weiss
Sent: Samstag, 6. Februar 2010 22:52
To: [email protected]
Subject: st: RE: Looping in each of 5 imputed datasets


<>

Actually, the way you condition on the "_mj" looks good to me  - and works
in my example below. 

-statsby- could be a convenient alternative for you.

You should -set trace on- just before the -psmatch2- call and report the
area around the error to the list.


*******
Vers 10.1

clear*
set obs 1000

forv i=1/10{
	gen x`i'=rnormal()
	replace x`i'=. if runiform()<.2
}

ice x1 x2 x3, saving(imputed) m(5) replace

u imputed, clear
forv x=1/5{
	reg x1 x2 if _mj==`x'
}
*******


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Anna D. Johnson
Sent: Samstag, 6. Februar 2010 17:25
To: [email protected]
Subject: st: Looping in each of 5 imputed datasets

I am using Stata 10 in Windows. I have multiply imputed data that I  
imputed using -ice-. I want to eventually be able to run the  
-psmatch2- and -pstest- commands in each of my 5 imputed data sets. I  
would like to tell Stata to run these commands, first in dataset  
_mj=1, then in dataset _mj=2, and so on through dataset _mj=5. A  
colleague was kind enough to share some code with me, but I can't get  
it run. Specifically, after the -psmatch2- line, I get an "invalid  
syntax" message. Here is the code I have been trying to use:

gen weight1=.;
gen pscore1=.;
forvalues x=1/5{;
set seed 339487731;
gen r = uniform();
sort _mj r;
drop r;

psmatch2 treatment covars covars outcome if _mj==`x',
outcome(outcome) noreplacement desc common trim(10);

pstest covars covars outcome, sum ;
replace weight1=_weight if _mj==`x';
replace pscore1=_pscore if _mj==`x';

I imagine somewhere in there I need to specify that the 'x' represents  
each of the _mj datasets, but I don't know how to do this. Any help  
would be greatly appreciated.

Many thanks.
-Anna


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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