and finally... thingy <- function(x) { x <- C(x, poly, 1) tmp <- contrasts(x) contrasts(x, 1) <- 2 * tmp / sum(abs(tmp)) x }
dat2 <- with(data.catapult, data.frame( Distance, h=thingy(h), s=thingy(s), l=thingy(l), e=thingy(e), b=thingy(b) ) ) lm5 <- lm(Distance ~ .^2, data = dat2) summary(lm5) On Tue, Jun 26, 2012 at 12:35 AM, Simon Knapp <sleepingw...@gmail.com> wrote: > ... but this is tantalisingly close: > > dat1 <- with(data.catapult, > data.frame( > Distance, > h=C(h, poly, 1), > s=C(s, poly, 1), > l=C(l, poly, 1), > e=C(e, poly, 1), > b=C(b, poly, 1) > ) > ) > lm4 <- lm(Distance ~ .^2, data = dat1) > summary(lm4) > > ... wish I knew what it meant. > > > > On Tue, Jun 26, 2012 at 12:18 AM, Simon Knapp <sleepingw...@gmail.com> wrote: >> They are coding the variables as factors and using orthogonal >> polynomial contrasts. This: >> >> data.catapult <- data.frame(data.catapult$Distance, >> do.call(data.frame, lapply(data.catapult[-1], factor, ordered=T))) >> contrasts(data.catapult$h) <- >> contrasts(data.catapult$s) <- >> contrasts(data.catapult$l) <- >> contrasts(data.catapult$e) <- >> contr.poly(3, contrasts=F) >> contrasts(data.catapult$b) <- contr.poly(2, contrasts=F) >> lm1 <- lm(Distance ~ .^2, data=data.catapult) >> summary(lm1) >> >> gets you closer (same intercept at least), but I can't explain the >> remaining differences. I'm not even sure why the results to look like >> they do (interaction terms like "a*b" not "a:b" and one level for each >> interaction). >> >> Hope that helps, >> Simon Knapp ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.