Announcement

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

  • Graphing Coefficients by Year-

    Hi All,

    A snippet of my data resembles the following:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(year y x)
    1990 121 123
    1990 213 123
    1990 213   3
    1990   3  12
    1990   1  23
    1990   1 123
    1990   4 123
    1991  23 123
    1991   3 123
    1991  12 123
    1991 123 123
    1991 123   1
    1991 123   3
    1991  12 313
    1991  32 123
    end
    Although the above contains just 1990-1991, my actual data extends from 1850-2010.
    What I wish to do, is to graph the coefficient on x by year, along with the confidence interval bands. I am presently using the following code:

    Code:
    forvalues i = 1990/1991 {     
        regress y x if year == `i'
        estimates store year`i'
        local allyears `allyears' year`i'  ||
        local labels `labels' `i'
    }
    Following this, the coef plot comes in handy:

    Code:
    coefplot `allyears', keep(x) vertical bycoefs bylabels(`labels')
    Now, when I verify whether the local variable stored values correctly, I use the command:

    Code:
    display "`allyears'"
    Indeed, when the dataset only contains 1990 and 1991, both the coeplot function, as well as the local variable works as expected. However, when I use the exact same command for the entire dataset, displaying the local variable results in a blank, which then results in the coefplot command also not displaying anything. Is there any reason why the exact same commands don't work for a bigger dataset? Is there a limit on the number of values that can be stored in the local variable?

    Any help on this is much appreciated.


    CS


  • #2
    This is indeed quite strange. I copied pasted the same dataset on a new Stata window, ran the commands, and the local variable allyears stored all the different years. I am at a total loss, as the dataset and commands are both identical.

    Comment

    Working...
    X