confint_contrast: Confidence interval estimation of contrasts

Description Usage Arguments Details Value Methods (by class) See Also Examples

View source: R/main.R

Description

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.

Usage

 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
)

Arguments

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 sum(contrast*fixcoef(model)).

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.

Details

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.

Value

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.

Methods (by class)

See Also

Other Contrast functions: estimate_confint_contrast(), estimate_contrast(), p_value_contrast()

Examples

 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))

glmglrt documentation built on Aug. 7, 2020, 9:10 a.m.