How to perform an ANCOVA in R

I want to perform an ANCOVA analysis of data concerning density of plant epiphytes. At first, I would like to know if there is any difference in plant density between two slopes, one N and one S, but I have other data such as altitude, canopy openness and height of the host plant. I know that my covariate would have to be the two slopes (N and S). I built this model that runs in R and although I have no idea if it performs well. Also I would like to know what the difference is if I use the symbol + or *.

model1 <- aov(density~slope+altitude+canopy+height)
summary(model1)
model1

Answer

The basic tool for this is lm; note that aov is a wrapper for lm.

In particular, if you have some grouping variable (factor), g, and a continuous covariate x, the model y ~ x + g would fit a main effects ANCOVA model, while y ~ x * g would fit a model which includes interaction with the covariate. aov will take the same formulas.

Pay particular attention to the Note in the help on aov.

As for + vs *, russellpierce pretty much covers it, but I’d recommend you look at ?lm and ?formula and most especially section 11.1 of the manual An Introduction to R that comes with R (or you can find it online if you haven’t figured out how to find it on your computer; most easily, this involves finding the “Help” pull down menu in either R or RStudio).

Attribution
Source : Link , Question Author : Pauloc , Answer Author : iNyar

Leave a Comment