Description Usage Arguments Details Value Methods (by class) See Also Examples
This S3 generic function allows the computation of confidence intervals of contrasts
(i.e. linear combinations) of fixed-effects in many models.
The default implementation computes Wald's confidence intervals with any model as long as it consistently implements fixcoef
, vcov_fixcoef
and df_for_wald
.
It is also specialized for GLMs with Wald's, LRT and Rao's confidence intervals and may be specialized with other models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | confint_contrast(
model,
contrast,
method = NULL,
level = 0.95,
alternative = c("two.sided", "less", "greater"),
...
)
## Default S3 method:
confint_contrast(
model,
contrast,
method = NULL,
level = 0.95,
alternative = c("two.sided", "less", "greater"),
clevel_logit_tol = 1e-05,
deriv_rel_SE = 1e-04,
...,
force = FALSE,
debuglevel = 1
)
|
model |
a fitted statistical model such as a glm or a coxph. |
contrast |
numeric vector of the same length as the number of coefficients in the model; it describes the contrast |
method |
character string value; specification of the algorithm used (implementation dependent). NULL must be accepted. Suggested values are "LRT" for inverted likelihood ratio test, "Rao" for inverted Rao's score test, "Wald" for inverted Wald's test. |
level |
numeric value between 0 and 1; nominal confidence level. |
alternative |
character value; either "two.sided", "less" or "greater", specifying a two-sided or one-sided confidence interval. |
... |
Additional parameters that may be used by some implementations. |
clevel_logit_tol |
numeric value; the difference of logit(1-level) that can be tolerated for convergence of the algorithm. |
deriv_rel_SE |
numeric value; the delta for the numeric derivative, used for the Newton-Raphson algorithm applied to the logit(1-pvalue). It is expressed as a multiplicative factor for the Standard Error of the contrast. |
force |
logical; if TRUE, force computation of P-values in case of convergence problems. |
debuglevel |
integer value; set to 0 (default) to disable warnings, 1 to enable warnings and 2 to enable warnings and notes. |
This function should consistent with estimate_contrast
and p_value_contrast
as they are designed to be used together.
If a null hypothesis (H0) is specified, it MUST be ignored by confint_contrast
as in estimate_contrast
.
If you want to make it consistent with p_value_contrast
you may subtract H0 from the output of estimate_contrast
and confint_contrast
.
When alternative is "less" or "greater", one-sided confidence intervals are generated.
A vector of length 2. The first value MUST be named "lower" and be the lower bound of the confidence interval. The second value MUST be named "upper" and be the upper bound of the confidence interval.
default
: Default implementation
Supports Wald's test on a wide range of models, including lm
, mlm
,
stats::glm
, negbin
, MASS::polr
,
MASS::rlm
(with normality assumptions, defeating the purpose of rlm), nlme::lme
,
nlme::gls
, lme4::lmer
, lme4::glmer
,
mgcv::gam
, gam::gam
, survival::coxph
,
survival::survreg
,
nnet::multinom
, stats::nls
.
It can be easily extended by implementing three generic functions:
fixcoef
, vcov_fixcoef
and df_for_wald
.
If the implementations of coef
, vcov
and df.residual
are consistent,
you do not have to implement fixcoef
, vcov_fixcoef
and df_for_wald
.
It also provides method="LRT"
and method="Rao"
on stats::glm
and method="LRT"
on
negative binomials (negbin
) models.
It is implemented by inverting tests performed by p_value_contrast
, with the help of the Newton-Raphson algorithm
on the logit of the two-sided P-value.
Other Contrast functions:
estimate_confint_contrast()
,
estimate_contrast()
,
p_value_contrast()
1 2 3 4 5 6 7 8 9 10 11 | data(mtcars)
model1 = glm(family="gaussian", data=mtcars, hp ~ 0+factor(gear))
# do cars with 5 gears have more horse power (hp) than cars with 4 gears ?
confint_contrast(model1, c(0,-1,1))
# now, we fit an equivalent model (same distribution and same predictions)
model2 = glm(family=gaussian(log), data=mtcars, hp ~ 0+factor(gear))
# do cars with 5 gears have at least twice the horse power than cars with 4 gears ?
confint_contrast(model2, c(0,-1,0.5))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.