Announcement

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

  • Access and save estimates after xlincom

    Dear Statalist,

    I am trying to run a linear regression, estimate the standard error of the sum of two coefficients via xlincom, and save the standard error as a separate variable.
    My code is as follows:

    Code:
    sysuse auto2, clear
    ssc install xlincom
    reg price i.rep78##c.weight, coefl
    g var=0
    foreach x of numlist 2(1)5{
        xlincom name`x' = _b[`x'.rep78] + _b[`x'.rep78#c.weight], repost
        replace var=_se[name`x'] if rep78 == `x'
    }
    It produces the error
    Code:
    [name2] not found
    even though I can see from matrix list e(b) that name2 is, in fact, stored in e(b).
    I'm really puzzled as to why I get the error.
    Any lead about how to solve this problem, or a different approach would be appreciated.
    Thank you,

    Valentina





  • #2
    If you are using the -repost- option, then -xlincom- adds the estimation results to the prior estimation results. You can inspect those results using

    Code:
    eret list
    matlist e(b)
    Your results will then be prefixed by "xlincom:", as if it was another equation in your model. So you can access them for example as

    Code:
    di _b[xlincom:name2], _se[xlincom:name2]
    If however you use the -post- option of -xlincom-, there is no need for the "xlincom:' prefix.

    Code:
    di _b[name2], _se[name2]

    Comment


    • #3
      Thanks a lot Leonardo! Indeed using [xlincom:name2] solved the problem.

      Comment

      Working...
      X