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

st: Re: automating a series of equations


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: automating a series of equations
Date   Thu, 8 May 2003 20:30:33 -0500

----- Original Message ----- 
From: "Don Spady" <[email protected]>
To: "Statalist" <[email protected]>
Sent: Thursday, May 08, 2003 6:11 PM
Subject: st: automating a series of equations


> Dear All
> 
> I need some help with repeating tasks.  I am doing a series of
> logistic regressions and want to automate the task.
> 
> 
> Say I have an equation
> logistic  depvar indepvar sexfm interactionterm if agegrp == X
> lincom indepvar + interaction term (sexfm+indepvar)
> I have about 8 depvars and 25 indepvars and 3 agegrps.
> I want to do all 8 depvars and 25 indepvars at 3 agegrps and do a lincom
> on each outcome.
> it is easy to automate the system using for var "x": if you are not
> doing lincom.  Use of lincom introduces a new command and I don't know
> how to
> deal with it.
> How do I do a for var depvar1 ... depvar10 and then do a lincom for each
> equation as it comes up.  I think it needs a loop within a loop but I am
> not at all sure how to do that.
> 
> Thanks in Advance for your help.
> 
> 
> Donald Spady
> Dep't of Pediatrics, University of Alberta
> (780) 407-1244
> 
> Nature has no reset button.
> 
> 

I think something like this should work:

levels agegrp , local(levels)
foreach var of varlist dep1 - dep10 {
        foreach l of local levels {
             logit `var' indepvar1 - indepvar25  if agegrp == `l'
             lincom indepvar1 + indepvar2  
      }
 }

Scott


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