I have data on native and invasive species along a height gradient. I want to know what effect the number of native species has on the number of invasive species (or the portion of invasive species). The problem is, that the (total) number of species along the height gradient is not random or constant, but the total number of species is a function of height (h) with a dependence of approximately Nspecies(h) = -ah²+bh+c. So my question is, how can I distinguish between the effect of species richness, which depends on height and the effect of height itself on the number or portion of invasive species? Is there a solution, preferrably in R?