我有两个符合beta
(也称为betar
)和Poisson
族的响应,我正在研究beta
分别使用和准族(计数数据过度分散)拟合加性混合模型。
我知道我可以使用同时接受和准家庭的包中的gamm
函数,但是我正在考虑它使用 PQL,并且mgcv
beta
AIC
报告的对于比较模型没有用 - 这是我分析的主要目标。
在计数响应的情况下,我知道它QAIC
已用于对过度分散的混合模型进行排名/比较,但我找不到任何说明它适用于过度分散的 GAMM 的内容。
我理解这些可能是两个问题合二为一,但它们都有一个共同的主题,即大家庭的模型选择,并且可能有不同的解决方案。下面我为每种情况提供可重复的示例。
##generate data
library(gamm4)
library(mgcv)
dat <- gamSim(1,n=400,scale=2)
dat<-subset(dat, select=c(x0,x1,x2,x3,f) )
dat$g <- as.factor(sample(1:20,400,replace=TRUE))#random factor
dat$yb<-runif(400)#yb ranges between 0-1 hence fitted with beta family
dat$f <- dat$f + model.matrix(~ g-1)%*%rnorm(20)*2
dat$yp <- rpois(400,exp(dat$f/7))#y2 is counts hence poisson family
#beta family example with gamm function (this works - however not sure if the subsequent model comparisons are valid!)
m1b<- gamm(yb~s(x0)+s(x1)+s(x2)+s(x3),family=betar(link='logit'),data=dat,random=list(g=~1))
m2b<-gamm(yb~s(x1)+s(x2)+s(x3),family=betar(link='logit'),data=dat,random=list(g=~1))
m3b<-gamm(yb~s(x0)+s(x2)+s(x3),family=betar(link='logit'),data=dat,random=list(g=~1))
#AIC to compare models
AIC(m1b,m2b,m3b)
#try the same using gamm4 (ideally)- it obviously fails with beta family.
m<-gamm4(yb~s(x0)+s(x1)+s(x2)+s(x3),family=betar(link='logit'),data=dat,random = ~ (1|g))
##Example with quassi family - yp response is overdispersed count data (may not be overdispered in this example
#example using gamm function
m1p<-gamm(yp~s(x0)+s(x1)+s(x2)+s(x3),family = quasipoisson,data=dat,random=list(g=~1))
m2p<-gamm(yp~s(x1)+s(x2)+s(x3),family = quasipoisson,data=dat,random=list(g=~1))
m3p<-gamm(yp~s(x0)+s(x2)+s(x3),family = quasipoisson,data=dat,random=list(g=~1))
#AIC to compare models
AIC(m1p,m2p,m3p)
#again the example with using gamm4 function will not work as it doesnt accept quassi falimies
m<-gamm4(yp~s(x0)+s(x1)+s(x2)+s(x3),family = quasipoisson,data=dat,random = ~ (1|g))