# How to write model with fixed factors nested in random one?

I'm at the beginning of models understanding so this question is maybe childish, excuse me, please. It is close to this but there are some differences and I'm not sure how to implement that solution and if it match my situation.

My data contains measures of cellobiohydrolase activity (CBHA) in rabbit caecum samples. 60 samples were taken from proximal and distal parts of the caecum (30:30). One half of the samples was extracted by buffer and the other one --- by glycerine. From each sample (eppendorf) there were 3 measures of CBHA in different concentrations (5, 10 and 15 g/ml). So my variables are:

> str(concWork)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   60 obs. of  5 variables:
$sample : Factor w/ 20 levels "25","26","27",..: 1 2 3 4 5 6 7 8 9 10 ...$ loc_part : Factor w/ 2 levels "distal","proximal": 2 2 2 2 2 1 1 1 1 1 ...
$extragent: Factor w/ 2 levels "glycerine","buffer": 1 1 1 1 1 1 1 1 1 1 ...$ conc     : Factor w/ 3 levels "5","10","15": 1 1 1 1 1 1 1 1 1 1 ...
\$ cbha    : num  22.68 15.1 7.49 14.97 14.88 ...


cbha is dependent variable, sample is random effect and other factors (fixed) are nested (I think):

Mainly I'm interesting in effects of extragent and concentration but also need to take into account other factors and their possible interactions. So the starting model ("beyond optimal", all possible fixed factors and their interactions + initial structure or random effect) is:

M0 <- lmer(cbha2 ~ extragent * conc * loc_part + (1 | sample), data = concWork)


I'm not sure is this model correct in terms of lme4. Really all factors are nested (see the scheme) but I don't understand how to put this hierarchy. May be like this:

M1 <- lmer(cbha2 ~ extragent * conc * loc_part + (1 | loc_part/extragent/sample/conc), data = concWork)


But I suspect this is wrong approach:

Error: number of levels of each grouping factor must be < number of observations


I remember about Prof. Bolker's warning:

In general you shouldn't include a categorical variable (factor) as both a fixed effect and a random-effect grouping variable: that's a redundant model specification.

...but I think some fixed effects will be dropped during top-down selection. Appreciate for any ideas.

• The "subjects" of the repeated measures are the sample IDs. These go on the RHS of |. What was measured for each subject was the concentration effect. That goes on the LHS. So I'd do M0 <- lmer(cbha2 ~ extragent * conc * loc_part + (conc | sample), data = concWork). – Roland Jun 7 '19 at 7:15
• @Roland, thank you! I think it's good idea to take into account the effect "concentration within sample". But how to specify other nestedness? – UlvHare Jun 7 '19 at 9:48
• As far as I understand you don't have nested subjects. – Roland Jun 7 '19 at 10:10