Confidence Interval for the Difference of Two Coefficients in a Linear Model
CoeffDiffCI.Rd
Calculate the confidence interval for the difference of two coefficients in a linear model.
Usage
CoeffDiffCI(x, coeff, conf.level = 0.95, sides = c("two.sided", "left", "right"))
Arguments
- x
the linear model object
- coeff
a vector of length two, containing either the names or the index of the two coefficients whose difference should be used
- conf.level
confidence level of the interval.
- sides
a character string specifying the side of the confidence interval, must be one of
"two.sided"
(default),"left"
or"right"
. You can specify just the initial letter."left"
would be analogue to a hypothesis of"greater"
in at.test
.
Value
a numeric vector with 3 elements:
- mean
mean
- lwr.ci
lower bound of the confidence interval
- upr.ci
upper bound of the confidence interval
Examples
# get some model first...
r.lm <- FitMod(Fertility ~ ., data=swiss, fitfn="lm")
# calculate the confidence interval for the difference of the
# coefficients Examination and Education
CoeffDiffCI(r.lm, c("Examination", "Education"))
#> diff lwr.ci upr.ci
#> -0.6129318 -1.4017814 0.1759177
# the test could be calculated as
car::linearHypothesis(r.lm, "Education = Examination")
#>
#> Linear hypothesis test:
#> - Examination + Education = 0
#>
#> Model 1: restricted model
#> Model 2: Fertility ~ Agriculture + Examination + Education + Catholic +
#> Infant.Mortality
#>
#> Res.Df RSS Df Sum of Sq F Pr(>F)
#> 1 42 2231.5
#> 2 41 2105.0 1 126.42 2.4623 0.1243