Announcement

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

  • Problem with generating an instrumental variable

    Hello,
    I’m using STATA 15 to generate a variable that will be used as an instrument in a regression.
    The dataset that I use is on director level, meaning that for each firm in a year the directors of the board are unique observations. (note that the directors in the sample don’t need to add up to the board size, since executives are excluded, for example)
    Below is a subsection of the dataset.
    cusip_9 fyear directorid gender board_size fraction_female_directos
    63904106 2000 323732 M 9 0.111
    63904106 2001 323712 M 10 0.1
    63904106 2001 323719 M 10 0.1
    63904106 2001 323721 M 10 0.1
    63904106 2001 323722 F 10 0.1
    63904106 2001 323728 M 10 0.1
    63904106 2001 324051 M 10 0.1
    63904106 2001 324056 M 10 0.1
    63904106 2002 323713 M 11 0.182
    63904106 2002 323722 F 11 0.182
    63904106 2002 323726 M 11 0.182
    63904106 2002 323728 M 11 0.182
    63904106 2002 323734 F 11 0.182
    63904106 2002 324056 M 11 0.182
    63904106 2003 323716 M 11 0.182
    63904106 2003 323719 M 11 0.182
    63904106 2003 323721 M 11 0.182
    Now the variable that I want to make is the: Fraction of Males with Board Connections to Female Directors.

    So, in the data a director can sit on multiple boards(firms) in a year. To break it down, I want to know of the directors that sit on other boards if there are females on those other boards. Secondly making the fraction of male directors in a board that sit on other boards in a year that have a female on the board. It is important that this fraction doesn’t incorporate females on the board in question for which I want to calculate this connection fraction.

    The code that I used so far is the following, and for a fact wrong and inefficient

    Code:
    //generating variable to indicate on how many other boards a directors sits in the sample.
    
    sort directorid fyear
    quietly by directorid fyear: gen other_boards=cond(_N==1,0,_n)
    label variable other_boards "# of boards a directors sits on in the sample"
    
    //generating other_boards only for men
    
    gen other_boards_m = 0
    replace other_boards_m = 1 if (gender=="M" & other_boards>1)
    
    
    //generating instrument as the fraction of male directors on the board who sit on other boards on which there are female directors
    //frist generating connection and later the fraction
    gen connection_female = 0
    replace connection_female = 1 if (firm_has_female_directors==1 & other_boards_m>=1)
    
    //fraction of male directors on the board who sit on other boards on which there are female directors
    
    gen fraction_connection_female = (connection_female/board_size)
    label variable fraction_connection_female "fraction of male directors on the board who sit on other boards on which there are female directors"
    This code is wrong since it doens't produce results for other_boards ==0. Which is also needed. Furthermore it doens't add up the individual directors first and then takes the fraction.
    Someone mentioned that the egen command could be far easier to compute what I'm after. Unfortunately, I have no idea how, since my stata knowledge is not that great.

    Hopefully someone can help me.
    Last edited by Freek Ramackers; 19 Feb 2020, 04:35.

  • #2
    First, whenever anyone mentions a procedure in Stata, you can look it up either from the command window with help procedure or findit procedure. You can also look it up in the PDF documentation. If you go to help, PDF documentation, it will open the documentation. On left-hand side there is a list of books. Index then click on subject and you will see how you access the subject index.

    I appreciate that you provide data and code. It is better if you provide the data using dataex – it makes it easier for us to use it. It is also important that your sample data actually illustrate the problem you're trying to solve even if you have to generate artificial data to do so. For example, your data only includes one firm so there's no way to use it to program your problem.

    The tricky part of your problem is identifying directors who serve on another board with female directors.

    Using these data

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float firm str4 director str1 sex
    1 "Bill" "m"
    1 "John" "m"
    1 "Mary" "f"
    1 "Bob"  "m"
    2 "Bill" "m"
    2 "Eric" "m"
    2 "Hank" "m"
    2 "John" "m"
    3 "Bob"  "m"
    3 "Jim"  "m"
    3 "Joan" "f"
    3 "Max"  "m"
    end
    Code:
    This code identifies if on board with females:
    bysort firm: egen hasfemale1=count(director) if sex=="f"
    bysort firm: egen bdnum=count(director)
    bysort director: egen numfemale=total(hasfemale1)
    bysort firm: egen hasfemale=mean(numfemale)
    g hasfemale2=hasfemale>0
    
    bysort director: egen memberfemale=sum(hasfemale2)
    g hasonotherbd=memberfemale>1
    You should take it from here.

    Comment

    Working...
    X