I would be really grateful if someone can help me with this since i am kind of new in R and not so used to multivariate statistics.

I have a dataset of species data collected across 3 habitats and at 3 different scales. However scales 2 and 3 build on scale 1, this is the number of species of a unit at scale 2 is the sum of four units at scale 1 and the number of species at one scale 3 unit is the sum of species of four units at scale 2 and so on... So the design is nested.

I want to test for the existence of significant effects of habitat and scale in the dependent variable species number. After reading several stats books i understood i should do a mixed ANOVA with one fixed effect(habitat) and one random effect (scale). However, i have some doubts since all the examples i have seen are on repeated measures (when one individual is measured for different things) and i am not sure if that is my case. It is truth that points in scale 1 are repeatedly used to build scales 2 and 3 but in my case it is 4 sampling points at scale 1 that are aggregated in one sampling point at scale 2 and so on. Also since scales 2 and 3 build upon scale 1 the number of points at the different scales is very uneven.

I have tried the function ezANOVA in R with the input file i send bellow.

after calling the dataset i used the following arguments:

Mothsanovasp<-ezANOVA(data=Manovasp,dv=.(Sp), wid.(Points), between=.(Hb), within_full=.(Scale),type=3,detailed=TRUE)

I used type 3 since i have unbalanced sampling sizes but my main doubt is if the argument wid. is right. Should it be the name of the sampling points or the scale?

Also, should the input data be in this format and is this the right analysis for my case (i attached both the dataset and a representation of the sampling scheme)?

Thanks a lot for your time!