mtcars$cyl <- factor(mtcars$cyl)
m <- lm(mpg ~ hp * cyl, data = mtcars)
x <- model.matrix(m)
y <- mtcars$mpg
m2 <- JWileymisc:::lm2(mpg ~ 1 + cyl + hp:cyl, data = mtcars,
designMatrix = x[, -2, drop = FALSE],
yObserved = y)
anova(m, m2)
rm(m, m2, x, y)
Run the code above in your browser using DataLab