![](/img/trans.png)
[英]Getting error messages when comparing negative binomial models (glm.nb) using aictab
[英]Getting AICc for multiple negative binomial glm models
我已經在六個候選GLM模型的列表上運行R中的函數“ aictab”(九次使用九個不同的響應變量)。 我的響應變量分布為Gamma或負二項式。 (我使用負二項式錯誤結構,因為我計算出的數據過於分散。)aictab函數的效果很好,並為我提供了帶有Gamma錯誤結構的模型的表,其中包含AICc值,模型權重等,但是當我嘗試在具有負二項式錯誤結構的模型上運行該函數時,我意識到aictab()不支持這種類型的錯誤結構,並且我無法獲得AICc或模型權重。
我的問題是:對於否定的二項式GLM模型,我還能使用哪些其他函數或代碼來獲得aictab函數的等效輸出? 代碼/錯誤示例如下。
setwd('C:/Users/Laura/Desktop/')
library(ggplot2)
library(Hmisc)
library(psych)
library(multcomp)
library(gridExtra)
library(lmerTest)
library(plotrix)
library(stats)
library(stats4)
library(gplots)
library(sciplot)
library(lme4)
library(lmerTest)
library(AICcmodavg)
library(glmulti)
##########################################
indi<-read.csv("trait_data_all_years.csv", header=T)
indi$year<-as.factor(indi$year)
str(indi)
summary(indi$tot.sil)
hist(indi$tot.sil, breaks=20)
indi<-subset(indi, tot.sil!="NA")
summary(indi$tot.sil)
year_site<-glm.nb(tot.sil~year + site, data=indi)
year_site_hab<-glm.nb(tot.sil~year + site + hab, data=indi)
yearhabinteract_plus_site<-glm.nb(tot.sil~year*hab + site, data=indi)
yearsiteinteract_plus_hab<-glm.nb(tot.sil~year*site + hab, data=indi)
habsiteinteract_plus_year<-glm.nb(tot.sil~year + site*hab, data=indi)
threewayinteract<-glm.nb(tot.sil~site*hab*year, data=indi)
model.set<- list(year_site, year_site_hab, yearhabinteract_plus_site, yearsiteinteract_plus_hab, habsiteinteract_plus_year, threewayinteract)
aictab (model.set)
運行aictab(model.set)時出現此錯誤
aictab (model.set)
Error in aictab.default(model.set) :
Function not yet defined for this object class
我知道沒有所謂的aictab.default()這樣的函數,也沒有在程序中定義這樣的函數。
您應該可以使用類似
model.set <- c(year_site, year_site_hab, yearhabinteract_plus_site, yearsiteinteract_plus_hab, habsiteinteract_plus_year, threewayinteract)
AIC(model.set)
或者,year_site $ aic將返回year_site二項式GLM的AIC。 您可以對其他模型執行相同的操作來提取單個AIC。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.