Announcement

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

  • nlcom - I cannot analytically derive the s.e. that I get from 'nlcom' using the Delta method

    <RESOLVED>

    I wanted to confirm that the result (s.e.) that I get from nlcom is the same as what I get from using the exact formula based on the Delta method (GVG'). But for the function of interest, I was never getting the result that I expect. The regression is as simple as: y = a + bT + e. The object of interest is g = b/a.

    Here is my algebra. Partial derivatives: g1 = -b/a^2, g2 = 1/a.
    Let V(a,b) = (s1, s12; s12, s2). Then var(g) = GVG' = s1*g1^2 + 2*s12*g1*g2 + s2*g2^2.

    I am curious if my algebra is wrong, or the nlcom command of Stata uses a different formula. (I even derived the messy algebra of 2nd order Delta method, but still that didn't match the result from nlcom.) BTW I know that it may not be a good idea to use Delta method here where the denominator is a random variable that can potentially take a value around zero. Is it possible that nlcom somehow takes this into account and does something else (which I doubt)?

    Code:
    clear
    set obs 6
    gen ti = cond(_n<=_N/2,0,1)
    gen y = _n - 2*ti
    // (0,1), (0,2), (0,3), (1,2), (1,3), (1,4)
    
    reg y ti
    local b_phi = _b[ti] / _b[_cons]
    local h1 = (-_b[ti]) / _b[_cons]^2
    local h2 = 1 / _b[_cons]
    local s1 = e(V)[1,1]
    local s12 = e(V)[1,2]
    local s2 = e(V)[2,2]
    local v_phi = (`h1')^2*(`s1') + 2*(`h1')*(`h2')*(`s12') + (`h2')^2*(`s2')
    local se_phi = sqrt(`v_phi')
    disp "h1 h2: [" `h1' ", " `h2' "]"
    disp "s1 s12 s2: [" `s1' ", " `s12' ", " `s2' "]"
    disp "bhat, ahat, b_phi, se_phi, v_phi: [" _b[ti] ", " _b[_cons] ", " `b_phi' ", " `se_phi' ", " `v_phi' "]"
    
    nlcom (g: _b[ti]/_b[_cons]), post
    local v_g = e(V)[1,1]
    disp "b_g, se_g, v_g: [" _b[g] ", " _se[g] ", " `v_g' "]"
    Result:
    bhat, ahat, b_phi, se_phi, v_phi: [1, 2, .5, .45643546, .20833333]
    b_g, se_g, v_g: [.5, .5204165, .27083333]
    Last edited by Dohyeon Lee; 27 Feb 2024, 00:29.

  • #2
    Shoot.... Soon after I hit the post button, I realized that there was one final thing that I didn't check carefully.
    I tried changing the order of index and now I got the same result.
    Looking for the delete button but I cannot find one

    Comment


    • #3
      Donhyeon:
      there's no such a thing as a "delete button".
      You can edit your message within 1 hour after posting it.
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment

      Working...
      X