Github user actuaryzhang commented on the issue:

    https://github.com/apache/spark/pull/16740
  
    @sethah Your formula for offset does not seem to be a general solution, and 
I'm not sure if there exists an analytical formula, in particular when the link 
function is not identity or log. In GLM, the normal equation for the 
coefficient is: (y - mu) * w = 0. When there is offset, mu = link.inv(intcpt + 
offset). Take the case where link.inv is inverse as an example, then we have (y 
- inverse(intcpt + offset)) * w = 0. This is nonlinear and has to be solved 
iteratively, right? The following is a simple R example to show that the 
formula you provided does not recover the coefficient. 
    
    ```
    set.seed(11)
    off <- rlnorm(200)
    a <- 0.52
    mu <- 1/(a + off)
    y <- rgamma(200, 1, scale = mu)
    f <- glm(y~1, offset = off, family = Gamma())
    coef(f)
    1/mean(y - off)
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to