5
$\begingroup$

I'm currently building a prediction model in R. My output variable is the market price of an item, so the value should be greater than 0.

I am using a GLM and started with family = gaussian, but I realized that I predicted values smaller than 0. That does not make sense.

I read that family = Gamma(link = log) fits best.

Can someone explain me why Gamma is for example better than the inverse Gaussian?

Why do I use the Link= log and not Link = inverse?

$\endgroup$
2
  • $\begingroup$ That is hard to say without having a look at the data. There is no ''best fit" that works all the time. My first step would be to run a gaussian model and check if the assumptions are met. Your negative prediction might also be because of something else (e.g. error in new data). The questions you are asking are kind of 'big' and theoretical. (I think) there is no short answer to it and I might say that they are not really appropriate on this forum. You might want to read a book about. $\endgroup$
    – Ivo
    Commented Oct 4, 2016 at 14:50
  • $\begingroup$ +1 to @Glen_b's answer, but stepping back a bit: why not use a random forest? There are no either no distributional assumptions or almost no distributional assumptions. Your outcome distribution will be approximately equal to your input distribution. Gamma GLM's are certainly appropriate to a lot of problems, but if you're after atheoretic prediction and don't need to worry about repeated observations, it's often hard to beat a random forest.\ $\endgroup$ Commented Nov 14, 2017 at 18:37

1 Answer 1

4
$\begingroup$

In terms of the description of the conditional distribution, the inverse Gaussian is more skew and has a variance that increases as a higher power of the mean (the cube rather than the square).

I'd be inclined to plot log(y) against the main predictors, though particular patterns in the predictors can easily interfere with this judgement; you may have to fit a model. One easy way to do that is take logs and fit a linear regression which should be sufficient to identify heteroskedasticity, left or right skewness and suitability of a log link all at the same time. However note that if you want to perform inference -- do hypothesis testing, or calculate confidence intervals, or predictions and prediction intervals, etc then that is going to be affected by the process of model choice (all of that looking-at-the data affects the properties of your inferences). If you can do some form of data splitting -- pull off a random subset to help identify the model - that would help avoid the problem. [[You may not need a very large subsample to choose between the models.]

If the gamma is suitable the spread shouldn't change much but if the spread still increases as you go from left to right, the inverse Gaussian might capture the variance better.

In addition, the conditional distribution of the gamma should be somewhat left skew (though may be nearly symmetric) while the inverse Gaussian will be right skew.

Here's an example where you can't necessarily tell from the plot of y vs x but you can see the difference when putting a log scale on the y-axis:

Gamma and inverse Gaussian vs x with similar mean functions and log link

You can see that the gamma has essentially constant spread and (conditionally) left skewness while the inverse Gaussian has increasing spread and (conditionally) some right skewness.

(If the plot looks symmetric with constant spread you might perhaps consider a lognormal instead, though a gamma should still do quite well.)

The choice of link should relate to how you expect the relationship between the mean of the response and the independent variables (predictor variables) to operate (preferably from theory or a practical understanding of the process). However if you do a plot like the above, you should hope to see a straight line (but again, multiple predictors can conspire to interfere with this appraisal; it may be better to look at residuals from that log linear fit I mentioned before.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.