Re: [R] Comparing each level of a factor to the global mean

2013-07-02 Thread Adams, Jean
You could subtract the mean from the response before fitting, then fit a model without an intercept. That would give you four parameters (one for each level) relative to the mean ... summary(lm(weight-mean(weight) ~ Diet -1, ChickWeight)) Jean On Thu, Jun 27, 2013 at 5:47 PM, Shaun Jackman

Re: [R] Comparing each level of a factor to the global mean

2013-06-27 Thread Shaun Jackman
Hi Jean, contr.treatment(4) shows what the default contrast matrix looks like for a factor with 4 levels. What function do I use to create a contrast matrix to compare each level with the global mean (four comparisons in total), and produce a table similar to `summary.lm`? Thanks, Shaun On 26

Re: [R] Comparing each level of a factor to the global mean

2013-06-27 Thread David Winsemius
On Jun 27, 2013, at 3:47 PM, Shaun Jackman wrote: Hi Jean, contr.treatment(4) shows what the default contrast matrix looks like for a factor with 4 levels. What function do I use to create a contrast matrix to compare each level with the global mean (four comparisons in total), and

Re: [R] Comparing each level of a factor to the global mean

2013-06-26 Thread Adams, Jean
Shaun, See the help on contrasts ... ?contr.treatment Jean On Tue, Jun 25, 2013 at 7:07 PM, Shaun Jackman sjack...@gmail.com wrote: Hi, I've used `lm` to create a linear model of a continuous variable against a factor variable with four levels using an example R data set (see

[R] Comparing each level of a factor to the global mean

2013-06-25 Thread Shaun Jackman
Hi, I've used `lm` to create a linear model of a continuous variable against a factor variable with four levels using an example R data set (see below). By default, it uses a treatment contrast matrix that compares each level of the factor variable with the first reference level (three