Announcement

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

  • Teffects and osample

    Hi, I'm trying to replicate some analysis I did using kmatch with teffects. Below is my syntax and the error message I get. After osample identified 10K observations I deleted them but then I get an error message of no observations. I'm stuck.

    . teffects nnmatch (zesci totreg pfemale pasian pblack phispanic pwhite pswd pell ppoor dist teacher_years_doe g8_zsci) (mat) , nneighbor(5) ematch(white black asian hispanic other ell swd swd lunch grade9 grade10 grade11 grade12) generate(nn) osample(nomatch)
    note: swd omitted because of collinearity.
    note: grade12 omitted because of collinearity.
    400 observations have fewer than 5 exact matches; they are identified in the osample() variable
    r(459);

    end of do-file

    r(459);

    . tab nomatch

    overlap |
    violation |
    indicator | Freq. Percent Cum.
    ------------+-----------------------------------
    0 | 9,949 96.13 96.13
    1 | 400 3.87 100.00
    ------------+-----------------------------------
    Total | 10,349 100.00

    . drop if nomatch ~= .
    (10,349 observations deleted)

    . do "C:\Users\mgw216\AppData\Local\Temp\341\STD4af0_00 0001.tmp"


    . teffects nnmatch (zesci totreg pfemale pasian pblack phispanic pwhite pswd pell ppoor dist teacher_years_doe g8_zsci) (mat) , nneighbor(5) ematch(white black asian hispanic other ell swd swd lunch grade9 grade10 grade11 grade12) generate(nn) osample(nomatch)
    no observations
    r(2000);


  • #2
    This is a self-inflected injury.

    Code:
    . tab nomatch
    
    overlap |
    violation |
    indicator | Freq. Percent Cum.
    ------------+-----------------------------------
    0 | 9,949 96.13 96.13
    1 | 400 3.87 100.00
    ------------+-----------------------------------
    Total | 10,349 100.00
    
    . drop if nomatch ~= .
    (10,349 observations deleted)
    The -drop if nomatch ~= .- command removes all observations in which variable nomatch is non-missing. But that is all of the observations! (Variable nomatch is creaed by the -osample()- option of -teffects nnmatch-, and it is always either 0 or 1, never missing.) On the assumption that what you were intending to do is drop those observations that violate the overlap assumption, the correct code would be -drop if nomatch == 1-, or just -drop if nomatch-.

    In Stata, yes-no conditions are best represented with 0 = no and 1 = yes. As far as I know, all variables created by official Stata commands that create yes-no variables work that way. I wonder if you were thinking about spreadsheets, where it is a common practice to represent such variables with no = missing and yes = 1 or "X" or something like that. That practice is not used in official Stata commands, and, when done by users makes the data harder to work with in Stata, because other official Stata commands will not "understand" that style of coding. It is usually a bad idea to rely on spreadsheet-based practices and ideas when working in Stata.
    Last edited by Clyde Schechter; 24 Apr 2025, 12:14.

    Comment

    Working...
    X