From: Vincent Staszewski <vincent.staszewski_at_ed.ac.uk>

Date: Wed, 13 Apr 2011 11:36:49 +0100

Date: Wed, 13 Apr 2011 11:36:49 +0100

Hi,

I have a dataset with a continuous response variable and, among other predictors, an ordinal variable.

Here is what it could look like

treatment <- factor(rep(c("AA", "AC", "AD","AE", "AB"), each = 10))

length <- c(75, 67, 70, 75, 65, 71, 67, 67, 76, 68,

57, 58, 60, 59, 62, 60, 60, 57, 59, 61, 58, 61, 56, 58, 57, 56, 61, 60, 57, 58, 58, 59, 58, 61, 57, 56, 58, 57, 57, 59, 62, 66, 65, 63, 64, 62, 65, 65, 62, 67)

This ordinal variable (treatment) contains 5 classes and can not be recoded as a numerical variable (for example 1, 2,3,4 and 5) because I have no information on the relative difference between classes (it could as well be 1, 24, 25, 50,55). Coding it simply as a categorical variable is also not ok because there is a hierarchy between the groups. This is the definition of ordinal variable.

I have defined the ordinal variable (the order is from a priori prediction)

**#NOW DEFINING THE ORDERED VARIABLE:
**

sugars$treatment_ordered<-ordered(sugars$treatment,c("AA", "AB","AC",
"AD","AE"))

The problem is that when I run the ANOVA or perform model comparison, R is giving me the same results if I use either "treatment" as a predictor in the model or "treatment_ordered".

anova(lm(length ~ treatment_ordered, sugars));anova(lm(length ~ treatment, sugars))

I've thought about using planned contrasts but I do not manage to
translate the prediction ("AA"<"AB"<"AC"< "AD"<"AE")
would it be

(AA<(AB,AC,AD,AE))&((AA,AB)<(AC,AD,AE))etc etc
(-1,0.25,0.25,0.25,0.25)&(-0.5,-0.5,0.33,0.33,0.33)&...

OR

(AA<AB)&(AB,AC)&...

(-1,1,0,0,0)&(0,-1,1,0,0)&...

and anyway you can only test one matrix at a time.

To make thinks a bit more complicated, I also have another factor, categorical variable and I'd like to test the interaction with the ordinal factor (of course sample sizes are higher in the "real" dataset):

treatment <- factor(rep(c("AA", "AC", "AD","AE", "AB"), each = 10))

length <- c(75, 67, 70, 75, 65, 71, 67, 67, 76, 68,

57, 58, 60, 59, 62, 60, 60, 57, 59, 61, 58, 61, 56, 58, 57, 56, 61, 60, 57, 58, 58, 59, 58, 61, 57, 56, 58, 57, 57, 59, 62, 66, 65, 63, 64, 62, 65, 65, 62, 67) treatment2 <- c("BA", "BA", "BB", "BB", "BC", "BC", "BD", "BD", "BE", "BE",

"BA", "BA", "BB", "BB", "BC", "BC", "BD", "BD", "BE", "BE","BA", "BA", "BB", "BB", "BC", "BC", "BD", "BD", "BE", "BE",

"BA", "BA", "BB", "BB", "BC", "BC", "BD", "BD", "BE", "BE",

"BA", "BA", "BB", "BB", "BC", "BC", "BD", "BD", "BE", "BE")

sugars <- data.frame(treatment, length,treatment2)

sugars$treatment_ordered<-ordered(sugars$treatment,c("AA", "AB","AC", "AD","AE"))

anova(lm(length ~

treatment_ordered+treatment2+treatment_ordered:treatment2, sugars))

Any suggestions?

Thanks,

V.

-- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ----- End forwarded message ----- -- Vincent STASZEWSKI Institute of Infection and Immunology Research Ashworth Laboratories Kings' Buildings EH9 3JT Edinburgh Scotland, UK Tel: 0044(0)131 650 8682 webpage: http://reece.bio.ed.ac.uk/vincent-staszewski.html -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. ______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Received on Wed 13 Apr 2011 - 15:15:49 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Wed 13 Apr 2011 - 15:20:29 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*