Announcement

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

  • Command for Listwise deletion

    I am doing linear regression and my IV has more cases than my DV so our instructor told us to do listwise deletion. I searched for the command using
    help listwise
    but it says nothing found. How can I do listwise deletion?

  • #2
    I don't understand why your instructor would tell you that. When you run any estimation command in Stata, listwise exclusion for missing values of an involved variables is done automatically. You don't have to explicitly do anything to make that happen.

    Comment


    • #3
      To demonstrate what Clyde explained in #2, try this:

      Code:
      * Generate some data to illustrate
      clear *
      matrix C = (1, .3 \ .3, 1)
      corr2data x y, n(100) corr(C)
      * Change a few y-values to missing to mimic the situation described in #1
      replace y = . if inlist(_n,7,26,31,77,92)
      regress y x
      summarize x y
      * Use e(sample) to list only the estimation sample from -regress-
      summarize x y if e(sample)
      Output from the two -summarize- commands:

      Code:
      . summarize x y
      
          Variable |        Obs        Mean    Std. Dev.       Min        Max
      -------------+---------------------------------------------------------
                 x |        100    1.83e-09           1  -2.332422   2.238905
                 y |         95   -.0300106    .9925115  -2.366965   2.713493
      
      . summarize x y if e(sample)
      
          Variable |        Obs        Mean    Std. Dev.       Min        Max
      -------------+---------------------------------------------------------
                 x |         95   -.0119315    1.007608  -2.332422   2.238905
                 y |         95   -.0300106    .9925115  -2.366965   2.713493

      --
      Bruce Weaver
      Email: [email protected]
      Version: Stata/MP 18.5 (Windows)

      Comment


      • #4
        Adding to the example in #3, try this:

        Code:
        regress y x
        regress y x if !missing(x,y)
        Last edited by Bruce Weaver; 19 Sep 2020, 14:04. Reason: Changed !missing(x) to !missing(x,y)
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 18.5 (Windows)

        Comment


        • #5
          Bruce Weaver what does the ! indicate in !missing?

          Comment


          • #6
            ! is a logical operator meaning "not".

            Code:
            help operators

            Comment


            • #7
              And if you want to do listwise deletion manually for analysis that involves three variables y, x, z, you do

              Code:
              drop if missing(y,x,z)

              Comment

              Working...
              X