There is no way to use the average of the two observations and at the same time use the Poisson distribution. You might try to figure out what the probability distribution of the average of two Poisson i.i.d random variables is, but I think this is not the best way out.
For me, the best way out would be to use a model of repeated measures, and consider a random effect of individual for each day.
For this, considering that you have a database as follows:
> dados <- data.frame(
+ id = 1:100,
+ explicativa = runif(100, 0, 20)
+ )
>
> dados$r1 <- rpois(100, dados$explicativa)
> dados$r2 <- rpois(100, dados$explicativa)
>
> head(dados)
id explicativa r1 r2
1 1 9.082513 16 14
2 2 17.741123 14 29
3 3 10.819865 13 12
4 4 18.527938 22 25
5 5 4.828392 6 7
6 6 13.986794 14 15
r1
and r2
are the frequencies observed on day 1 and day 2.
Turn your data into format tidy/long
:
library(tidyr);library(dplyr)
dados <- dados %>% gather(dia, resposta, starts_with("r"))
Then adjust a model as follows:
library(lme4)
modelo <- glmer(resposta ~ explicativa + (0 + dia | id), data = dados, family = poisson)
Thus, you will be considering that for each individual there is a random variation related to the day it is being measured.
You need to go into more detail about your question. Not getting why? Get an error? Your doubt is even of programming, in relation to the code of analysis (or its result), or statistics?
– Molx
Hello Erlon, thank you for your interest. My counting data is not integer numbers because it is averages. So when I do GLM with Poisson distribution, link=log, it gives error. For example: al1<-glm(cbind(al)~sp*sex,Poisson(link="log"),data=abfm) Warning messages: 1: In dpois(y, mu, log = TRUE) : non-integer x = 4,500000 2: In dpois(y, mu, log = TRUE) : non-integer x = 7,500000
– Bruna
Bruna, edit these details in the question itself, trying to clarify your problem, as @Molx suggested!
– Carlos Cinelli
I tried to edit the question, but it was rejected. for me, it’s a shame that question is deleted...
– Daniel Falbel
Was she excluded? I did not delete....
– Bruna
@Danielfalbel the question will not be deleted, it is only pending for edits to occur before new answers appear (otherwise it could happen like that other question you answered but the guy was asking something else!). Try to edit again, if it doesn’t work, anything pass me the details of the edition I edit and we vote to reopen the question!
– Carlos Cinelli
@Carloscinelli has now accepted the edition. We will try to reopen?
– Daniel Falbel
@Danielfalbel thanks, I voted to reopen, already has 3 votes
– Carlos Cinelli