[R] Is this a valid syntax for lm()
Brian Smith
br|@n@m|th199312 @end|ng |rom gm@||@com
Wed Nov 12 17:30:54 CET 2025
Hi,
I have below code
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
group1 <- head(gl(2, 10, 22, labels = c("Ctl1","Trt1")), 20)
weight <- c(ctl, trt)
dat = as.data.frame(cbind(weight, group, group1))
lm.D9 <- lm(weight ~ group * group1 - 1 - group1, dat)
I want to incorporate interaction between 2 variables group and
group1, however do not want to incorporate level-0 for group1 not the
intercept.
Therefore I used (-1 - group1) in the formula.
I would like to know if above is a valid syntax for the stated model.
Thanks and regards,
More information about the R-help
mailing list