6
$\begingroup$

I am learning about Generalized Linear Models and the use of the R statistical package, but, unfortunately, I am unable to understand some fundamental concepts.

I am trying to develop a GLM - Poisson model but using a specific log link function. The function is of the form

$$\ln(E(y_i)) = \ln(\beta_1) + \beta_2 \ln(\text{exp}_1) + \beta_3 \ln(\text{exp}_2).$$

In this equation, $\text{exp}_1$ and $\text{exp}_2$ are measures of exposure in the model. From my understanding, in R, I would first load all the data and ensure it was properly set-up. I then believe I should be running:

model = glm(formula = Y~exp1+exp2, family=poisson(link="log"),data=CSV_table)

As I am new to GLMs and R, I am not exactly sure what specifying poisson(link="log") does. I hope this question isn't too trivial. I have been trying to google clear concise explanations online for hours; however many answers/links assume a level of knowledge higher than mine.

$\endgroup$
  • $\begingroup$ Are you sure you want the log transforms of your RHS values? That is permissible, but would be unusual. Moreover, it doesn't make any sense to think in terms of taking the log of your intercept (ie, $\ln(\beta_1)$). $\endgroup$ – gung - Reinstate Monica Oct 3 '13 at 20:56
  • $\begingroup$ Yah, the model is supposed to be that way. I think that the intercept is log'd as well because the intercept has meaning (relative to the exposure, which is also being log'd) and is probably supposed to represent an offset or something. $\endgroup$ – Matthew Oct 4 '13 at 14:30
  • $\begingroup$ An offset is a variable; that is, you have different values of the offset for different observations. An intercept is a constant; it is just a number. The log of a number is just another number, taking the log doesn't add anything meaningful; you could just as well subtract 2 from the intercept. It may help you to read my answer here. Although it's not specific to your question, it does talk a little bit about Poisson regression & may help w/ general understanding. $\endgroup$ – gung - Reinstate Monica Oct 4 '13 at 15:09
  • $\begingroup$ Yes, I understand that logging a constant just generates a constant, however in the context of the fact that the only two variables in the model are exposures and since they also have the same units, the intercept in my mind could be interpreted in relation to the exposures (in this context only though), and that relation may be more obvious if you consider it as a ln(). I dunno though, I didn't write the model's equation. $\endgroup$ – Matthew Oct 5 '13 at 2:51
4
$\begingroup$

There are three components to the GLM: an outcome variable, a linear predictor and a link function. The link function in the GLM relates the expected value of the outcome variable to the linear predictor. In other words, not the expected value itself, but a function of it is modeled by the linear predictor. An example with the logarithm as the link function and the linear predictor $\beta_0 + \beta_1*x$ is:

$$\log(E(y)) = \beta_0 + \beta_1*x$$

In your case, the linear predictor is $\log(\beta_0) + \beta_1*\log({\rm exp}_1) + \beta_2*\log({\rm exp}_2)$. So the equation for your model becomes:

$$\log(E(y)) = \log(\beta_0) + \beta_1*\log({\rm exp}_1) + \beta_2*\log({\rm exp}_2)$$

I think this is a bit weird and I would argue that possibly that's not the model you are supposed to fit. Anyway, to fit this model with R, the code should look like this:

model <- glm(formula = Y ~ log(exp1) + log(exp2), family = poisson(link="log"), 
             data = CSV_table)

The only thing you have to take care of after running the model is to take the exponential function of the intercept, if you want to write the intercept as a log. A good book if you want to learn about the GLM and categorical data analysis in general is the one by Agresti (2007).

References:

Agresti, A. (1996). An introduction to categorical data analysis (Vol. 135). New York: Wiley.

$\endgroup$
  • 3
    $\begingroup$ The code in the question is incorrect, because it implements the model $\log(E(y_i))=\beta_0 + \beta_1 \text{exp}_1 + \beta_2 \text{exp}_2.$ Note the two distinct differences: $\beta_0$ is not $B_1$ and, more importantly, the variables are not the ones intended. $\endgroup$ – whuber Oct 3 '13 at 17:41
  • $\begingroup$ @whuber I agree. I also think that the model that you specified in your comment is the one that is implemented with the code. I also think that's what Matthew wants. It's not the same as what he gave us in his question, but probably because he didn't know how to handle the link function. Feel free to write an answer if you disagree. I might be wrong. In this case I will just delete my answer. $\endgroup$ – Jens Kouros Oct 3 '13 at 17:51
  • $\begingroup$ I understand and appreciate your interpretation, Jens, and would like to encourage you to clarify that aspect of your answer so that others will be less likely to misunderstand it as I did. $\endgroup$ – whuber Oct 3 '13 at 17:57
  • 1
    $\begingroup$ I apologize, I wrote B because I was lazy. B is actually Beta. My link equation is specified for me though, so I cannot drop the logs/lns unless it is synonomous. I have updated the function to exactly match what it is supposed to be. $\endgroup$ – Matthew Oct 3 '13 at 19:00
  • $\begingroup$ Could you clarify? So, the equation that you wrote down is the one that you have to model? $\endgroup$ – Jens Kouros Oct 3 '13 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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