# Confusion related to generalized linear model example

Ordinary linear regression predicts the expected value of a given unknown quantity (the response variable, a random variable) as a linear combination of a set of observed values (predictors). This implies that a constant change in a predictor leads to a constant change in the response variable (i.e. a linear-response model). This is appropriate when the response variable has a normal distribution (intuitively, when a response variable can vary essentially indefinitely in either direction with no fixed "zero value", or more generally for any quantity that only varies by a relatively small amount, e.g. human heights).

However, these assumptions are inappropriate for many types of response variables. For example, in many cases when the response variable must be positive and can vary over a wide scale, constant input changes lead to geometrically varying rather than constantly varying output changes. As an example, a model that predicts that each increase in 10 degrees leads to 1,000 more people going to a given beach is unlikely to generalize well over both small beaches (e.g. those where the expected attendance was 50 at the lower temperature) and large beaches (e.g. those where the expected attendance was 10,000 at the lower temperature). An even worse problem is that, since the model also implies that a drop in 10 degrees leads 1,000 fewer people going to a given beach, a beach whose expected attendance was 50 at the higher temperature would now be predicted to have the impossible attendance value of -950! Logically, a more realistic model would instead predict a constant rate of increased beach attendance (e.g. an increase in 10 degrees leads to a doubling in beach attendance, and a drop in 10 degrees leads to a halving in attendance). Such a model is termed an exponential-response model (or log-linear model, since the logarithm of the response is predicted to vary linearly).

I actually didn't get the example given. For two different types of beaches, I will have two different models.

For big beach

y = 1000x


For small beach

y = 50x


So if x raises by 10, y will be impacted accordingly in the two beaches. I didn't get what they are trying to do. Any clarifications?

They have given that if they use the exponential function like $$e^{Xb}$$ it will solve the issue. But I don't know how. Suppose the temperature X=1, b=1 lest suppose then y = 2.7183. Now suppose the temperature is raised by let's say 10. then it will be $$e^{11}$$ = 5.9874e+04. The response is not doubled and they were looking something like this.

I am confused.

My less-technical explanation: Actually, you are approaching their answer. You realize that the formula for a large beach doesn't work well for a small beach, so you make a second model. But neither of these models will work well for a medium beach, so you add a third. None of these works well for a huge beach, so you add a fourth. If you get picky, you end up with models for micro, medium-large and extra-large beaches, too.

Why the proliferation of models? If you take each one and calculate the population increase from a 1-degree increase, and plot these from smallest to largest, you'll see that it's not linear. It's exponential and its slope increases as the size increases. (You see that already $50x$ versus $1000x$.)

What your quote is describing is a multiplicative model, which is based not on absolute values but percentages. Which is exactly what you were trying to do (the hard way): an $x$-percent increase at a small beach is a small number, while at a large beach it is a large number. You're just trying to imitate this percentage-based increase by using a bunch absolute-based increase models.

EDIT: Think of the combinations of action and reaction you expect to see in the world:

1. "If temperature increases 1 degree, the number of people at this beach will increase by approximately 100 people"
2. "If the temperature increases 1 percent, the number of people at this beach will increase by approximately 1 percent"
3. "If the temperature increases by 1 degree, the number of people at this beach will increase by approximately 1 percent"
4. "If the temperature increases 1 percent, the number of people at this beach will increase by approximately 100 people"

You are proposing that you can use #1 in any situation, but the quote is describing a situation where reality more closely resembles #2.

• +1, your list provides a nice, clear way to understand the distinction. Commented Jun 9, 2013 at 19:07

The 'geometric' change with constant input means that it will change by a constant proportion, or factor, rather than by a constant additive amount. For example, if the old value is $y_{old}$ and $x$ goes up by 1, there will be an $\exp(\beta)$-fold change in $y$. That is, the new $y_{new}=\exp(\beta)y_{old}$. On the other hand, if the change were additive, it would be $y_{new}=y_{old}+\beta$ instead. In your example, you're using the wrong value for b (presumably b1, note that you also need a b0). Try the following (in R code, let me know if it's not transparent):

> b1 = 0.06931472   # this is the appropriate b1, not b1=1
> b0 = 1-b1         # here I make the constant
> X  = 1
> exp(b0 + b1*X)
[1] 2.718282        # this calculation gives you your original y
> X  = 11           # now we've incremented X by 10,
> exp(b0 + b1*X)
[1] 5.436564        # and y has doubled
> X  = 21           # we can go up by another 10,
> exp(b0 + b1*X)
[1] 10.87313        # and y doubles again


Here's a quick way to create your own examples:

> y1 = 2.7183           # this is the number you want y to be when X=1
> foldIncrease = 2      # this is the multiple by which you want y to go up
> y2 = y1*foldIncrease  # now we've created y_new
> xUnits = 10           # this is the number of units that X will go up to get to y_new

> b1 = (log(y2)-log(y)) / xUnits
> b1
[1] 0.06931472          # now we've calculated the appropriate b1
> b0 = log(y1)-b1
> b0
[1] 0.930692            # this gives us the appropriate value for b0