+ Reply to Thread
Results 1 to 4 of 4

Thread: All possible logistic regressions for a set of confounders

  1. #1
    Points: 598, Level: 11
    Level completed: 96%, Points required for next Level: 2

    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    All possible logistic regressions for a set of confounders



    Hi all,

    I'm building a logistic model to evaluate an epidemiologic research question and I want to automate the process of fitting logistic models for every possible combination of my potential confounders. I've done this before using OLS regression in SAS by specifying a certain algorithm, but I have no idea how to do it in Stata.

    To clarify,
    I have c1, c2, c3, c4 .... ck. I want to automate the process of fitting a model for
    d = e + c1
    d = e + c2
    d = e + c1 + c2

    etc

    Can anyone help me code this?

    Thanks,
    Mike

  2. #2
    Points: 811, Level: 15
    Level completed: 11%, Points required for next Level: 89

    Posts
    78
    Thanks
    0
    Thanked 24 Times in 23 Posts

    Re: All possible logistic regressions for a set of confounders

    The user-written command -tuples- " produces a set of local macros, each containing a list of the names defining a tuple selected from a given list. ". You could use -forvaues- to write a loop to run your model. Type -findit tuples- to find and install it.
    For example,

    **************

    sysuse auto, clear
    tuples mpg turn length, display

    forvalues i=1/7 {
    logit foreign `tuple`i''
    }

    ****************



    Quote Originally Posted by Nicapyke View Post
    Hi all,

    I'm building a logistic model to evaluate an epidemiologic research question and I want to automate the process of fitting logistic models for every possible combination of my potential confounders. I've done this before using OLS regression in SAS by specifying a certain algorithm, but I have no idea how to do it in Stata.

    To clarify,
    I have c1, c2, c3, c4 .... ck. I want to automate the process of fitting a model for
    d = e + c1
    d = e + c2
    d = e + c1 + c2

    etc

    Can anyone help me code this?

    Thanks,
    Mike

  3. The Following 2 Users Say Thank You to wangwang For This Useful Post:

    bukharin (09-22-2012), Nicapyke (09-22-2012)

  4. #3
    Points: 598, Level: 11
    Level completed: 96%, Points required for next Level: 2

    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: All possible logistic regressions for a set of confounders

    Thanks for the tip, wangwang. To take it further, how would I code it if I just want to list the ORs produced by the logit regressions? I know I would use a "qui logit" command, but what would be the proper scalar to specify that picks out the OR in the logit output? If I can get that, then I would just do "list (scalarvariable)".

    Thanks again!

    Mike

  5. #4
    Points: 811, Level: 15
    Level completed: 11%, Points required for next Level: 89

    Posts
    78
    Thanks
    0
    Thanked 24 Times in 23 Posts

    Re: All possible logistic regressions for a set of confounders


    Like ?

    ************
    sysuse auto, clear
    tuples mpg turn length, display

    forvalues i=1/7 {
    qui logit foreign `tuple`i'', or
    estimates table, stat(b) eform
    }

    **************




    Quote Originally Posted by wangwang View Post
    The user-written command -tuples- " produces a set of local macros, each containing a list of the names defining a tuple selected from a given list. ". You could use -forvaues- to write a loop to run your model. Type -findit tuples- to find and install it.
    For example,

    **************

    sysuse auto, clear
    tuples mpg turn length, display

    forvalues i=1/7 {
    logit foreign `tuple`i''
    }

    ****************

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats