Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

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

From |
Tim Evans <Tim.Evans@wmciu.nhs.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: using foreach in regression models |

Date |
Tue, 25 Oct 2011 10:26:42 +0100 |

Nick, You are right, I don't actually need to run this: xi: logit treatmentinsccnetre2 i.agegrp i.NRCENT i.site_4 i.sex i.id07 i.yydx, iterate(10) or xi: logit treatmentinsccnetre2 i.NRCENT i.site_4 i.sex i.agegrp i.id07 i.yydx, iterate(10) or xi: logit treatmentinsccnetre2 i.id07 i.NRCENT i.site_4 i.sex i.agegrp i.yydx, iterate(10) or xi: logit treatmentinsccnetre2 i.site_4 i.sex i.agegrp i.id07 i.NRCENT i.yydx, iterate(10) or Since the output will be the same as if I just run the first: xi: logit treatmentinsccnetre2 i.agegrp i.NRCENT i.site_4 i.sex i.id07 i.yydx, iterate(10) or Sorry for that. I did have a look at the local macros, but I need to spend some more time thinking about what you say as its currently above my programming skills. Best wishes Tim -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 25 October 2011 10:11 To: statalist@hsphsun2.harvard.edu Subject: Re: st: using foreach in regression models It's hard to see why the order of variables makes a difference to the model fitted. You should look at extended macro functions for list manipulation. Start with -help macro-. The key is to have a local macro with everything and subtract what you don't want each time. On Tue, Oct 25, 2011 at 10:03 AM, Tim Evans <Tim.Evans@wmciu.nhs.uk> wrote: > Hi all, > > I am running a number of logistic regression models (Stata 11.2), using the same dependant variable, but cycling through a number of independent variables to obtain 'unadjusted' regressions like such: > > xi: logit treatmentinsccnetre2 i.agegrp, iterate(10) or > xi: logit treatmentinsccnetre2 i.NRCENT, iterate(10) or > xi: logit treatmentinsccnetre2 i.id07, iterate(10) or > xi: logit treatmentinsccnetre2 i.site_4, iterate(10) or > > I can condense this down to the following > > foreach v of varlist agegrp id07 NRCENT site_4 { > xi: logit treatmentinsccnetre2 i.`v', iterate(10) or > } > > This is fine, however, I also do want to run the analysis by introducing a range of other variables in order to 'adjust' for their effect. The list of variables will always be the same, but although the list is the same, some variables move around the list - if they are the variable of interest i.e: > > > xi: logit treatmentinsccnetre2 i.agegrp i.NRCENT i.site_4 i.sex i.id07 i.yydx, iterate(10) or > xi: logit treatmentinsccnetre2 i.NRCENT i.site_4 i.sex i.agegrp i.id07 i.yydx, iterate(10) or > xi: logit treatmentinsccnetre2 i.id07 i.NRCENT i.site_4 i.sex i.agegrp i.yydx, iterate(10) or > xi: logit treatmentinsccnetre2 i.site_4 i.sex i.agegrp i.id07 i.NRCENT i.yydx, iterate(10) or > > What I would like to do is use the loop I employ for the unadjusted model, but be able to use something like `v' in order to condense the code from the above. > * * 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/ _DISCLAIMER: This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful. * * 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/

**Follow-Ups**:**Re: st: using foreach in regression models***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: R: variable not found?***From:*"Carlo Lazzaro" <carlo.lazzaro@tin.it>

**Re: st: R: variable not found?***From:*Christian Otchia <bensamen@gmail.com>

**RE: st: R: variable not found?***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: using encode to order string distances***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

**st: RE: using encode to order string distances***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: using foreach in regression models***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

- Prev by Date:
**Re: st: Graph Mean SD of continuous variable over categorical variable - but with a twist** - Next by Date:
**Re: st: using foreach in regression models** - Previous by thread:
**Re: st: using foreach in regression models** - Next by thread:
**Re: st: using foreach in regression models** - Index(es):