I am trying to create a GLMM model which explains differences in abundance/count of three species of scorpion around a field reserve in different forest types.

-I have 7 trails in different forest types (1 trail in edge habitat, 1 trail in pasture habitat, 1 trail in secondary forest habitat, and 4 trails in primary forest habitat)

-I am quantifying each trail as a 'transect' (transect_name) and each trail has its own length

-I sampled in each transect 4-5 times (trials)

-I also have sampling time during each transect trial (intensity)

-I have counts of each species collected on each trail during each trial (flavopictus, gracilis, rileyi)

-I have the week they were sampled (1 or 2)

Finally I have abundance of each species during each trial at each transect: I took the (counts of each species/total # of species) * 100 and rounded it to an integer.

Here is str of my data enter image description here

would I run a GLMM of species count with forest type being my random effect and sampling length and intensity as my fixed effect?

f <-glmer(flavo ~ Type + (1|length) + (1|intensity), family = 'poisson', data = transect) summary(f)

g <-glmer(abundflavo ~ Type + (1|length)+ (1|intensity), family = 'poisson', data = transect) summary(g)

The problem is that when I run a glmm on abundance I get 'singular fit'.

Mostly I am confused on what my random effects are, are they the trials, the weeks they were collected.

Also I am trying to figure out some sort of standardization between transects since each one is a different length.

I also have datalogger readings of temp and humidity at each forest type.

Any help is very much appreciated!


I wonder if you could treat Transect_Name and Day (where Day is converted to a factor) as random grouping factors in your model? This would acknowledge that the transects and days included in your study are not the only ones you are interested in, but you selected them to be representative of a larger universe of transects and days.

If you can, then you will have multiple trials (i.e., 4-5 trials) for each combination of transect and day. Each of these trials will give you an abudance measure. The abundance measure - which is your response variable - seems to be expressed as a percentage?

Intuitively, you can think of a random grouping factor as a bucket where you store multiple values of your response variable. Because you actually have two random grouping variables - transect and day - imagine that you are 'nesting' two buckets inside each other (for lack of a better visual) for each transect by day combination and then store your multiple abundance values for all the trials available for that combination in the 'nested bucket'. For example, you will have one 'nested bucket' for Circuit_P on Day 6, another for Circuit_P on Day 7, etc. (assuming Circuit_P was visited on both of those days.

Now, the 'nested buckets' themselves have some characteristics which will be treated as predictor variables in your model. These characteristics can be constant from trial to trial within the same 'nested bucket' (i.e., they refer to the 'nested bucket' as a whole) or they can change from trial to trial within that bucket (i.e., they refer to what happens inside the 'nested bucket'). As an example, sampling time (or intensity) during each trial is one such characteristics and it varies within the bucket as the trials vary. The week when the trial in each 'nested bucket' was conducted is another characteristic. The forest type is also a characteristic which refers to the 'nested bucket' as a whole (indeed, you can attach a forest type to each transect by day combination and that type won't change across the trials in the bucket). It doesn't seem that forest type should be a random grouping factor in your model, as you will likely be interested in comparing the concrete forest types you included in the study against each other.

This would suggest that you should have terms like (1|Transect_Name) and (1|Day) in the random effects portion of your model - presumably, these are partially crossed in your study? In other words, not all transects were measured on all days.

In the fixed effects part of your model, you can include fixed effects for species of scorpion, type of forest, intensity, (transect) length, week, temp, humidity, etc. Maybe you'll allow species and type of forest to interact with each other? For those characteristics which change from trial to trial within a 'nested bucket' you could also allow for random slopes - for example, (1 + intensity|Transect_Name) + (1 + intensity|Day).

Now, your response variable is currently expressed as a percentage - for modelling purposes you could convert it to a proportion and then perhaps use beta mixed effects modelling (with 0 and/or 1 inflation if necessary). It doesn't seem to me that you should treat it as a count - it is clearly computed as a proportion.


Thank you so much for your input.

The bucket analogy was very easy to understand, and I have a much better idea of how nesting and random factor grouping works. This is my first time using glmm's in my statistics and the way you explained it was very easy to digest, and I feel I can better get the answers I am looking for from my data.

For example in week 1(first bucket), I sampled circuit_P on day 5 (second bucket within my first bucket). The combination of which week, and which transect on which day is one of my nesting buckets. All the combinations of which week and which day I sampled which trail is all of my nested 'buckets' which will go into my model.

These nested buckets then can be used as predictors in my model; depending if I want to compare between buckets, or among all the buckets in my study. If I use trials for example, that can be a predictor as to what happens within each nested bucket. If I use forest type, that can be used as a predictor for which buckets belong to which forest type; comparing groups of buckets among eachother.

This code makes alot more sense to me now:

(1 + intensity|Transect_Name) + (1 + intensity|Day)

because the model is going to derive slopes from the combination of both the sampling intensity within each transect, and the intensity of sampling depending on the day in which each trail was sampled. This combination also takes into account the changes in characteristics of each bucket from trial to trial.

I was planning on having species and forest type interact with each other as my fixed effects because the main crux of my project is to determine if species are different among different forest types.

You are correct in which my response variable (species abundance) is expressed as a percentage. How do I change it to a proportion, because my glmer model cannot use numeric values in my fixed effects variable. I got abundance by dividing species counts by total species counts. I chose to make it a percentage because those are integers and not numeric.

Thanks again


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.