[R-sig-eco] Deviance in Multinomial Logistic Regression
Alexandre F. Souza
alexsouza.cb.ufrn.br at gmail.com
Thu Jun 1 16:34:57 CEST 2017
Hello,
I am using the following code to perform model selection on a categorical
variable with 9 levels corresponding to floristic regions. Explanatory
variables are climatic, soil, and MEMs describing spatial structure. I am
using AIC and wAIC to choose models. As far as I understood, the Deviance
should be smaller in the worse model, which would be similar to the null
model containing just the intercept, and larger in the best model. However,
the Deviance statistic, however, is increasing from the best model to the
worse model. Do anyone have any idas about what am I doing or reading wrong?
Many thanks in advance, any ideas will help
# Verify the total deviance (null model)
Null_model<-multinom(subregion~1, data=variables)
Total_deviance<-Null_model[[25]] # store the total deviance
# Prepare the models to be tested
formlist <- list() # Empty list to receive nested formulas in forward
selection
formlist[[1]]<-as.formula("subregion~AMT+APP+CEC+Sand+TAR+MEM2+MEM1+MEM3+MEM4+MEM5+MEM27+MEM24+MEM15+MEM10+MEM26+MEM16")
# Climatic/soil Productivity
formlist[[2]]<-as.formula("subregion~ElevR+ElevCV+MEM2+MEM1+MEM3+MEM4+MEM5+MEM27+MEM24+MEM15+MEM10+MEM26+MEM16")
# Topography
formlist[[3]]<-as.formula("subregion~HFP+MEM2+MEM1+MEM3+MEM4+MEM5+MEM27+MEM24+MEM15+MEM10+MEM26+MEM16")
# Human footprint
formlist[[4]]<-as.formula("subregion~AMT+APP+CEC+Sand+TAR+ElevR+ElevCV+MEM2+MEM1+MEM3+MEM4+MEM5+MEM27+MEM24+MEM15+MEM10+MEM26+MEM16")
# Productivity + Topography
formlist[[5]]<-as.formula("subregion~AMT+APP+CEC+Sand+TAR+HFP+MEM2+MEM1+MEM3+MEM4+MEM5+MEM27+MEM24+MEM15+MEM10+MEM26+MEM16")
# Productivity + HFP
formlist[[6]]<-as.formula("subregion~HFP+ElevR+ElevCV+MEM2+MEM1+MEM3+MEM4+MEM5+MEM27+MEM24+MEM15+MEM10+MEM26+MEM16")
# HFP + Topography
formlist[[7]]<-as.formula("subregion~AMT+APP+CEC+Sand+TAR+ElevR+ElevCV+HFP+MEM2+MEM1+MEM3+MEM4+MEM5+MEM27+MEM24+MEM15+MEM10+MEM26+MEM16")
# Total Contemporary Environment
formlist[[8]]<-as.formula("subregion~MEM2+MEM1+MEM3+MEM4+MEM5+MEM27+MEM24+MEM15+MEM10+MEM26+MEM16")
# Space only
# Prepare empty dataframe to receive models' results
MLRresults<-as.data.frame(matrix(nrow=8, ncol=4))
colnames(MLRresults) <- (c("Model", "Deviance", "AIC", "AICc"))
for (i in 1:8){ # the remaining variables to be forward selected
formula<-formlist[[i]]
MLR_test<-multinom(formula, data=variables)
MLRresults[i,1]<-paste(formlist[i]) # store the 'model formula'
MLRresults[i,2]<-(Total_deviance-MLR_test[[19]])/Total_deviance # store
the % of deviance explained
MLRresults[i,3]<-MLR_test[[26]] # store the AIC value
MLRresults[i,4]<-AICc(MLR_test)} # store the AICc value
wAICc<-Weights(MLRresults$AICc) # AIC weigth
MLRresults<-cbind(MLRresults, wAICc) # combine results in a single table
View(MLRresults[order(MLRresults$wAICc, decreasing=T), ]) # print the
output table from the model selection procedure
The above code yields
MODEL
DEVIANCE AIC AICc wAIC
8
subregion ~ MEM2 + MEM1 + MEM3 + MEM4 + MEM5 + MEM27 + MEM24 + MEM15 +
MEM10 + MEM26 + MEM16
0.5025134
738.7133
910.5673
9.999907e-01
3
subregion ~ HFP + MEM2 + MEM1 + MEM3 + MEM4 + MEM5 + MEM27 + MEM24 + MEM15
+ MEM10 + MEM26 + MEM16
0.5393317
718.0280
933.7467
9.260806e-06
2
subregion ~ ElevR + ElevCV + MEM2 + MEM1 + MEM3 + MEM4 + MEM5 + MEM27 +
MEM24 + MEM15 + MEM10 + MEM26 + MEM16
0.5574922
716.9467
985.8879
4.409071e-17
6
subregion ~ HFP + ElevR + ElevCV + MEM2 + MEM1 + MEM3 + MEM4 + MEM5 + MEM27
+ MEM24 + MEM15 + MEM10 + MEM26 + MEM16
0.5805342
710.7362
1044.5544
8.036491e-30
1
subregion ~ AMT + APP + CEC + Sand + TAR + MEM2 + MEM1 + MEM3 + MEM4 + MEM5
+ MEM27 + MEM24 + MEM15 + MEM10 + MEM26 + MEM16
0.6736414
648.9077
1161.1251
3.909003e-55
5
subregion ~ AMT + APP + CEC + Sand + TAR + HFP + MEM2 + MEM1 + MEM3 + MEM4
+ MEM5 + MEM27 + MEM24 + MEM15 + MEM10 + MEM26 + MEM16
0.6818203
658.3141
1294.6032
4.051928e-84
4
subregion ~ AMT + APP + CEC + Sand + TAR + ElevR + ElevCV + MEM2 + MEM1 +
MEM3 + MEM4 + MEM5 + MEM27 + MEM24 + MEM15 + MEM10 + MEM26 + MEM16
0.6943008
663.2007
1458.1197
1.260428e-119
7
subregion ~ AMT + APP + CEC + Sand + TAR + ElevR + ElevCV + HFP + MEM2 +
MEM1 + MEM3 + MEM4 + MEM5 + MEM27 + MEM24 + MEM15 + MEM10 + MEM26 + MEM16
0.7016101
673.5208
1675.9823
6.197945e-167
--
Dr. Alexandre F. Souza
Professor Adjunto IV
Universidade Federal do Rio Grande do Norte
CB, Departamento de Ecologia
Campus Universitário - Lagoa Nova
59072-970 - Natal, RN - Brasil
lattes: lattes.cnpq.br/7844758818522706
http://esferacientifica.wixsite.com/esferacientifica
http://www.docente.ufrn.br/alexsouza
[[alternative HTML version deleted]]
More information about the R-sig-ecology
mailing list