| lm2 | R Documentation | 
This function is a minor modification of the lm() function
to allow the use of a pre-specified design matrix. It is not intended for
public use but only to support modelTest.lm.
lm2(
  formula,
  data,
  subset,
  weights,
  na.action,
  model = TRUE,
  x = FALSE,
  y = FALSE,
  qr = TRUE,
  singular.ok = TRUE,
  contrasts = NULL,
  offset,
  designMatrix,
  yObserved,
  ...
)
| formula | An object of class "formula" although it is only minimally used | 
| data | the dataset | 
| subset | subset | 
| weights | any weights | 
| na.action | Defaults to  | 
| model | defaults to  | 
| x | defaults to  | 
| y | defaults to  | 
| qr | defaults to  | 
| singular.ok | defaults to  | 
| contrasts | defaults to  | 
| offset | missing by default | 
| designMatrix | a model matrix / design matrix (all numeric, pre coded if applicable for discrete variables) | 
| yObserved | the observed y values | 
| ... | additional arguments | 
an lm class object
lm
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.