Re: [R] Comparison of age categories using contrasts

2009-02-17 Thread Mark Difford
Hi Dylan, Am I trying to use contrast.Design() for something that it was not intended for? ... I think Prof. Harrell's main point had to do with how interactions are handled. You can also get the kind of contrasts that Patrick was interested in via multcomp. If we do this using your

Re: [R] Comparison of age categories using contrasts

2009-02-17 Thread Chuck Cleland
On 2/16/2009 10:18 PM, Dylan Beaudette wrote: On Mon, Feb 16, 2009 at 5:28 PM, Patrick Giraudoux patrick.giraud...@univ-fcomte.fr wrote: Greg Snow a écrit : One approach is to create your own contrasts matrix: mycmat - diag(8) mycmat[ row(mycmat) == col(mycmat) + 1 ] - -1 mycmati -

Re: [R] Comparison of age categories using contrasts

2009-02-17 Thread Mark Difford
Hi Dylan, Chuck, contrast(l, a=list(f=levels(d$f)[1:3], x=0), b=list(f=levels(d$f)[4], x=0)) There is a subtlety here that needs to be emphasized. Setting the interacting variable (x) to zero is reasonable in this case, because the mean value of rnorm(n) is zero. However, in the real world

Re: [R] Comparison of age categories using contrasts

2009-02-17 Thread Mark Difford
Hi Dylan, Chuck, Mark Difford wrote: Coming to your question [?] about how to generate the kind of contrasts that Patrick wanted using contrast.Design. Well, it is not that straightforward, though I may have missed something in the documentation to the function. In the past I have

[R] Comparison of age categories using contrasts

2009-02-16 Thread Patrick Giraudoux
Dear listers, I would like to compare the levels of a factor with 8 age categories (0,10] (10,20] (20,30] (30,40] (40,50] (50,60] (60,70] (70,90] (however, the factor has not been ordered yet). The default in glm is cont.treatment (for unordered factors) and that leads to compare each level to

Re: [R] Comparison of age categories using contrasts

2009-02-16 Thread Greg Snow
of age categories using contrasts Dear listers, I would like to compare the levels of a factor with 8 age categories (0,10] (10,20] (20,30] (30,40] (40,50] (50,60] (60,70] (70,90] (however, the factor has not been ordered yet). The default in glm is cont.treatment (for unordered factors

Re: [R] Comparison of age categories using contrasts

2009-02-16 Thread Patrick Giraudoux
Greg Snow a écrit : One approach is to create your own contrasts matrix: mycmat - diag(8) mycmat[ row(mycmat) == col(mycmat) + 1 ] - -1 mycmati - solve(mycmat) contrasts(agefactor) - mycmati[,-1] Now when you use agefactor, the intercept will be the first age group and the

Re: [R] Comparison of age categories using contrasts

2009-02-16 Thread Dylan Beaudette
On Mon, Feb 16, 2009 at 5:28 PM, Patrick Giraudoux patrick.giraud...@univ-fcomte.fr wrote: Greg Snow a écrit : One approach is to create your own contrasts matrix: mycmat - diag(8) mycmat[ row(mycmat) == col(mycmat) + 1 ] - -1 mycmati - solve(mycmat) contrasts(agefactor) - mycmati[,-1]

[R] Comparison of age categories using contrasts

2009-02-15 Thread Patrick Giraudoux
Dear listers, I would like to compare the levels of a factor with 8 age categories (0,10] (10,20] (20,30] (30,40] (40,50] (50,60] (60,70] (70,90] (however, the factor has not been ordered yet). The default in glm is cont.treatment (for unordered factors) and that leads to compare each level