[BioC] about formula in ancova
Dejian Zhao
zhaodj at ioz.ac.cn
Sun Mar 14 10:47:22 CET 2010
Dear list members,
I have a question about the formula in ancova(), which is embedded in
the HH package.There are several examples in the ancova() help file
which can be accessed by type "?ancova" in R console after loading HH
package.Some codes are as follows:
hotdog <- read.table(hh("datasets/hotdog.dat"), header=TRUE)
## y ~ x + a or y ~ a + x ## constant slope, different intercepts
ancova(Sodium ~ Calories + Type, data=hotdog)
ancova(Sodium ~ Type + Calories, data=hotdog)
After running the codes,I found I got different results when choosing
different formula,i.e."ancova(Sodium ~ Calories + Type, data=hotdog)"
and "ancova(Sodium ~ Type + Calories, data=hotdog) " produced different
results.
The same thing also happens to the following example codes:
## y ~ x * a or y ~ a * x ## different slopes, and different intercepts
ancova(Sodium ~ Calories * Type, data=hotdog)
ancova(Sodium ~ Type * Calories, data=hotdog)
Hence,I am confused about the difference between the formula "y ~ x + a"
and "y ~ a + x",likewise "y ~ x * a" and "y ~ a * x". I thought the
order of variables in the formula is arbitrary,however,here it seems the
order matters.
Can someone explain the formula for me? And how should we choose the
formula, or arrange the order of variables in the formula, when
processing our own data?
Many thanks!
Dejian
-----
Dejian Zhao, PhD student
Group of Evolutionary Ecology
State Key Laboratory of Integrated Pest Management
Institute of Zoology, Chinese Academy of Sciences
1 Beichen West Road, Chaoyang District, Beijing, P.R.China
Postal code: 100101
Tel (office): +86-10-64807217
Fax: +86-10-64807099
Email: zhaodj at ioz.ac.cn
More information about the Bioconductor
mailing list