Announcement

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

  • Exporting linear postestimation results in custom table

    Hello,

    I am fairly new to Stata (17) and am trying to export some linear combination results of multiple prior regressions in a table. For some reason, when I apply the methods of different posts on statalist it is not working properly.

    I run two regressions of the following :

    eststo: xtreg Drevenue c.W#c.D_2021_2022#c.f_2021 ///
    c.W#c.D_2020_2022#c.f_2020 c.W#c.D_2020_2022#c.f_2021 ///
    c.W#c.D_2019_2022#c.f_2019 c.W#c.D_2019_2022#c.f_2020 c.W#c.D_2019_2022#c.f_2021 ///
    c.W#c.D_2018_2022#c.f_2018 c.W#c.D_2018_2022#c.f_2019 c.W#c.D_2018_2022#c.f_2020 c.W#c.D_2018_2022#c.f_2021 ///
    c.W#c.D_2017_2022#c.f_2017 c.W#c.D_2017_2022#c.f_2018 c.W#c.D_2017_2022#c.f_2019 c.W#c.D_2017_2022#c.f_2020 c.W#c.D_2017_2022#c.f_2021 ///
    c.W#c.D_2017_2021#c.f_2017 c.W#c.D_2017_2021#c.f_2018 c.W#c.D_2017_2021#c.f_2019 c.W#c.D_2017_2021#c.f_2020 c.W#c.D_2017_2021#c.f_2021 ///
    c.W#c.D_2016_2022#c.f_2016 c.W#c.D_2016_2022#c.f_2017 c.W#c.D_2016_2022#c.f_2018 c.W#c.D_2016_2022#c.f_2019 c.W#c.D_2016_2022#c.f_2020 c.W#c.D_2016_2022#c.f_2021 ///
    i.year, fe vce(cluster id)

    - where W is for the first regression a simple dummy and in the second a continuous variable. The D_x_y represent the cohorts in the population, where x is the year of entry in the treatment program and y the year of exit.

    After both regressions, I need to compute some linear combinations on the result, some examples are below:
    1) per cohort entering in 2019 : lincom (c.W#c.D_2019_2022#c.f_2019 + c.W#c.D_2019_2022#c.f_2020 + c.W#c.D_2019_2022#c.f_2021)/ 3
    2) per year (eg 2020) : lincom (c.W#c.D_2020_2022#c.f_2020 + c.W#c.D_2019_2022#c.f_2020 + c.W#c.D_2018_2022#c.f_2020 + c.W#c.D_2017_2022#c.f_2020 + c.W#c.D_2017_2021#c.f_2020 + c.W#c.D_2016_2022#c.f_2020) / 6

    My first problem is that even though I seem to store the regression results, once I run a lincom, the following lincom commands cannot find the coefficients/variables (_b[...]) from the regression anymore ?

    These linear combinations cannot be put in a loop because depend on each year and cohort.

    The second problem I am struggling with is how can I make a table with 2 columns (for the dummy and continuous W regression), without the results of xtreg (because too long), but only containing the results of the linear commands in each column?
    These postestimation results should include the coefficient, stars for significance level and the standard errors.

    I would be very grateful for any help,
    Ariane


  • #2
    . eststo e1: ...

    then

    . estimates restore e1

    before the lincom.

    You can store the lincoms in a matrix or as scalars and then create a table using those.



    Comment


    • #3
      Thank you Professor Ford!

      I managed with your instructions, but have one remaining problem. Here is the code for all three regressions :
      Code:
      *for W
      eststo est1: xtreg Drevenue c.D_2021_2022#c.f_2021 /// 
      c.D_2020_2022#c.f_2020 c.D_2020_2022#c.f_2021  ///
      c.D_2019_2022#c.f_2019 c.D_2019_2022#c.f_2020 c.D_2019_2022#c.f_2021  ///
      c.D_2018_2022#c.f_2018 c.D_2018_2022#c.f_2019 c.D_2018_2022#c.f_2020 c.D_2018_2022#c.f_2021  ///
      ... i.year, fe vce(cluster id)
      
      estimates restore est1
      xlincom (E2021 = c.D_2021_2022#c.f_2021) (E2020 = (c.D_2020_2022#c.f_2020 + c.D_2020_2022#c.f_2021) / 2) (E2019 = (c.D_2019_2022#c.f_2019 + c.D_2019_2022#c.f_2020 + c.D_2019_2022#c.f_2021)/ 3)
      (E2018 = (c.D_2018_2022#c.f_2018 + c.D_2018_2022#c.f_2019 + c.D_2018_2022#c.f_2020 + c.D_2018_2022#c.f_2021) / 4 ) (E2017 = (c.D_2017_2022#c.f_2017 + c.D_2017_2022#c.f_2018 + c.D_2017_2022#c.f_2019
      + c.D_2017_2022#c.f_2020 + c.D_2017_2022#c.f_2021 + c.D_2017_2021#c.f_2017 + c.D_2017_2021#c.f_2018 + c.D_2017_2021#c.f_2019 + c.D_2017_2021#c.f_2020) / 9) .... , post
      eststo W
      
      * for W_cl
      eststo est2: xtreg Drevenue c.W_cl#c.D_2021_2022#c.f_2021 /// 
      c.W_cl#c.D_2020_2022#c.f_2020 c.W_cl#c.D_2020_2022#c.f_2021  /// 
      c.W_cl#c.D_2019_2022#c.f_2019 c.W_cl#c.D_2019_2022#c.f_2020 c.W_cl#c.D_2019_2022#c.f_2021 ... i.year, fe vce(cluster id)
      estimates restore est2
      
      xlincom (E2021 = c.D_2021_2022#c.f_2021) (E2020 = (c.D_2020_2022#c.f_2020 + c.D_2020_2022#c.f_2021) / 2) (E2019 = (c.D_2019_2022#c.f_2019 + c.D_2019_2022#c.f_2020 + c.D_2019_2022#c.f_2021)/ 3)
      (E2018 = (c.D_2018_2022#c.f_2018 + c.D_2018_2022#c.f_2019 + c.D_2018_2022#c.f_2020 + c.D_2018_2022#c.f_2021) / 4 ) (E2017 = (c.D_2017_2022#c.f_2017 + c.D_2017_2022#c.f_2018 + c.D_2017_2022#c.f_2019
      + c.D_2017_2022#c.f_2020 + c.D_2017_2022#c.f_2021 + c.D_2017_2021#c.f_2017 + c.D_2017_2021#c.f_2018 + c.D_2017_2021#c.f_2019 + c.D_2017_2021#c.f_2020) / 9) ..., post
      eststo W_cl
      
      * for W_nl
      eststo est3: xtreg Drevenue c.W_cnl#c.D_2021_2022#c.f_2021 /// 
      c.W_cnl#c.D_2020_2022#c.f_2020 c.W_cnl#c.D_2020_2022#c.f_2021 ... i.year, fe vce(cluster id)
      estimates restore est3
      
      xlincom (E2021 = c.D_2021_2022#c.f_2021) (E2020 = (c.D_2020_2022#c.f_2020 + c.D_2020_2022#c.f_2021) / 2) (E2019 = (c.D_2019_2022#c.f_2019 + c.D_2019_2022#c.f_2020 + c.D_2019_2022#c.f_2021)/ 3)
      (E2018 = (c.D_2018_2022#c.f_2018 + c.D_2018_2022#c.f_2019 + c.D_2018_2022#c.f_2020 + c.D_2018_2022#c.f_2021) / 4 ) ..., post
      eststo W_cnl
      
      esttab W W_cl W_cnl using "PerCohYear.tex", replace star(* 0.10 ** 0.05 *** 0.01) stats(N , labels("Observations" )) mlabel("Membership" "Activity" "Activity_lagged")
      My only problem is how to deal with the xlincom commands if some of those regressors are omitted for example due to collinearity?

      Thank you for your help,
      Ariane

      Comment

      Working...
      X