Lform {carEx} | R Documentation |
Creates an L matrix using expressions evaluated in data
for each column of
the L matrix
Lform(fit, form, data = getData(fit))
fit |
a fitted model with a |
form |
formulas (expressions) to evaluate (see Details). |
data |
the data frame in which expressions are evaluated. |
If Lform
is called with only a fit
argument, it outputs code
consisting of an expression that would, if used as the form
argument
to Lform
would generate the full model matrix for the linear model.
If Lform
is called with two or three arguments, it generates a
hypothesis matrix by evaluating the expressions in form
in the
environment data
. The function M
is designed to facilitate the
generation of blocks of the hypothesis matrix corresponding to main effects
or interaction effects of factors.
hypothesis matrix
mod <- lm( income ~ (education + I(education^2) )* type, Prestige) summary(mod) # estimate the marginal value of an extra year of education for a # range of years for each type years.type <- expand.grid( education = seq(6,18,2), type = levels(Prestige$type)) Lf <- Lform( mod, list( 0, 1, 2*education, 0, 0, type =="prof", type =="wc", 2*education*(type =="prof"), 2*education*(type =="wc")), years.type) Lf ww <- wald( mod, Lf) ww ytderiv <- as.data.frame( ww, se = 2) head( ytderiv ) if (require("lattice")){ xyplot(coef ~ education, ytderiv, groups = type, type = 'l', auto.key = list(columns = 3, lines = TRUE, points = FALSE)) }