[R] weights vs. offset (negative binomial regression)
유준택
yjt7660 @end|ng |rom gm@||@com
Sat Oct 28 09:30:22 CEST 2023
Colleagues,
I have a dataset that includes five variables.
- Catch: the catch number counted in some species (ind.)
- Effort: fishing effort (the number of fishing vessels)
- xx1, xx2, xx3: some environmental factors
As an overdispersion test on the “Catch” variable, I modeled with negative
binomial distribution using a GLM. The “Effort” variable showed a gradually
decreasing trend during the study period. I was able to get the results I
wanted when considered “Effort” function as a weights function in the
negative binomial regression as follows:
library(qcc)
Catch=c(25,2,7,6,75,5,1,4,66,15,9,25,40,8,7,4,36,11,1,14,141,9,74,38,126,3)
Effort=c(258,258,258,258,258,258,258,254,252,252,252,252,252,252,252,252,252,252,252,248,246,246,246,246,246,246)
xx1=c(0.8,0.5,1.2,0.5,1.1,1.1,1.0,0.6,0.9,0.5,1.2,0.6,1.2,0.7,1.0,0.6,1.6,0.7,0.8,0.6,1.7,0.9,1.1,0.5,1.4,0.5)
xx2=c(1.7,1.6,2.7,2.6,1.5,1.5,2.8,2.5,1.7,1.9,2.2,2.4,1.6,1.4,3.0,2.4,1.4,1.5,2.2,2.3,1.7,1.7,1.9,1.9,1.4,1.4)
xx3=c(188,40,2,10,210,102,117,14,141,28,48,15,220,115,10,14,320,20,3,10,400,150,145,160,460,66)
#
edata <- data.frame(Catch, Effort, xx1, xx2, xx3)
#
qcc.overdispersion.test(edata$Catch, type="poisson")
#
summary(glm.nb(Catch~xx1+xx2+xx3, weights=Effort, data=edata))
summary(glm.nb(Catch~xx1+xx2+xx3+offset(log(Effort)), data=edata))
I am not sure the application of the weights function to the negative
binomial regression is correct. Also I wonder if there is a better way
doing this. Can anyone help?
[[alternative HTML version deleted]]
More information about the R-help
mailing list