[R] Weigths in lm and kruskal_test

Armin Goralczyk agoralczyk at gmail.com
Tue Jan 5 19:52:10 CET 2010


Is it correct that the weights argument in lm and kruskal_test from
package coin have different meanings?

Example:

library("coin")

set.seed(29)
x <- gl(3, 10)
y <- rnorm(length(x), mean = c(0, 0, 1)[x])
d <- data.frame(y = y, x = x)
w <- rep(2, nrow(d)) ### double each obs

### all the same
kruskal_test(y ~ x, data = rbind(d, d))
kruskal_test(y ~ x, data = d[rep(1:nrow(d), w),])
kruskal_test(y ~ x, data = d, weights = ~ w)

anova(lm(y ~ x, data = d[rep(1:nrow(d), w),]))
anova(lm(y ~ x, data = d, weights = w))

-- 
Armin Goralczyk
--
http://www.gwdg.de/~agoralc



More information about the R-help mailing list