# Nested design with “lmer” function

I have a nested data which I cannot model properly. The data satisfies all the assumptions of ANOVA. Data description: 4 varieties of plants planted in 4 blocks and in each block the same variety has 3 plots each with different spacing. There are 48 plots in total and each has a unique ID. I draw a picture to visualize things. See it below. I also added the structure of my data below the figure.

data.frame':    48 obs. of  5 variables:
$$Variety: Factor w/ 4 levels "Big Green","Little Gem",..: 3 1 2 4 3 1 2 4 3 1 ...$$ Spacing: Factor w/ 3 levels "20","40","60": 1 1 1 1 1 1 1 1 1 1 ...
$$Block : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 2 2 2 2 3 3 ...$$ Plot   : Factor w/ 48 levels "1","2","3","4",..: 1 4 7 10 13 16 19 22 25 28 ...
\$ Yield  : int  32 37 35 40 21 38 32 36 19 27 ...


I would like to see

a) if spacing has a significant effect on yield

b) variety has a significant effect on yield

Yield is my response variable. I tried to use lmer function for this purpose and I failed miserably. It seems like I cannot get the correct formula, especially the nestedness of the data. Below model is what I tried for a).

Model_1 <- lmer(Yield ~ Spacing + (1|Variety/Block/Plot), data = Q1) Error: number of levels of each grouping factor must be < number of observations

How should I build these models? This is my first time with multi factor nested models, so please excuse me if any of the things I'm saying is nonsense.

If this is a designed experiment then you forgot the whole "randomness" part, that is choosing at random which variety goes in which row and which spacing goes in which column. Since there is no randomness then these are fixed effects, so your model would be lmer(Yield ~ Spacing + Variety + (1|Block), data = Q1). Also, the reason you are getting the error is probably because you included Plot in the model, which uniquely identifies each row (row id), so that is pointless.