11
$\begingroup$

I am carrying out research to look at differences in fish density and fish species richness when using two different underwater visual census methods. My data was originally count data but then typically this is changed to fish density but I have still decided to use a Poisson GLM, which I hope is right.

model1 <- glm(g_den ~ method + site + depth, poisson)

My 3 predictor variables are method, site and depth which I ordered as factors when I input them.

My response variables are grouper species richness, grouper density and the same for other fish groups. I am aware that density is not an integer and it is numerical data e.g 1.34849. I am now however getting this error:

In dpois(y, mu, log = TRUE) : non-integer x = 0.037500

I've been reading up and many people suggest using an offset, is this the most advisable thing to do?

$\endgroup$
  • 1
    $\begingroup$ This isn't really about how to use R. This is a basic statistical question disguised as an R question. It should be on topic here. $\endgroup$ – gung - Reinstate Monica Aug 31 '16 at 17:46
11
$\begingroup$

There are several issues here:

  1. You need to use the observed counts as your response variable. You should not use the densities (g_den).
  2. If the observed counts are from differing areas, you need to take the log of those areas as a new variable:

    larea = log(area)
    
  3. You can control for the differing areas for the observations in two different ways:

    • By using larea as an offset. This will make your response actually a rate (even though what is listed on the left hand side of your model is a count).
    • By using larea as a covariate. This will control for the differing areas, but will not make your response equivalent to a rate. This is a more flexible approach that will let you assess if increases in larea have an increasing or decreasing effect on the count (i.e., whether the slope is less than or greater than 1).

There is more information about these issues in the following CV threads:

$\endgroup$
6
$\begingroup$

It looks like you divided the fish counts by the volume (or perhaps area) of water surveyed. In that case an offset is indeed appropriate, you should use the log of whatever you divided by. Perhaps

model1 <- glm(g_den ~ method + site + depth + offset(log(area)), poisson)

(edited from earlier incorrect version, missing the log)

The reason for the error message is that the poisson distribution is normally integer-valued but the response wasn't an integer. This changes once an offset is present; (response/offset) must be an integer (which of course it is, assuming the original counts were integers).

$\endgroup$
  • 2
    $\begingroup$ You mention that you should use the log transformation of area (as the Poisson model uses the log link) in your answer but your code doesn't do the transformation. I don't think offset applies the transformation by default but it has been a while since I've used offset. $\endgroup$ – iacobus Aug 31 '16 at 15:34
  • 3
    $\begingroup$ Note that offset() does not apply the transformation by default; it merely forces the coefficient to be 1. See, eg, here. $\endgroup$ – gung - Reinstate Monica Aug 31 '16 at 17:49
  • 1
    $\begingroup$ Thanks for the comments. So should I change my data back to counts rather than densities and include area as a separate variable? I have also been advised on another forum to do a gamma or inverse Gaussian model and change my zero values to 0.00001 if I were to keep the data as densities, do you think that would also be appropriate? $\endgroup$ – Vivienne Sep 1 '16 at 7:40
  • 3
    $\begingroup$ @JDL It is not right to keep the non-integer density as the response once log(area) is included as an offset. The log link-function and the log(area) offset amounts to the a priori reasonable assumtion that $E(\mathrm{count}) = \exp(\beta^T x)\mathrm{area} = \exp(\beta^T x + \log(\mathrm{area}))$, that is, direct proportionality the expected number of fish and the size of each area. This implies that the expected density $E(\mathrm{count}/\mathrm{area}) = E(\mathrm{count})/\mathrm{area} = \exp(\beta^T x)$ is independent of log(area). $\endgroup$ – Jarle Tufto Sep 1 '16 at 11:36
  • 4
    $\begingroup$ You cannot use the densities as the response. You must use the original counts as your response. Including the offset will automatically make the count response equivalent to densities in the correct manner. $\endgroup$ – gung - Reinstate Monica Sep 1 '16 at 14:51
5
$\begingroup$

If you are going to model using the Poisson you have to have integer values for your response variable. You then have two options

  • Use area or some other suitable denominator as an offset. This would usually need to be logged first
  • Include area or etc as a predictor variable. Again this would usually be included as a log because you are modelling the log counts.

If you use the offset approach you are saying that if I double the area I would expect to get double the count. If you use the predictor approach you are sayinh that you know iif you multiply the area you multiply the counts but not necessarily by the same factor.

It is your call.

$\endgroup$

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.