Skip to main content
edited tags
Link
Robert Long
  • 65.8k
  • 11
  • 133
  • 248
Tweeted twitter.com/StackStats/status/1239657887867289601
Improved clarity, added data tables and corrected inconsistent naming of variables.
Source Link
Dan
  • 41
  • 3

I have a field experiment looking at the effect of a seed-mix treatment on insectmoth abundance and I am struggling to define the correct random effects structure. My experiment is structured like this:

I have 16 Blocks, each split into 3 Sections, with each Section having a different seed mix (Treatment). Each night, I sample insects in 4 Blocks then the next night move on to the next 4 Blocks. This continues on a rotation Monday - Thursday (see image). So the whole experiment is sampled fully once in each week. I repeated this over 8 weeks (32 nights), and then repeated the whole thing again the next year, resulting in 16 weeks andover 2 years, amounting to 64 sample nights.

The data look like this:

str(Moths)

'data.frame':   768 obs. of  8 variables:
 $ Section  : Factor w/ 48 levels "10BC","10GR",..: 22 23 24 25 26 27 28 29 30 31 ...
 $ Week     : Factor w/ 16 levels "1_2018","1_2019",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Treatment: Factor w/ 3 levels "BC","GR","WF": 1 2 3 1 2 3 1 2 3 1 ...
 $ Abundance: int  5 3 5 7 3 16 6 6 14 8 ...
 $ Year     : Factor w/ 2 levels "2018","2019": 1 1 1 1 1 1 1 1 1 1 ...
 $ Big_block: Factor w/ 4 levels "B_1","B_2","B_3",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Night    : Factor w/ 64 levels "1_2019","10_2018",..: 58 58 58 58 58 58 58 58 58 58 ...
 $ Block    : Factor w/ 16 levels "1","2","3","4",..: 1 1 1 2 2 2 3 3 3 4 ...

head(Moths, 10)

   Section   Week Treatment Abundance Year Big_block  Night Block
1      1BC 1_2018        BC         5 2018       B_1 6_2018     1
2      1GR 1_2018        GR         3 2018       B_1 6_2018     1
3      1WF 1_2018        WF         5 2018       B_1 6_2018     1
4      2BC 1_2018        BC         7 2018       B_1 6_2018     2
5      2GR 1_2018        GR         3 2018       B_1 6_2018     2
6      2WF 1_2018        WF        16 2018       B_1 6_2018     2
7      3BC 1_2018        BC         6 2018       B_1 6_2018     3
8      3GR 1_2018        GR         6 2018       B_1 6_2018     3
9      3WF 1_2018        WF        14 2018       B_1 6_2018     3
10     4BC 1_2018        BC         8 2018       B_1 6_2018     4
> 


Originally, I thought that this was a partially crossed design as each Block is sampled on multiple nightsNights and each Night is associated with multiple Blocks. I was originally coding my model (in R - lme4) as so:

Mod1 <- glm.nb(Abundance ~ Treatment + (1|Night) + (1|Block), data = dataMoths)

Mod2 <- glm.nb(Abundance ~ Treatment + (1|Big_block/Block/SiteSection/Week), data = dataMoths)

This includes a random intercept for each Week, nested in each SiteSection, nested in each Block, nested in each Big_block. As each Big_block is only sampled once in each week, this implicitly includes a Night effect... I think.

I am still not convinced by this structure though as I feel like it should be partially crossed, not fully nested. As I see it, the Night happens to 4 Blocks all at the same time, so I don't see how the temporal effect can be nested within SiteSection, rather than 'above' it, as I am visualising it. I think It should be more like this:

Mod3 <- glm.nb(Abundance ~ Treatment + (1|Night) + (1|Block/SiteSection), data = dataMoths)

Which is almost the same as my original formulation. In fact, I don't know whether (1|Block/SiteSection) is any different to (1|Block) considering it's always the same SiteSection in the same blockBlock.

Abundance: Continuous response
Treatment: Factor (3 levels)
Big_block: Factor (4 levels). Each Big_block contains 4 Blocks 
Block: Factor (16 levels). Each Block contains 3 SitesSections
SiteSection: Factor (48 levels). Each SiteSection contains 1 Treatment
Night: Factor with 64 levels
Week: Factor with 16 levels (Each Week contains 4 Nights).

