I understand that Gamma distribution generates only positive values. And this is reflected in R gamma
family glm
function which does not run when the dependent variable contains zeros or negative values. However, in Stata, the glm
procedure for Gamma family runs and gives output with estimated coefficents even when there are zeros in the dependent variable.
glm cost salary [pw=wg], family(gamma) link(log) exposure(exposure_time) vce(cluster unique_key)
Iteration 0: log pseudolikelihood = -1602.3771
Iteration 1: log pseudolikelihood = -1579.4773
Iteration 2: log pseudolikelihood = -1579.3417
Iteration 3: log pseudolikelihood = -1579.3417
Generalized linear models No. of obs = 22,624
Optimization : ML Residual df = 22,622
Scale parameter = .0233436
Deviance = 195.440412 (1/df) Deviance = .009039
Pearson = 504.7344288 (1/df) Pearson = .0233436
Variance function: V(u) = u^2 [Gamma]
Link function : g(u) = ln(u) [Log]
AIC = .146258
Log pseudolikelihood = -1579.341674 BIC = -215625.8
(Std. Err. adjusted for 16,223 clusters in unique_key)
------------------------------------------------------------------------------
| Robust
cost | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
salary | .0000121 2.87e-06 4.21 0.000 6.45e-06 .0000177
_cons | 4.112714 .1696957 24.24 0.000 3.780116 4.445311
ln(exposu~e) | 1 (exposure)
------------------------------------------------------------------------------
count if cost==0
9,265
It does not look like Stata drops the zero values by default.
glm cost salary [pw=wg] if cost!=0, family(gamma) link(log) exposure(exposure_time) vce(cluster unique_key)
Iteration 0: log pseudolikelihood = -1299.6486
Iteration 1: log pseudolikelihood = -1286.4665
Iteration 2: log pseudolikelihood = -1286.3631
Iteration 3: log pseudolikelihood = -1286.3631
Generalized linear models No. of obs = 13,359
Optimization : ML Residual df = 13,357
Scale parameter = .0232079
Deviance = 188.1527815 (1/df) Deviance = .0152264
Pearson = 286.780419 (1/df) Pearson = .0232079
Variance function: V(u) = u^2 [Gamma]
Link function : g(u) = ln(u) [Log]
AIC = .2084899
Log pseudolikelihood = -1286.363084 BIC = -116241.2
(Std. Err. adjusted for 8,402 clusters in unique_key)
------------------------------------------------------------------------------
| Robust
cost | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
salary | .00001 2.48e-06 4.03 0.000 5.14e-06 .0000149
_cons | 4.44726 .1527983 29.11 0.000 4.147781 4.746739
ln(exposu~e) | 1 (exposure)
------------------------------------------------------------------------------
Anyone has any idea why this is so? How exactly was the model generated in former case?