I believe the strange behavior of glht is due to zero variance within the 2012 level of factor Season. This blows up the SE on the test being used for the contrast, resulting in non-signifcance.
A larger issue is this data doesn't seem negative binomial at all the combinations of factor levels that the model attempts to predict, leading to poor performance of the model (see some diagnostic plots below). Dropping 2012 from the analysis helps a bit, but issues remain. I would look into a zero-inflated model with at least Season as a predictor of the probability of getting a zero!
## this data isn't negative binomial within levels of the predictors!
ggplot(all_habitat, aes(Season, Density_100)) + geom_jitter()
## resid v fitted -- model understantably struggles to get those 2012 zeroes
plot(t2, which=1)
## qqplot is ugly - should be somewhat linear
plot(t2, which=2)
library(ggplot2)
all_habitat$resid <- resid(t2)
all_habitat$fitted <- predict(t2, type='response')
## residuals by year -- systematic underprediction within the non-2012 years
ggplot(all_habitat, aes(Season, resid)) + geom_jitter()
ggplot(all_habitat, aes(fitted, resid)) + geom_jitter() + geom_smooth(method='lm') +
geom_hline(xintercept=0) + facet_wrap(~Season)
## try without 2012
ahb2 <- all_habitat[all_habitat$Season != 2012, ]
ahb2$Season <- factor(ahb2$Season)
ahb2$HabitatSeason <- interaction(ahb2$Habitat, ahb2$Season, drop=T) # put interaction into a column in the data frame
t3<-glm.nb(Density_100 ~HabitatSeason, data=ahb2) # run another model
## qqplot -- still trouble
plot(t3, which=2)
## resid v fitted -- doesn't seem to help with underprediction
plot(t3, which=1)
ggplot(ahb2, aes(Season, resid)) + geom_jitter()
(g <- ggplot(ahb2, aes(fitted, resid)) + geom_jitter() + geom_smooth(method='gam') + geom_hline(xintercept=0))
g + facet_wrap(~Season)