Announcement

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

  • A different way of regression discontinuity

    Hi all,

    I have a panel data with 5000 observations and 117 variables. I will only use 2 variables: investment (ivt) and distance from cut-off (dis).

    I want to:

    1. Filter only the cells with -0.5 < = dis <= 0.5
    2. Group them according to their values, with 0.1 in difference between them (Group 1 are cells with 0<=dis<0.1; Group 2 are cells with 0.1<=dis<0.2; and so on). With that in mind, I have 10 groups in total.
    3. Calculate the mean of investment (ivt) for each of the group
    4. Draw a bar chart comparing the mean of investment of these 10 group.

    Is that the correct way to do to compare the level of investment amongst these group?

    I use command egen for the first step but it did not really work. Could anyone shed some light on how should I command these? Thank you very much!

  • #2
    Code:
    keep if inrange(dis, -0.5, 0.5) // Step 1.
    
    gen int group = floor(10*dis) // Step 2.
    
    collapse (mean) ivt, by(group)  // Step 3.
    
    graph bar ivt, over(group)  // Step 4.
    This will give you a graphical exploration of the level of investment among these groups. Analytically, you could do a comparison of the investment in each groups by stopping after step 2 and just doing a simple -regress ivt i.group-. But generally speaking, an analysis using the unbinned values of the continuous variable dis would be preferred.

    In the future when asking for help with code, it is a good idea to show example data in your post, using the -dataex- command. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Also, it is not helpful to say that something "didn't work." There can be many ways in which a command can fail to produce the desired results, and in the absence of specifics about what actually happened, it is anybody's guess what went wrong, all the more so when you don't even show the exact command you tried. So, in the future, if you have tried code but not gotten the desired results, show the actual code you used and the output that Stata produced in response to it, including any messages. And, unless it is blatantly obvious even to a person who has no idea what your project is about, also explain how what you got differed from what you want.
    Last edited by Clyde Schechter; 09 Dec 2021, 16:27.

    Comment

    Working...
    X