Announcement

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

  • Multiple imputation

    Dear all,
    I have a problem with imputed data. I have 5 imputed data sets, txt files, which I imported into Stata via Excel. Now, I have 5 imputed data sets in Stata and I estimated 5 logistic regressions. But how can I tell Stata that there are imputed data and how can I get the MI-Model? The data was originally imputed in R.
    I am grateful for any support Maria

  • #2
    Load your original data variables and the imputed variables in a wide format, then use the proper mi import wide command, followed by mi estimate: logistic ... .

    Comment


    • #3
      This question has partly been answered here.

      Read the help entry for mi import.

      [Edit: I see, you have already done this:]
      I see, you have already done this:
      Before you can mi import the datasets, you will first have to import delimted the .txt files and save them as .dta files (or perhaps as one .dta file).
      [/Edit]

      I believe that you will need to include the original file, containing missing values, as well.

      I will refrain from posting syntax because I have not gone through the details of the help files myself.

      Best
      Daniel
      Last edited by daniel klein; 17 Apr 2020, 09:48.

      Comment


      • #4
        Dear Daniel,
        thank you Daniel (both) for the answer. I have already saved the 5 files as stata data. I imported from txt to excel and than to Stata. But I don't know how to get the MI estimate. I can estimate 5 individual logistic regressions, but then I still don't have the MI estimate. The last step pooling is missing. Do I have to save the 5 files in one? If yes, how does it work?

        Thank you for support, kind regards
        Maria





        Comment


        • #5
          First, as I have mentioned, you will have to import a sixth dataset: the original dataset, including the missing values. Second, all six datasets must have one or more variables that uniquely identify observations. If you do not have the original data, stop here and get them into Stata. If you do not have a variable that uniquely identifies observations, stop here and create one.

          Let's assume that you now have the six files mydata0.dta, mydata1.dta, ..., mydata5.dta, where mydata0.dta is the original dataset, including missing values, and mydata1.dta, mydata2.dta, ..., mydata5.dta are the first, second, ..., fifth imputed datasets. Further, assume all datasets contain a variable, say id, that uniquely identifies the observations. Last, say you have three variables, a, b, and c, that have missing values in mydata0.dta and imputed values in mydata1.dta, mydata2.dta, ..., mydata5.dta.

          To get multiple imputation estimates, you will first have to tell Stata about the details that I have just outlined. You tell Stata about those details using mi import flongsep. You would type something along the lines:

          Code:
          use mydata0 , clear
          mi import flongsep mymidata , using(mydata1 mydata2 mydata3 mydata4 mydata5) id(id) imputed(a b c)
          If you have passive variables, you will have to tell Stata, too. Anyway, you would then run a couple of tests to make sure Stata understood everything correctly and there are no problems with your datasets. Something like

          Code:
          mi describe
          mi varying
          If there are no problems, you could optionally convert to flong-style, telling Stata to convert all six files to one dataset.

          Code:
          mi convert flong , clear
          save mymidata
          Now, you can get your mi estimates typing something along the lines

          Code:
          mi estimate : logit a b c
          This is all explained in

          Code:
          help mi import
          and the linked pdf files, which I (and others) have pointed to before.

          I hope this gets you started.

          Best
          Daniel

          Comment

          Working...
          X