Description Usage Arguments Details Value Author(s) See Also Examples
General Linear Hypothesis with Wald test for, e.g., lm
, glm
,
lme
, nlme
and lmer
objects. Can be extended to other
classes by writing an appropriate getFix
method.
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 | wald(
fit,
L. = "",
clevel = 0.95,
p.adjust = "holm",
adjust = c("all", "each"),
pred = NULL,
data = NULL,
debug = FALSE,
maxrows = 25,
full = FALSE,
fixed = FALSE,
invert = FALSE,
method = "svd",
df = NULL,
pars = NULL,
tol.df = 1e+06,
tol.qr = 1e-10,
...
)
## S3 method for class 'wald'
print(x, round = 6, ...)
## S3 method for class 'wald'
as.data.frame(
x,
row.names = NULL,
optional,
se = 2,
digits = 3,
sep = "",
which = 1,
...
)
|
fit |
a model for which a |
L. |
a hypothesis matrix or a pattern to be matched or a list of these. |
clevel |
level for confidence intervals. No confidence intervals if
|
p.adjust |
a method to adjust p-values for simultaneous inference,
using the |
adjust |
if |
pred |
(default |
data |
data frame used as |
debug |
(default |
maxrows |
maximum number of rows of hypothesis matrix for which a full variance-covariance matrix is returned |
full |
if |
fixed |
normally if |
invert |
if |
method |
|
df |
denominator degrees of freedom (overrides usual value). |
pars |
passed to |
tol.df |
tolerance for detecting reliable computation of degrees of freedom
(default, |
tol.qr |
zero tolerance (default |
..., optional |
to match generic, ignored. |
x |
a |
row.names |
optional row names for the resulting data frame. |
se |
multiplier (default 2) for standard errors in computing confidence limits. |
digits, round |
number of digits to the right of the decimal. |
sep |
separator character, for creating names, default is |
which |
which element(s) of a |
Tests a general linear hypothesis for the linear fixed portion of a model. The hypothesis can be specified in a variety of ways such as a hypothesis matrix or a pattern that is used as a regular expression to be matched with the names of coefficients of the model. A number of tools are available to facilitate the generation of hypothesis matrices.
wald
correctly handles hypotheses for stable regression splines generated by
functions returned by gspline
.
Usage:
wald(fit, L)
where L
is a hypothesis matrix
wald(fit, "pat")
where "pat"
is a regular expression (see
regex
) used to match names of coefficients of fixed effects.
e.g. wald( fit, ":.*:")
tests all second and higher order
interactions.
wald(fit, c(2, 5, 6))
to test 2nd, 5th and 6th coefficients.
wald(fit, list(hyp1 = c(2, 5, 6), H2 = "pat"))
for more than one
hypothesis matrix.
To extend the wald
function to a new class of objects, one needs to
write a getFix
method to extract estimated coefficients, their
estimated covariance matrix, and the denominator degrees of freedom for each
estimated coefficient.
An object of class wald
.
Georges Monette
To extend to new models see getFix
. To generate
hypothesis matrices for general splines see gspline
.
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 | if (require(nlme)){
###
### Using wald to create and plot a data frame with predicted values
###
MathAchieve$Sector <- MathAchSchool[as.character(MathAchieve$School), "Sector"]
fit <- lme(MathAch ~ (SES+I(SES^2)) * Sex * Sector, MathAchieve, random = ~ 1|School)
summary(fit)
pred <- expand.grid( SES = seq(-2,2,.1), Sex = levels(MathAchieve$Sex),
Sector = levels(MathAchieve$Sector))
pred
w <- wald(fit, getX(fit, data=pred)) # attaches data to wald.object
# so it can be included in data frame
w <- wald(fit, pred = pred)
w <- as.data.frame(w)
head(w)
if(require("latticeExtra")){
xyplot(coef ~ SES | Sector, w, groups = Sex,
auto.key = TRUE, type = 'l',
fit = w$coef,
upper = with(w,coef+2*se),
lower = with(w,coef-2*se),
subscript = TRUE) +
glayer(panel.fit(...))
}
wald(fit, 'Sex') # test overall effect of Sex
wald(fit, ':Sex') # but no evidence of interaction with ses
wald(fit, '\\^2') # nor of curvature
# but we continue for the sake of illustration
L <- Lform(fit, list(0, 1, 2*SES, 0, Sex == 'Male', (Sex == 'Male')*2*SES), MathAchieve)
head(L)
(ww <- wald (fit, L ))
wald.dd <- as.data.frame(ww, se = 2)
head( wald.dd )
if (require("lattice")){
xyplot(coef + U2 + L2 ~ SES | Sex, wald.dd,
main= 'Increase in predicted mathach per unit increase in ses')
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.