lm2 {JWileymisc} | R Documentation |
Modified lm() to use a specified design matrix
Description
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
.
Usage
lm2(
formula,
data,
subset,
weights,
na.action,
model = TRUE,
x = FALSE,
y = FALSE,
qr = TRUE,
singular.ok = TRUE,
contrasts = NULL,
offset,
designMatrix,
yObserved,
...
)
Arguments
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 |
Value
an lm class object
See Also
lm
Examples
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)
[Package JWileymisc version 1.4.1 Index]