### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

Thanks Michael. I agree that it is possible to simplify the codes. Best, Zhu -Original Message- From: Michael Weylandt Sent: Monday, May 20, 2019 3:41 PM To: Wang, Zhu Cc: Ivan Krylov ; R-package-devel@r-project.org Subject: Re: [R-pkg-devel] How to obtain intercept of

### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

Negative binomial is a bit trickier since it's a two parameter family without a closed-form MLE. For the probability parameter, you can use the closed form MLE at https://en.wikipedia.org/wiki/Negative_binomial_distribution#Maximum_likelihood_estimation For the number of samples, you'll need to

### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

Thanks Michael. I also need an intercept-only negative binomial model with unknown scale parameter. So my thought was on borrowing some codes that already existed. I think Ivan's solution is an excellent one and can be extended to other scenarios. Best, Zhu On May 11, 2019, at 9:48 AM,

### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

On Sat, May 11, 2019 at 8:28 AM Wang, Zhu wrote: > > I am open to whatever suggestions but I am not aware a simple closed-form > solution for my original question. > > It would help if you could clarify your original question a bit more, but for at least the main three GLMs, there are closed

### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

Ivan's answer is very impressive. Michael, I am open to whatever suggestions but I am not aware a simple closed-form solution for my original question. Thanks, Zhu > On May 11, 2019, at 8:01 AM, Michael Weylandt > wrote: > > This is very cool, but I wonder if it isn't over-kill for the

### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

This is very cool, but I wonder if it isn't over-kill for the larger problem. In general, calculating the coefficient of an intercept-only GLM is just calculating (a transformation of) the MLE of a univariate exponential family distribution. (Things may be a bit trickier if the GLM also involves

### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

On Fri, 10 May 2019 16:17:42 + "Wang, Zhu" wrote: > Are there any examples or links for me to follow through more closely? Calling R functions from C++ is described at and elsewhere in Rcpp documentation. An example follows:

### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

Thanks Ivan for the tip. Are there any examples or links for me to follow through more closely? Thanks, Zhu -Original Message- From: Ivan Krylov Sent: Monday, May 6, 2019 4:14 AM To: Wang, Zhu Cc: R-package-devel@r-project.org Subject: Re: [R-pkg-devel] How to obtain intercept of

### Re: [R-pkg-devel] How to obtain intercept of intercept-only glm in Fortran?

On Sat, 4 May 2019 22:41:16 + "Wang, Zhu" wrote: > In an R package I would like to compute intercept for an > intercept-only GLM in a Fortran subroutine. If all else fails, you could use R API [*] to call coef(glm.fit(...)), though it might require writing a C or C++ wrapper to avoid