Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 2 way chi square table, stratified by RACE

    Hi, I have read and understood how to create multiway table using frequency or percent statistics, but don't see how to do it with a chi square test. For example, I have a bunch of patient demographic variables which I can run individually against bivariate outcome SMM (severe maternal morbidity), but I would like to see the distribution broken down by RACE. I know if I want to see a p val or OR for each individual RACE category I would have to do individual Logistic Regressions on each variable against SMM with RACE in the equation, but is there a way to just create a bivariate chi sq analysis table stratified by RACE? Thank you in advance.

  • #2
    I'm somewhat confused about what you want, given that a chi-squared test won't "create" any table. (A chi-squared test can be computed for a table that you request, though.)

    I'm thinking perhaps that you'd like a table showing SMM by each DemogVar for each race category, and you'd like to have a chi-squared test for each table. If so, you could do something like this:

    Code:
    sort RACE
    foreach D of varlist DemogVar1 DemogVar2 DemogVar3 {
       by RACE:  tab2 SMM `D', chi2
    }
    I'm not certain this is what you want, so feel free to follow up. However, presuming this *is* what you want, I'd still wonder if this analysis would be the best way to answer some broader question I'm imagining you have in mind, so you might also want to describe the question or problem you want this collection of tables to answer. Among other things, "significant" differences in distributions would not necessarily bias a comparison by race, nor would non-significant differences preclude such a bias.

    Comment


    • #3
      I am not sure if this is what you need, but I give it a try. I found this post by Jeff Pitblado (StataCorp) very helpful.

      It shows how to collect p-values and integrate it into a table.

      https://www.statalist.org/forums/for...dtable-command

      Comment


      • #4
        Sounds to like you are interested in log linear models: https://maartenbuis.nl/presentations/london15b.pdf
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Thanks Martin that's a great explanation of linear log models and very helpful, although I"m not sure it's what I'm looking for in this situation.
          Simon, thanks that's helpful, will take me a while to explore that.
          Mike: Thanks that is so helpful I will take that back to the bosses.
          It's unfortunately not "my question" , it's the way the clinicians want their tables to look, which frequently makes no sense. Frustrating communication issues at times but so goes the world!

          Comment


          • #6
            so...using Mike Lacy's code above with my variables I have:

            sort RACE
            foreach D of varlist GER OBESE SUBSTANCE_ABUSE DIABETES_GEST DIABETES_PREXIST {
            by RACE: tab2 SMM `D', chi2

            which is a great discovery, I didn't know how to do that....but when I try to figure out how to make the supplemental table for this study, I need N, percent, and p val for each comorbid variable against outcome SMM, subdivided by RACE. The above code gives me the individual Ns for each category but not the percents.

            For example, output for Race = white, Pre-existing Diabetes against outcome SMM, I have 197 for the N but how can I figure out what percentage of white race with SMM that is? I know they will ask for a percent in their table. So confusing, I'm honestly not even sure what percent they will want, row or column. But in case they ask, is there a way?

            RACE = 1

            -> tabulation of SMM by DIABETES_PREXIST

            | DIABETES_PREXIST
            SMM | 0 1 | Total
            -----------+----------------------+----------
            0 | 206,271 7,124 | 213,395
            1 | 3,036 197 | 3,233
            -----------+----------------------+----------
            Total | 209,307 7,321 | 216,628

            Pearson chi2(1) = 74.0277 Pr = 0.000

            Comment


            • #7
              The percent of whites with SMM could be obtained by using the -row- or -col- option for a different table request, e.g. -tab2 SMM race, column- Checking out the options described within -help tab2- will give you some relevant info and examples.

              Comment


              • #8
                Thank you Mike and everyone! I got what I needed by adding "cell" to the above code. I didn't want to deal with separate 2 way tables and copying all that into Word table so I tried this and it worked. I got cell frequencies and percents as well as individual p values by Race.

                sort RACE
                foreach D of varlist GER OBESE SUBSTANCE_ABUSE DIABETES_GEST DIABETES_PREXIST {
                by RACE: tab2 SMM `D', chi2 cell
                }

                Comment

                Working...
                X