Description Usage Arguments Examples
Creates an L matrix using expressions evaluated in data
for
each column or multi-column term of the L matrix
1 2 3 4 5 6 7 8 9 10 11 |
fit |
a fitted model with a 'getFix' method. |
expr.list |
a list of expressions with one component for each column (or groups of columns) of the hypothesis matrix corresponding to each term of the model. A term with multiple degrees of freedom can either be generated as separate single terms or with an expression that evaluates to a suitable matrix. |
data |
the data frame in which expressions are evaluated. |
wrap |
|
debug |
|
formula |
as an argument of |
expr |
as an argument of |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | ##
## The estimated effect of an additional year of education
##
data(Prestige) # from car
fit <- lm( income ~ (education+I(education^2)) * type, Prestige)
summary(fit)
Lfx(fit) # geneates expression to cut and paste and differentiate
pred <- expand.grid( education = 3:16, type = levels(Prestige$type))
Lf.ed <- Lfx( fit,
list( 0,
1 + 0* education,
2 * M(I(education)),
0 * M(type),
1 * 1 * M(type),
2 * M(I(education)) * M(type)
),pred)
zw <- as.data.frame(wald(fit,Lf.ed))
head(zw)
xyplot( coef ~ education , zw, groups = type, type = 'l', auto.key = T)
fit2 <- lm( income ~ (education+I(education^2)) * type*women, Prestige)
pred <- expand.grid( education = 3:16, type = levels(Prestige$type), women=c(0,50,100))
Lfx(fit2)
zw <- Lfx(fit2,
list( 0, # differentiated wrt education
1 * 1,
1 * M(I(education)),
0 * M(type),
0 * women,
1 * 1 * M(type),
2 * M(I(education)) * M(type),
1 * 1 * women,
2 * M(I(education)) * women,
0 * M(type) * women,
1 * 1 * M(type) * women,
2 * M(I(education)) * M(type) * women
),pred)
zw
zw <- as.data.frame( wald(fit2, zw))
summary(fit2)
xyplot( coef ~ education|women , zw, groups = type, type = 'l', auto.key = T,
ylim = c(-30000,30000))
###
### Differencing of factor
###
pred <- expand.grid( education = 3:18, women = c(0,50,100),
type = levels(Prestige$type),
type0 = levels(Prestige$type))
Lfx(fit2)
Lcomp <- Lfx(fit2,
list( 0,
0 * education,
0 * M(I(education^2)),
1 * M(type) - M(type0),
0 * women,
1 * education * (M(type)-M(type0)),
1 * M(I(education^2)) * (M(type) - M(type0)),
0 * education * women,
0 * M(I(education^2)) * women,
1 * (M(type)-M(type0)) * women,
1 * education * (M(type) - M(type0)) * women,
1 * M(I(education^2)) * (M(type) - M(type0)) * women
), pred)
zw <- as.data.frame( wald( fit2, Lcomp))
zw
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.