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 hav

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 wor

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 > 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(mycma

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 artifi

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 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] >>> >> >> Now

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 gr

Re: [R] Comparison of age categories using contrasts

2009-02-16 Thread Greg Snow
To: r-h...@stat.math.ethz.ch > Subject: [R] Comparison 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 ha

Re: [R] Comparison of age categories using contrasts

2009-02-16 Thread Frank E Harrell Jr
Mark Difford wrote: Hi Patrick, The default in glm is cont.treatment (for unordered factors) and that leads to compare each level to the first one. I would rather prefer to compare the 2nd to the 1st, the 3rd to the 2nd, the 4th to the 3rd, etc... The functions ?C and ?contrasts allow you t

[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 th

Re: [R] Comparison of age categories using contrasts

2009-02-15 Thread Mark Difford
Hi Patrick, >> The default in glm is cont.treatment (for unordered factors) and that >> leads to compare each level to the first one. I would rather prefer to >> compare the 2nd to the 1st, the 3rd to the 2nd, the 4th to the 3rd, >> etc... The functions ?C and ?contrasts allow you to set up yo

[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 t