I have a field experiment looking at the effect of a seed-mix treatment on insect abundance and I am struggling to define the correct random effects structure. My experiment is structured like this:

I have 16 Blocks, each split into 3 Sections, with each Section having a different seed mix (Treatment). Each night, I sample insects in 4 Blocks then the next night move on to the next 4 Blocks. This continues on a rotation Monday - Thursday (see image). So the whole experiment is sampled fully once in each week. I repeated this over 8 weeks (32 nights), and then repeated the whole thing again the next year, resulting in 16 weeks and 64 sample nights.

Originally, I thought that this was a partially crossed design as each Block is sampled on multiple nights and each Night is associated with multiple Blocks. I was originally coding my model (in R - lme4) as so:

Mod1 <- glm.nb(Abundance ~ Treatment + (1|Night) + (1|Block), data = data)

Mod2 <- glm.nb(Abundance ~ Treatment + (1|Big_block/Block/Site/Week), data = data)

This includes a random intercept for each Week, nested in each Site, nested in each Block, nested in each Big_block. As each Big_block is only sampled once in each week, this implicitly includes a Night effect... I think.

I am still not convinced by this structure though as I feel like it should be partially crossed, not fully nested. As I see it, the Night happens to 4 Blocks all at the same time, so I don't see how the temporal effect can be nested within Site, rather than 'above' it, as I am visualising it. I think It should be more like this:

Mod3 <- glm.nb(Abundance ~ Treatment + (1|Night) + (1|Block/Site), data = data)

Which is almost the same as my original formulation. In fact, I don't know whether (1|Block/Site) is any different to (1|Block) considering it's always the same Site in the same block.

Abundance: Continuous response
Treatment: Factor (3 levels)
Big_block: Factor (4 levels). Each Big_block contains 4 Blocks Block: Factor (16 levels). Each Block contains 3 Sites Site: Factor (48 levels). Each Site contains 1 Treatment
Night: Factor with 64 levels
Week: Factor with 16 levels.

I have a field experiment looking at the effect of a seed-mix treatment on moth abundance and I am struggling to define the correct random effects structure. My experiment is structured like this:

I have 16 Blocks, each split into 3 Sections, with each Section having a different seed mix (Treatment). Each night, I sample insects in 4 Blocks then the next night move on to the next 4 Blocks. This continues on a rotation Monday - Thursday (see image). So the whole experiment is sampled fully once in each week. I repeated this over 16 weeks over 2 years, amounting to 64 sample nights.

The data look like this:

str(Moths)

'data.frame':   768 obs. of  8 variables:
 $ Section  : Factor w/ 48 levels "10BC","10GR",..: 22 23 24 25 26 27 28 29 30 31 ...
 $ Week     : Factor w/ 16 levels "1_2018","1_2019",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Treatment: Factor w/ 3 levels "BC","GR","WF": 1 2 3 1 2 3 1 2 3 1 ...
 $ Abundance: int  5 3 5 7 3 16 6 6 14 8 ...
 $ Year     : Factor w/ 2 levels "2018","2019": 1 1 1 1 1 1 1 1 1 1 ...
 $ Big_block: Factor w/ 4 levels "B_1","B_2","B_3",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Night    : Factor w/ 64 levels "1_2019","10_2018",..: 58 58 58 58 58 58 58 58 58 58 ...
 $ Block    : Factor w/ 16 levels "1","2","3","4",..: 1 1 1 2 2 2 3 3 3 4 ...

head(Moths, 10)

   Section   Week Treatment Abundance Year Big_block  Night Block
1      1BC 1_2018        BC         5 2018       B_1 6_2018     1
2      1GR 1_2018        GR         3 2018       B_1 6_2018     1
3      1WF 1_2018        WF         5 2018       B_1 6_2018     1
4      2BC 1_2018        BC         7 2018       B_1 6_2018     2
5      2GR 1_2018        GR         3 2018       B_1 6_2018     2
6      2WF 1_2018        WF        16 2018       B_1 6_2018     2
7      3BC 1_2018        BC         6 2018       B_1 6_2018     3
8      3GR 1_2018        GR         6 2018       B_1 6_2018     3
9      3WF 1_2018        WF        14 2018       B_1 6_2018     3
10     4BC 1_2018        BC         8 2018       B_1 6_2018     4
> 


Originally, I thought that this was a partially crossed design as each Block is sampled on multiple Nights and each Night is associated with multiple Blocks. I was originally coding my model (in R - lme4) as so:

