Announcement

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

  • Error r(321) after trying to conduct p for trend analysis

    Hello Stata Listers,

    Thankyou for reading my query!
    I currently am using a dataset with 52 variables, 82284 observations for longitudinal analysis. The dataset is based on information returned from 6 different surveys. I have converted the dataset to long format so currently there are ~ 6 different observations (in years) for each ID (panel data). There are approximately 13,000 unique ID variables.

    I have created a fake dataset for this example. My main variable of interest is carbohydrate intake (with participants divided into quintiles) and my primary endpoint is Type 2 diabetes mellitus (dummy variable 0/1).
    I have conducted multiple imputation logistic regression (mi estimate, cmdok: melogit) with multiple models performed to correct for CVD risk factors, sociodemographic factors and dietary variables. Multiple imputation was performed for participants with missing data on gestational diabetes mellitus.

    I am now wishing to calculate the p-value for trend across the quintiles however have been issued with an error code r(321). I have read the pdf and my only guess is that this is occurring due to the additional complexity of the mi estimate command. Can anyone provide any further insight?

    Thank-you again,
    Sarah

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(idalias wave_sg) int year byte(DM GDM PCOS TotalCarb_quintile PercentCarb_quintile _mi_m) long _mi_id byte _mi_miss
    1 1 2004 0 . 0 3 1 4 56922 .
    1 0 2001 0 . . 3 1 0 56921 1
    1 2 2007 0 0 0 3 1 5 56923 .
    1 0 2001 0 . 0 3 1 5 56921 .
    1 2 2007 0 0 0 3 1 2 56923 .
    2 5 2016 1 0 0 1 1 2 56929 .
    2 5 2016 1 0 0 1 1 5 56929 .
    2 0 2001 0 0 0 1 1 0 56924 0
    2 4 2013 0 0 0 1 1 4 56928 .
    2 2 2007 0 0 0 1 1 0 56926 0
    2 3 2010 0 0 0 1 1 0 56927 0
    2 1 2004 0 0 0 1 1 0 56925 0
    2 4 2013 0 0 0 1 1 0 56928 1
    2 4 2013 0 0 0 1 1 1 56928 .
    2 4 2013 0 0 0 1 1 5 56928 .
    2 5 2016 1 0 0 1 1 4 56929 .
    2 4 2013 0 0 0 1 1 2 56928 .
    2 4 2013 0 0 0 1 1 3 56928 .
    2 5 2016 1 0 0 1 1 1 56929 .
    2 5 2016 1 0 0 1 1 0 56929 1
    2 5 2016 1 0 0 1 1 3 56929 .
    3 4 2013 0 0 0 5 5 2 56934 .
    3 4 2013 0 0 0 5 5 5 56934 .
    3 1 2004 0 0 0 5 5 0 56931 0
    3 5 2016 0 0 0 5 5 3 56935 .
    3 5 2016 0 0 0 5 5 2 56935 .
    3 4 2013 0 0 0 5 5 1 56934 .
    3 4 2013 0 0 0 5 5 3 56934 .
    3 4 2013 0 0 0 5 5 0 56934 1
    3 2 2007 0 0 0 5 5 0 56932 0
    3 5 2016 0 0 0 5 5 1 56935 .
    3 5 2016 0 0 0 5 5 5 56935 .
    3 5 2016 0 0 0 5 5 0 56935 1
    3 5 2016 0 0 0 5 5 4 56935 .
    3 0 2001 0 0 0 5 5 0 56930 0
    3 3 2010 0 0 0 5 5 0 56933 0
    3 4 2013 0 0 0 5 5 4 56934 .
    4 4 2013 0 0 0 2 4 4 56940 .
    4 5 2016 0 0 0 2 4 4 56941 .
    4 5 2016 0 0 0 2 4 0 56941 1
    4 4 2013 0 0 0 2 4 3 56940 .
    4 2 2007 0 0 0 2 4 0 56938 0
    4 5 2016 0 0 0 2 4 1 56941 .
    4 3 2010 0 0 0 2 4 0 56939 0
    4 5 2016 0 0 0 2 4 5 56941 .
    end


    Code:
    mi estimate , cmdok: melogit DM i.wave_sg i.PercentCarb_quintile || idalias:,     or  
        contrast p.PercentCarb_quintile, noeffects

  • #2
    This is the code I ran for my logistic regression followed by my attempt to deduce the p value for the trends across quintiles which prompted error message r(321). Am I doing something wrong?

    Code:
    mi estimate , cmdok: melogit DM i.wave_sg i.PercentCarb_quintile || idalias:, or   
         contrast p.PercentCarb_quintile, noeffects

    Comment


    • #3
      The problem is you are trying to run -contrast- after a multiple imputation estimation. The only official postestimation commands that Stata allows following a multiple imputation estimation command are test, testtransform, predict, and predictnl. There is also @Dan Klein's -mimrgns- command, which does a multiple imputation version of -margins-. If there is some user-written command that will emulate -contrast- following multiple imputation estimation, I am not aware of it.

      Comment


      • #4
        Ah, I see. Thank-you Clyde for your quick response. It is appreciated truly.

        Comment

        Working...
        X