walddf | R Documentation |
A version of the wald function that produces a data frame directly, analogously to as.data.frame(wald(...))
walddf(
fit,
Llist = "",
clevel = 0.95,
data = NULL,
debug = FALSE,
full = FALSE,
fixed = FALSE,
invert = FALSE,
method = "svd",
df = NULL,
se = 2,
digits = 3,
sep = ""
)
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 corresponding 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.
## 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.