Announcement

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

  • What does i.yr in STATA really mean?

    I saw a code that

    ```areg dep_var pt i.yr, a(TYPE2)```

    while TYPE2 is firm identification and yr is year identification

    I am wondering what exactly i.yr does, Whether it create a dummy variable for each yr. For example, all firms (TYPE2) will receive the same value of 1 in each year? For example, STATA will create a variable called yr1989 for the year 1989 means that this variable received value 1 in this year and 0 for other years.

  • #2
    You have the general concept. i.yr causes Stata to create a 0/1 indicator ("dummy") variable for each yr. But it is not actually a variable in the data set. When a command encounters that notation, Stata will create the necessary internal structures to carry out the calculations as if such indicator variables were actually in the data set. (For example, in -regress-, Stata will create additional columns in the design matrix with 1s and 0s corresponding to what actual year indicator variables would have produced. Also if you want to reference one of these "variables" individually, it's not called yr1989: it's called 1989.yr.

    The advantage of this notation, in addition to saving you the trouble of creating a lot of variables yourself and cluttering up your data set with them, is that it also gives you control over which ones to omit in the presence of colinearity, and it also provides information that is essential if you use the -margins- command afterwards. To read all about it, see -help fvvarlist-.

    Comment

    Working...
    X