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

Wang, Zhu w@ngz1 @end|ng |rom uth@c@@@edu
Sat May 11 18:10:40 CEST 2019


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, Michael Weylandt <michael.weylandt using gmail.com<mailto:michael.weylandt using gmail.com>> wrote:

On Sat, May 11, 2019 at 8:28 AM Wang, Zhu <wangz1 using uthscsa.edu<mailto:wangz1 using uthscsa.edu>> 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 form solutions, based on means of y. Assuming canonical links,

- Gaussian: intercept = mean(y)
- Logistic: intercept = logit(mean(y))  [Note that you have problems here if your data is all 0 or all 1]
- Poisson: intercept = log(mean(y)) [You have problems here if your data is all 0]

(Check my math on these, but I'm pretty sure this is right.)

Like I said above, this gets trickier if you add observation weights or offsets, but the same ideas work.

Stepping back to the statistical theory: GLMs predict the mean of y, conditional on x. If x doesn't vary (intercept only model), then the GLM is just predicting the mean of y and the MLE for the mean of y is exactly that under standard GLM assumptions - the sample mean of y.

We then just have to use the link function and its inverse to transform to and from the observation space (where mean(y) lives) and the linear predictor space (where the intercept term naturally lives).

Michael

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list