3
$\begingroup$

For a negative binomial GLM, are we allowed to write the log transformation in the following way?

library(MASS)
nb.fit <- glm.nb(y~log(X1)+log(X2)+X3+X4+log(X5),maxit=1000, data=df)
chisq.p.value <- pchisq(deviance(nb.fit ), df.residual(nb.fit), lower = F)
chisq.p.value

Here X3 and X4 have pretty low values compared to X1, X2, and X5. Y is a count response with extremely high variance with no zero responses. How can I check that my model fits the data well?

Since chisq.p.value = 0.22078 (p> 0.05), can we say our model fits the data well?

$\endgroup$
0
1
$\begingroup$

Your initial question is ambiguous. I think you are asking if using the log within the model formula replicates the link function. If so, the answer is no. The link function (which in this case is the log) is a transformation of the predicted mean, not of your covariates. Although written in a different context, it may be helpful to read my answer to: Difference between logit and probit models. You might also be asking if it is allowed to use transformations, or logarithmic transformations specifically, of predictor variables. If so, the answer is yes, there is no problem with using logs of X's. Regarding their interpretations, you may want to read: Interpretation of log transformed predictor and/or response. Lastly, if you are asking if R allows you to use the log() function within the formula argument to a standard model function, the answer is also yes (after all, you just did it and it worked).

You cannot compare the raw values of the estimated coefficients for untransformed and log transformed variables. They don't mean the same thing (see link above). In addition, you shouldn't generally compare coefficients for different variables, as they are usually in incommensurate units.

Finally, the test you conduct manually at the end is not a test of goodness of fit in the sense you are thinking. Instead, it is a test of the model as a whole (see: Test GLM model using null and model deviances). The fact that it isn't significant implies your model doesn't have much information about the response. (That doesn't mean it's a bad fit, though!) To test goodness of fit, you need to compare the fitted model to the saturated model (cf., Test logistic regression model using residual deviance and degrees of freedom). But in general, I think the best way to assess fit is to plot your data with the model and a LOWESS fit overlaid, and see how they compare.

$\endgroup$
5
  • $\begingroup$ Thank you so much for your elaborate response. However, I am not quite sure how can I compare the fitted model to the saturated model in R. I was wondering if you could provide some suggestions on that. $\endgroup$ – Simpson's Paradox Sep 13 '20 at 4:03
  • $\begingroup$ @Barsal, it's discussed in the last link (test lr mod...). However, I'm not a fan of doing it. We know from Box that "All models are wrong, but some models are useful". So if you test for goodness of fit (really badness of fit), you will either get a significant result (correct decision) or a non-significant result (type II error). Asking if you have enough data to detect the lack of fit that is in your model is a silly question. Instead, it is sensible to ask how much & what kind of lack of fit is there, & is that important in your situation. If you want more detail, you should ask a new Q. $\endgroup$ – gung - Reinstate Monica Sep 13 '20 at 12:25
  • $\begingroup$ In linear regression, we can say R^2 or adjusted R^2 > .90 means our model was good to fit the data. Is there any evaluation criteria available in GLM to make such comments? The reviewer wanted to see that my model fits the data well. I am kinda puzzled to address this. $\endgroup$ – Simpson's Paradox Sep 13 '20 at 13:47
  • $\begingroup$ @Barsal, you should ask a new question for that. I've seen comments like the reviewer's before, but I don't agree with them. In addition, "we can say R^2 or adjusted R^2 > .90 means our model was good to fit the data" is not correct. $\endgroup$ – gung - Reinstate Monica Sep 13 '20 at 14:18
  • $\begingroup$ @ gung - Reinstate Monica I am going to ask another question. Thanks! $\endgroup$ – Simpson's Paradox Sep 13 '20 at 14:39

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.