Performing a GLMM using Gaussian Data

I am trying to plot a GLMM of Gaussian data.
eg. Diversity measure = Gaussian Data (8 decimal points) = y

Sample_ID = A, B, C - I want to include this as a random effect.
Type = D, E, F, G (fixed effect)
Colour = green, yellow, blue (fixed effect)
Time in hours (Fixed effect / continuous data)

So something like:
model <- glmm(chao1_mean ~ Type + Colour + Time + (1|Sample_ID), family = gaussian, data = Data)

I have tried using glmm function but I can only have families as 'binomial', 'poisson', or 'bernoulli'. So I am assuming I have to use a different version of the glmm.

I've tried using "mixed_models" from "GLMMadaptive" and also "lme" from "lme4" the first gives me an error and tells me to use the "lme" and "lme" just gives me errors. I thought the glmmADMB might be the correct package but it is unavailable on my R study version.

Am I on the correct lines or is there a package for modelling Gaussian data for GLMMs that I've missed.

I am also unsure if (1|Sample_ID) is the correct formulation.

Many thanks in advance.

Since initially asking this question I have tried using lme4 again with the following code:

glmm_model <- glmer (Diversity ~ Type + (1|Sample_ID), data = Data)

I think this is correct though I get a message
"calling glmer() with family = Gaussian (identity link) as a shortcut to lmer() is deprecated; please call lmer() directly"

I am not sure what this message means.

model <- lmer (Diversity ~ Type + (1|Sample_ID), data = Data)
seems to work but I am now having difficulty checking for overdispersion.

overdisp_fun <- function(model) {
rdf <- df.residuals(model)
rp <- residuals(model, type"pearson")
Pearson.chisq <- (sum(rp^2)
prat <- Pearson.chisq/rdf
pval <- pchisq(Pearson.chisq, df=rdf, lower.tail=FALSE)
c(chisq = Pearson.chisq, ratio = prat, rdf = rdf, p = pval)}

I then use:


Yesterday I had a p value of p = 1.0. Today I have a p value of p = 0.0. As far as I can see I've used the libraries and same data and run the same code. The only difference is a pvals.fnc function seemed to work yesterday but today it says it is no longer supported by lme4 which is also supported by further searches. Any suggestions how to fix this or what I should use instead?

I don't know what's going on with the function, but since you can't have overdispersion in linear mixed models (where you assume normality of errors) I don't think you need to spend any more time troubleshooting. :smile:

Thanks :slight_smile:

Any idea how I test if the lmer model is a good fit if it isn't by this method?
eg. how would I test if

model1 <- lmer ( Diversity ~ Type + (1|Sample_ID), data = Data)

is a good model or not?

Since you were checking for overdispersion, which is a check to see that the variance defined by the chosen (non-normal) distribution adequately captures the variability in the data, I'm guessing you want to check the model assumptions. The first thing I usually do after fitting a model is to make residual plots to see if assumptions are (adequately) met.

While I have become more hesitant to recommend it due to their suggestions on model selection that I think are out-dated, Zuur et al. 2009 ("Mixed Effects Models and Extensions in Ecology with R") do a nice review of the assumptions of linear models and how to check those assumptions graphically. I believe that's in Chapter 2. I don't know if the book is online or not (the library at my institution offers it in PDF form).

1 Like