<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)?
Result:
bhat, ahat, b_phi, se_phi, v_phi: [1, 2, .5, .45643546, .20833333]
b_g, se_g, v_g: [.5, .5204165, .27083333]
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' "]"
bhat, ahat, b_phi, se_phi, v_phi: [1, 2, .5, .45643546, .20833333]
b_g, se_g, v_g: [.5, .5204165, .27083333]
Comment