Announcement

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

  • Using stored coefficients

    Dear all,

    I´m currently trying to run a dynamic simulation on individuals work biography in a panel dataset.

    What it want to do is:
    1. in the first step I want to run regressions in the unbalanced panel,
    2. then I want to store these coefficients of the explanatory variables
    3. use the stored coefficients to calculate transition probabilities.

    On example of my code for estimating whether an individual will change their labor force status in t+1 (with trans_lfs is a dummy indicating whether the individual will change its labor force status in t+1):

    Code:
    xtlogit trans_lfs lfs l.lfs c.age c.age2 c.age3 i.edu_highest  i.migration i.num_kids c.duration experience earnings birth, re
    
    *store coefficients
    preserve
    mat mat_lfs= e(b)'
    capture drop scc install matsave
    matsave mat_lfs, replace saving p("path") dropall
    restore
    In the next step I want to run a dynamic simulation for every year using the saved coefficients:

    Code:
    forval y=1990/2010 {
    
    gen lfs_probabilty=.
    
    replace lfs probability = lfs*E_lfs + l.lfs*E_laglfs_+ c.age*E_age +  c.age2 + E_age2 + ...... if year= `y' & flag==1
    }
    with E_* being the stored coeffiencts.

    The problem is, that I have about 10 different models for which I have to store coefficients and later run a dynamic simulation.

    So my question is: What is a good why to save and calculate with these coefficients? Saving all the coefficients in ten different dataset seems not really practical and I do not know how I then can use the stored coefficients of each particular regression when needed.

    Is there maybe a more elegant/ straightforward way to deal with my problem than the "matsave"-command?

    Any help would be appreciated. Thank you very much in advance.

  • #2
    You probably should be reviewing the output of help estimates save to learn how to use estimates save to store the regression results in ten different datasets that you can later use estimates use to read back in and use the predict command to generates your predictions.

    Comment


    • #3
      Thank you William for your very helpful advice.

      I´ve got one more question after reviewing the help manual on estimates and predict:
      If I run the model in the unbalanced panel separately by gender, do I then have to use the -e(sample)- command for my prediction, if I just want to use the coefficients gained by running the regression for men to predict the labor force status transition probability for men in t+1?

      Comment


      • #4
        No, you do not have to use e(sample). I'm guessing you want a single variable, say prd_trans_life, that you will build up year by year and gender by gender. So you will want code along the following lines.
        Code:
        generate prd_trans_life = .
        forval y=1990/2010 {
            estimates restore male`1990'
            predict temp if year==`y'
            replace prd_trans_life = temp if year==`y' & male==1
            drop temp
            estimates restore female`1990'
            predict temp if year==`y'
            replace prd_trans_life = temp if year==`y' & male==0
            drop temp
        }
        Again, the point to the above example is that you can use any results to predict using any set of observations, it doesn't have to be limited to the sample that the regression was run on.

        Comment


        • #5
          Ok. Thanks a lot!

          Comment

          Working...
          X