Description Usage Arguments Value Examples
A version of the wald function that produces a data frame directly, analogously to as.data.frame(wald(...))
1 2 3 |
fit |
a model for which a |
Llist |
a hypothesis matrix or a pattern to be matched or a list of these |
clevel |
level for confidence intervals. No confidence intervals if clevel is NULL |
data |
data frame used as 'data' attribute fot list elements returned only if
the corresonding element of |
debug |
(default FALSE) produce verbose information |
full |
if TRUE, the hypothesis matrix is the model matrix for
|
fixed |
if |
invert |
if |
method |
'svd' (current default) or 'qr' is the method used to find the full rank version of the hypothesis matrix. 'svd' has correctly identified the rank of a large hypothesis matrix where 'qr' has failed. |
se |
a vector with the multiples of standard error used to generate lower and upper limits. 'names(se)' is appended to 'L' and 'U' to label the variables. |
which |
selects elements of 'obj' to turn to a data.frame. |
A data frame with estimated coefficient, standard error, and, optionally, upper and lower limits and
the variables included the 'data' element of 'obj' if present.
If length(which) > 1
, the returned object is a list of data frames.
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | ## Not run:
###
### Using walddf to create and plot a data frame with predicted values
###
data(hs)
library( nlme )
fit <- lme(mathach ~ (ses+I(ses^2)) * Sex * Sector, hs, random = ~ 1|school)
summary(fit)
pred <- expand.grid( ses = seq(-2,2,.1), Sex = levels(hs$Sex), Sector = levels(hs$Sector))
head(pred)
w <- walddf(fit, getX(fit,data=pred)) # attaches data to wald.object so it can included in data frame
head(w)
library(latticeExtra)
xyplot(coef ~ ses | Sector, w, groups = Sex,
auto.key = T, type = 'l',
fit = w$coef,
upper = w$L,
lower = w$U,
xlim = c(0,2),
subscript = T) +
glayer( gpanel.fit(...))
wald(fit, 'ses')
wald( fit, 'Sex') # sig. overall effect of Sex
wald( fit, ':Sex') # but no evidence of interaction with ses
wald( fit, '\\^2') # nor of curvature
# conditional effect of ses
head(getX(fit))
###
### Effect of ses: Differentiating with respect to ses
###
L <- Lfx(fit, list(
0,
1,
2 * ses,
0 * M(Sex),
0 * M(Sector),
1 * M(Sex),
2 * ses * M(Sex),
1 * M(Sector),
2 * ses * M(Sector),
0 * M(Sex) * M(Sector),
1 * M(Sex) * M(Sector),
2 * ses * M(Sex) * M(Sector)),
pred)
head(wald(fit, L), 20)
w <- walddf(fit, L)
xyplot(coef ~ ses | Sector, w, groups = Sex,
auto.key = list(columns = 2, lines = T),
type = 'l',
fit = w$coef,
upper = w$L,
lower = w$U,
xlim = c(0,2),
ylab = 'estimate change in mathach per unit increase in ses',
subscripts = T) +
glayer( gpanel.fit(...)) +
layer(panel.abline(a=0,b=0,lwd = 1, color ='black'))
###
### Difference in effect of ses between Sectors
###
pred.d <- expand.grid( ses = seq(-2,2,.1), Sex = levels(hs$Sex), Sector = levels(hs$Sector), Sector0 = levels(hs$Sector))
pred.d <- subset(pred.d, Sector > Sector0)
head(pred.d)
L <- Lfx(fit, list(
0,
0,
0 * ses,
0 * M(Sex),
0 * M(Sector),
0 * M(Sex),
0 * ses * M(Sex),
1 * M(Sector) - M(Sector0),
2 * ses * (M(Sector) - M(Sector0)),
0 * M(Sex) * M(Sector),
1 * M(Sex) * (M(Sector) - M(Sector0)),
2 * ses * M(Sex) * (M(Sector) - M(Sector0))),
pred.d)
w <- walddf(fit, L)
w
w <- sortdf(w, ~ Sex/ses)
xyplot(coef ~ ses | Sex, w,
type = 'l',
auto.key = T,
fit = w$coef,
lower = w$L2,
upper = w$U2,
xlim = c(0,2),
ylab = 'effect of ses (Public minus Catholic)',
subscripts = T) +
layer(gpanel.fit(...)) +
layer(panel.abline(a=0,b=0,lwd = 1, color ='black'))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.