Announcement

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

  • How do I make a graph of a FE-model?

    Hi there

    First off, I’m sorry if this is obviously to everyone else, but I have searched the internet for weeks now, and haven’t found anything on this subject.

    So I’m running a FE-model including 40 countries over 11 years and my dataset are unbalanced. I’m essential looking at, what affects the number of entrepreneurs in a country and my model looks like this:

    xtreg y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12, fe vce(cluster Country_No)

    My problem is that I would like to show the within-estimator of one of my dependent variables in a line-graph and in the same graph show all the coefficients of the different groups (countries).

    I my case, I would for example like to show how the level of taxation is collated with the number of entrepreneurs (as % of pop.) in every given country along with the overall fixed-effects within-estimator.

    I have to admit, that I have given up on STATAs own graph and tried to export the numbers and build the graph in Excel.

    So far, I have tried running a normal reg. in both parmby and statsby – like this:

    parmby "reg y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12", by(Country) label saving(model2,replace)
    statsby, clear by(Country) : reg x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12

    The problem is, that it then won’t include the country dummy variables and the estimations are the way off compared to my original estimation (or at least that’s what I think? I simply just take the mean of all coefficients within one variable from the different countries – and that mean is nothing like my FE estimate).

    I have also tried to run statsby and parmby with xtreg, fe - but that won’t put out any results at all (which I don’t blame it for, since it needs more than one country at a time).

    So my question is – what do I do? I have simply given up and you guys are my last hope :-) ANY help would be deeply appreciated!

    Thanks in advance,
    Emil

  • #2
    It is not clear to me what you want to graph. Using a publicly available data set what are you trying to display:

    Code:
    webuse grunfeld,clear
    xtreg invest mvalue kstock, fe

    Comment


    • #3
      Sorry about that.

      But, in the case with the grunfeld data, I would like to graph the coefficient for kstock (,1101238), together with the “country coefficient“ for company 1, company 2, company 3 etc.

      Hope that made a bit more sense? :-)

      Comment


      • #4
        Something like this:

        Code:
        clear*
        webuse grunfeld
        xtreg invest mvalue kstock, fe
        predict fe, u
        mat beta=e(b)
        svmat double beta, names(matcol)
        collapse fe beta*, by(com)
        replace betamvalue = betamvalue[1]
        scatter fe  com || line betamvalue com

        Comment


        • #5
          Thanks for your reply and help :-)

          I’m getting this:
          [ATTACH=CONFIG]n4623[/ATTACH]

          But what I’m really looking for is something like this:
          [ATTACH=CONFIG]n239[/ATTACH]
          Last edited by Emil Jensen; 14 May 2014, 08:01.

          Comment


          • #6
            Of course, all the lines will have the same slope, but try this:

            Code:
            clear*
            webuse grunfeld
            xtreg invest mvalue kstock, fe
            predict fe, u
            clonevar kstock_orig = kstock
            clonevar mvalue_orig  = mvalue
            //Set kstock  equal to the mean
            sum kstock, meanonly
            replace kstock = r(mean)
            //Set mvalue = 20 to 400
            bys com: replace mvalue = 20*_n
            
            predict invest_within, xb
            gen  invest2 = invest_within + fe
            line invest2 mvalue, c(L) lc(blue) lw(thin) /// 
             || line invest_with mvalue , lw(medthick) lc(black) /// 
             || scatter invest2 mvalue if mvalue == 400, ms(none) mlabel(com)   /// 
               mlabcolor(blue) mlabsize(*.6)  /// 
             || scatteri `=invest_within[_N]' `=mvalue[_N]' (12) "within" , /// 
               ms(none) mlabcolor(black) mlabsize(*.9)  /// 
             || , legend(off) ytitle(Predicted Investment) ylabel(-200(50)250) /// 
                xtitle(mvalue)

            Comment


            • #7
              Thanks a lot! Really grateful for the help. Though the point was, to see the different slope. Do you think that can be done? Or are there simply limitations to STATAs magic?

              Comment


              • #8
                In the example there is only one estimate for the variable mvalue though a different intercept for each group. Perhaps you want a random coefficient model, see mixed

                Also, you might find this site helpful:


                http://data.princeton.edu/pop510/lang2.html

                Comment


                • #9
                  Okay – thanks again :-) I’ll have a look.

                  Comment

                  Working...
                  X