# How to get fitted values, prediction, and residual plots for Exponential GLM?

To get Exponential GLM, you can do:

fit = glm(formula =..., family = Gamma)

summary(fit, dispersion=1)

But how do you get the fitted values, prediction using new data, and Pearson's residuals easily? I used to do fitted.values(fit), predict(fit, newdata, type = 'response'), and residual(fit, type = 'pearson') after fitting a GLM as the object fit. But this isn't fitting an Exponential GLM to the object fit...

• This appears to be a question only about how to use these R functions (& hence off topic here). – gung - Reinstate Monica Dec 7 '16 at 22:08
• @gung I believe there's an underlying statistical issue to explain here. This question could be modified to reflect that aspect and some of the present question relating to R functionality is then partly moot -- the remainder could be posted as a new question. – Glen_b -Reinstate Monica Dec 8 '16 at 4:14
• I'd be happy with this question if it were edited to focus on the underlying statistical issue. – gung - Reinstate Monica Dec 8 '16 at 12:54

## 1 Answer

The distinction between exponential and general gamma has no impact on the fitted or predicted values from the GLM. So you can calculated them as normal.

Depending on how exactly you want to define Pearson residuals, it may impact the Pearson residuals by a scale factor related to the square root of the estimated deviance. Any plots based on Pearson residuals will have the same appearance either way, so unless you're calculating some quantity based on the Pearson residual it probably won't matter. However they can be rescaled by the square root of the ratio of deviances as desired (R doesn't seem to adjust its Pearson residuals by an estimated dispersion in any case, so it should make no difference).

• Thanks. My response has 0's in it. When I fit a Gamma GLM, I got this error "Error in eval(expr, envir, enclos) : non-positive values not allowed for the 'gamma' family". I wanted to use Exponential distribution because 0 is in the support. – hiya Dec 8 '16 at 4:55
• Actually, you should have exactly the same problem with exponential as with the Gamma, because in both cases the support is the same -- $(0,\infty)$ (don't believe Wikipedia's page on the exponential in this regard; you can't have exact zeros with the exponential) – Glen_b -Reinstate Monica Dec 8 '16 at 5:08
• @ Glen_b: Gah, you're right; I wasn't thinking. I guess my only option for continuous response is Tweedie. – hiya Dec 8 '16 at 5:11
• Hardly your only option. I'd think zero-inflated or hurdle models; the problem with Tweedie is that a $p$ parameter than matches the proportion of zeros well is rarely one that matches the rest of the distribution well. – Glen_b -Reinstate Monica Dec 8 '16 at 5:17
• @ Glen_b: Actually, 0 is allowed in the support of exponential distribution. I looked at a textbook. Yeah, I think I need a zero-inflated model of some sort because the histogram of the response seems spiked towards 0. Hmmm...I guess Tweedie is not good for prediction a lot of the times? – hiya Dec 8 '16 at 5:20