[R] Helmert contrasts and weighted means

erlis ruli erlis.ruli at gmail.com
Thu Nov 10 16:30:38 CET 2016


Hi all!

Suppose that we have got a response y and an unbalanced treatment x with three levels or groups. 
The treatment is unbalanced by design. Indeed, the first group has 3 replications and the other two have two replications each.
 
For instance, in R the data might look like this:

y = c(66.18, 66.69, 50.31, 51.99, 52.07, 52.87, 54.03)
group = as.factor(c(rep("a", 3), rep("b", 2), rep("c",2)))

The group means are:
    a       b       c 
61.06   52.03   53.45 

and the overall mean is 56.31.

Using Helmert contrasts in lm I get the following

> my.mod = lm(y~group, contrasts = list(group = "contr.helmert"))

> summary(my.mod)

Call:
lm(formula = y ~ group, contrasts = list(group = "contr.helmert"))

Residuals:
     1      2      3      4      5      6      7 
  5.12   5.63 -10.75  -0.04   0.04  -0.58   0.58 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   55.513      2.540  21.858 2.59e-05 ***
group1        -4.515      3.012  -1.499    0.208    
group2        -1.032      1.851  -0.557    0.607    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.598 on 4 degrees of freedom
Multiple R-squared:  0.4093,	Adjusted R-squared:  0.114 
F-statistic: 1.386 on 2 and 4 DF,  p-value: 0.3489

Here comes the questions. Is it possible to modify Helmert contrasts in order to use weighted means instead of means of means? 

Thanks

Erlis



More information about the R-help mailing list