Mod1 <- glm.nb(Abundance ~ Treatment + (1|Night) + (1|Block), data = Moths)

Mod2 <- glm.nb(Abundance ~ Treatment + (1|Big_block/Block/Section/Week), data = Moths)

This includes a random intercept for each Week, nested in each Section, nested in each Block, nested in each Big_block. As each Big_block is only sampled once in each week, this implicitly includes a Night effect... I think.

I am still not convinced by this structure though as I feel like it should be partially crossed, not fully nested. As I see it, the Night happens to 4 Blocks all at the same time, so I don't see how the temporal effect can be nested within Section, rather than 'above' it, as I am visualising it. I think It should be more like this:

Mod3 <- glm.nb(Abundance ~ Treatment + (1|Night) + (1|Block/Section), data = Moths)

Which is almost the same as my original formulation. In fact, I don't know whether (1|Block/Section) is any different to (1|Block) considering it's always the same Section in the same Block.

Abundance: Continuous response
Treatment: Factor (3 levels)
Big_block: Factor (4 levels). Each Big_block contains 4 Blocks 
Block: Factor (16 levels). Each Block contains 3 Sections
Section: Factor (48 levels). Each Section contains 1 Treatment
Night: Factor with 64 levels
Week: Factor with 16 levels (Each Week contains 4 Nights).

Source Link
Dan
  • 41
  • 3

Should repeated measures be included as a nested or a crossed random effect in glmer?

I have a field experiment looking at the effect of a seed-mix treatment on insect abundance and I am struggling to define the correct random effects structure. My experiment is structured like this:

I have 16 Blocks, each split into 3 Sections, with each Section having a different seed mix (Treatment). Each night, I sample insects in 4 Blocks then the next night move on to the next 4 Blocks. This continues on a rotation Monday - Thursday (see image). So the whole experiment is sampled fully once in each week. I repeated this over 8 weeks (32 nights), and then repeated the whole thing again the next year, resulting in 16 weeks and 64 sample nights.

The variation in insect abundance from night-to-night is very large (due to weather) but I am not interested in this effect, so accounting for this variation is important.

Originally, I thought that this was a partially crossed design as each Block is sampled on multiple nights and each Night is associated with multiple Blocks. I was originally coding my model (in R - lme4) as so:

Mod1 <- glm.nb(Abundance ~ Treatment + (1|Night) + (1|Block), data = data)

With Night as a factor (1:64) and Block as a factor (1:16). The response variable is a count with high over-dispersion, hence the negative binomial error structure.

A statistician at my institute agreed with this formulation, but another statistician said that this does not properly account for the fact that the same Block is being visited repeatedly. Statistician No. 2 said that I also need to account for the fact that the same 4 Blocks are always sampled together on the same night (this level I call Big_block, with 4 unique levels each). Statistician No. 2 recommended the following:

Mod2 <- glm.nb(Abundance ~ Treatment + (1|Big_block/Block/Site/Week), data = data)

This includes a random intercept for each Week, nested in each Site, nested in each Block, nested in each Big_block. As each Big_block is only sampled once in each week, this implicitly includes a Night effect... I think.

I am still not convinced by this structure though as I feel like it should be partially crossed, not fully nested. As I see it, the Night happens to 4 Blocks all at the same time, so I don't see how the temporal effect can be nested within Site, rather than 'above' it, as I am visualising it. I think It should be more like this:

Mod3 <- glm.nb(Abundance ~ Treatment + (1|Night) + (1|Block/Site), data = data)

Which is almost the same as my original formulation. In fact, I don't know whether (1|Block/Site) is any different to (1|Block) considering it's always the same Site in the same block.

To recap, I have the following variables:

Abundance: Continuous response
Treatment: Factor (3 levels)
Big_block: Factor (4 levels). Each Big_block contains 4 Blocks Block: Factor (16 levels). Each Block contains 3 Sites Site: Factor (48 levels). Each Site contains 1 Treatment
Night: Factor with 64 levels
Week: Factor with 16 levels.

I've been working on this problem for a long time, reading books and forums, and I'm just going round in circles. I hope someone on here can help put me out of my misery!

[![Sampling design for Year 1. Four blocks are sampled each night on a rotation.][1]][1] [1]: https://i.sstatic.net/mBIlx.png