Please enable JavaScript.
Coggle requires JavaScript to display documents.
GLMM (Different Packages (glmmPQL - (This function fitted the GLMM using…
GLMM
Different Packages
glmmPQL -
-
Convention
model1<-glmmPQL(y~x, random =~1|randomEffectsVar, family=binomial)
-
glmer
glmer(y~fixedVariable + (1|randomEffectsVariable), family = binomial)
The main difference between glmer and glmmPQL is that glmer gives an AIC, BIC, log likelihood value and a deviance whereas glmmPQL does not.
glmmML
Convention
model1<-glmmML(y~x, cluster = randomEffectsVar, family=binomial)
MCMCglmm
-
Convention
model1 <- MCMCglmm(y~x, random =~us(randomEffectsVar), family="poisson")
glmmADMB
-
model1 <- glmmadmb(y~x, random =~(1|randomEffectsVar), family="nbinom")
If you need to deal with overdispersion you will probably choose glmmPQL or glmmADMB that can (which is very handy) use negative binomial errors.
Likelihoods:
To approximate the likelihood, methods such as PQL, Laplace approximations, GHQ and MCMC have been proposed.
PQL is the simplest and most widely used but has problems when standard deviations of random effects are large or with binary data.
works poorly for Poisson data wit low number of counts per treatment and with low expectation number for binomial
-
-
-
useful shit
-
-
library(MASS)
DE.PQL<-glmmPQL(Ecervi.01 ~ CLength * fSex,
random = ~ 1 | fFarm, family = binomial, data = DeerEcervi)
summary(DE.PQL)
-
Rationale
The question is now: what if I have count, proportion or binary data as dependent variable and top of that spatial or temporal correlation and/or a nested structure?
-
Model Selection
Two main concerns before modeling species distributions is whether there is high collinearity between the explanatory variables and whether there is spatial correlation
Collinearity: because many variables are the same variable but measured at different scales, they might be highly collinear.
cor(Koalas[, 6:22], method = "spearman")
Glm_testCollinear<- glm(presence~pprim_ssite+psec_ssite+
phss_1km+phss_5km+phss_2.5km+
pm_5km+pm_2.5km+pm_1km+
pdens_5km+pdens_2.5km+pdens_1km+
rdens_5km+rdens_2.5km+rdens_1km+
edens_5km+edens_2.5km+edens_1km,
data=Koalas2,family=binomial)
library(car)
vif(Glm_testCollinear)
clear problems of collinearity. There are two options: we would normally do the first which is to remove variables; the second is to group variables through linear combinations of highly collinear variables
Spatial correlation
Our next worry is spatial correlation. Using a new approach that works with GLMs, let’s look at the correlogram of the GLM model Pearson residuals where we have ignored spatial correlation.
install.packages("ncf")
Correlog_Glm_2 <- spline.correlog(x = Koalas[, "easting"],
y = Koalas[, "northing"],
z = residuals(Glm_testCollinear2,
type = "pearson"), xmax = 10000)
-
correlogram shows correlation as a function of distance. If there is none we should see it all around zero.
Let’s construct our GLMM. The clear candidate as a random effects is "site". We use the function glmer. This is a good candidate because it produces AIC scores which we want to use for our information-theoretic approach for model selection.
library(lme4)
Combinations of variables of the global model will be used to generate candidate models using the function "dredge()".