Announcement

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

  • Multiple imputation: 'Invalid add' error message

    Hi,

    Currently using version 14.1 with a dataset of 115 variables and around 27,000 observations. However my complete case analysis sample size requires the use of multiple imputation, which is where I am having issues.

    I have written my MI code as so:


    mi set mlong
    mi register imputed [varlist of variables to be imputed]
    set seed 130495
    mi impute chained (ologit) [varlist of ordinal variables] (logit) [varlist of binary variables] (regress) [varlist of continuous variables] = [varlist of auxiliary variables], add(10) rseed(130495)


    It then returns the 'invalid add' error message with no further details and I haven't found any other information about troubleshooting this.

    Any advice or guidance is much appreciated.


    Thank you,
    Rachel


  • #2
    We need details, too. What is

    Originally posted by Rachel Warsaw View Post
    the 'invalid add' error message
    Please show the code, exactly as typed, and the error message, exactly as reported by Stata.

    Comment


    • #3
      Here is the code from my do file and the error message as seen in Stata:


      . mi set mlong

      .
      . mi register imputed GCRSKA00 GCRSKB00 GCRSKC00 GCRSKD00 GCRSKE00 GCRSKF00 GCRSKG00 GCRSKH00 GCRSKI00 GCRSKJ00 GCPRFA00 GCPRFB00 GCPRFC00 GCPRFD00 GCPRFE00 GCPRFF00 GCPRFG00 GCPRFH00 GCPRFI00 GCPRFJ00 CGT_decision_quality sleep_quality_14 sleep_quality_17 smoking cannabis other_drugs alcohol5 night_wakefulness
      (25178 m=0 obs. now marked as incomplete)
      .
      . set seed 130495
      .
      . mi impute chained (ologit) GCRSKA00 GCRSKB00 GCRSKC00 GCRSKD00 GCRSKE00 GCRSKF00 GCRSKG00 GCRSKH00 GCRSKI00 GCRSKJ00 GCPRFA00 GCPRFB00 GCPRFC00 GCPRFD00 GCPRFE00 GCPRFF00 GCPRFG00 GCPRFH00 GCPRFI00 GCPRFJ00 night_wakefulness smoking, force (logit) cannabis other_drugs alcohol5 sleep_quality_14 sleep_quality_17 (regress) CGT_decision_quality = ethnicity FCGTOUTCM FCGTDELAY FCGTDTIME FCGTOPBET FCGTRISKA FCGTRISKT school_bedtime school_wakeup noschool_bedtime noschool_wakeup sleep_latency alcohol family_structure sweep7_sleep parents_carers ADHINC00 income_weight sex parent_academic home_ownership, add(10) rseed(130495)
      invalid 'add'

      Comment


      • #4
        I am guessing that the syntax does not allow you to specify multiple options (highlighted).

        . mi impute chained (ologit) GCRSKA00 GCRSKB00 GCRSKC00 GCRSKD00 GCRSKE00 GCRSKF00 GCRSKG00 GCRSKH00 GCRSKI00 GCRSKJ00 GCPRFA00 GCPRFB00 GCPRFC00 GCPRFD00 GCPRFE00 GCPRFF00 GCPRFG00 GCPRFH00 GCPRFI00 GCPRFJ00 night_wakefulness smoking, force (logit) cannabis other_drugs alcohol5 sleep_quality_14 sleep_quality_17 (regress) CGT_decision_quality = ethnicity FCGTOUTCM FCGTDELAY FCGTDTIME FCGTOPBET FCGTRISKA FCGTRISKT school_bedtime school_wakeup noschool_bedtime noschool_wakeup sleep_latency alcohol family_structure sweep7_sleep parents_carers ADHINC00 income_weight sex parent_academic home_ownership, add(10) rseed(130495)
        Try instead:

        mi impute chained (ologit) GCRSKA00 GCRSKB00 GCRSKC00 GCRSKD00 GCRSKE00 GCRSKF00 GCRSKG00 GCRSKH00 GCRSKI00 GCRSKJ00 GCPRFA00 GCPRFB00 GCPRFC00 GCPRFD00 GCPRFE00 GCPRFF00 GCPRFG00 GCPRFH00 GCPRFI00 GCPRFJ00 night_wakefulness smoking (logit) cannabis other_drugs alcohol5 sleep_quality_14 sleep_quality_17 (regress) CGT_decision_quality = ethnicity FCGTOUTCM FCGTDELAY FCGTDTIME FCGTOPBET FCGTRISKA FCGTRISKT school_bedtime school_wakeup noschool_bedtime noschool_wakeup sleep_latency alcohol family_structure sweep7_sleep parents_carers ADHINC00 income_weight sex parent_academic home_ownership, force add(10) rseed(130495)

        Comment


        • #5
          Andrew Musau 's suggestion will, I think work, but the general problem is to remember that anything appearing after the first comma but before the second is an option and anything appearing before the first comma OR after the second comma but before the third is part of the command; here "add()" is clearly an option but you had it appearing after the second comma

          Comment


          • #6
            I would like to add a substantive comment: Do not use the force option. You never want that. Instead, find and fix the underlying problem.

            Comment


            • #7
              Originally posted by Andrew Musau View Post
              Try instead:

              mi impute chained (ologit) GCRSKA00 GCRSKB00 GCRSKC00 GCRSKD00 GCRSKE00 GCRSKF00 GCRSKG00 GCRSKH00 GCRSKI00 GCRSKJ00 GCPRFA00 GCPRFB00 GCPRFC00 GCPRFD00 GCPRFE00 GCPRFF00 GCPRFG00 GCPRFH00 GCPRFI00 GCPRFJ00 night_wakefulness smoking (logit) cannabis other_drugs alcohol5 sleep_quality_14 sleep_quality_17 (regress) CGT_decision_quality = ethnicity FCGTOUTCM FCGTDELAY FCGTDTIME FCGTOPBET FCGTRISKA FCGTRISKT school_bedtime school_wakeup noschool_bedtime noschool_wakeup sleep_latency alcohol family_structure sweep7_sleep parents_carers ADHINC00 income_weight sex parent_academic home_ownership, force add(10) rseed(130495)

              This returned another error:

              invalid 'force'

              Comment


              • #8
                I think that you have to build the command line gradually to figure out what the issue is. Start with

                Code:
                mi impute chained (ologit) GCRSKA00 GCRSKB00 (logit) cannabis other_drugs (regress) CGT_decision_quality = ethnicity FCGTOUTCM, force add(10) rseed(130495)

                If this runs, add other variables gradually.

                Comment


                • #9
                  I see nothing obviously wrong with the code in #4 that is copied into #7. Is this really what you have typed? Exactly? Why did you copy the code from the reply? Please copy and show your code from your do-file. Anything else is just wasting everyone's time, including yours.

                  At the risk of sounding repetitive: get rid of the force option! It is almost guaranteed to get you in trouble later.
                  Last edited by daniel klein; 26 Apr 2022, 08:36.

                  Comment


                  • #10
                    daniel klein This is my code from my do file, yes. I wanted to be clear which comment I was actioning at that point - thank you for your help.
                    Rich Goldstein your explanation about the commas was really clear and something I hadn't fully understood until I read it - thank you.

                    I have now resolved the issue, and ensured I've not included any force option and my add(#) is after the first comma instead of the second.

                    Thank you so much for everyone's comments.

                    Comment

                    Working...
                    X