| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/conf_int.R |
| 3 |
\name{conf_int} |
| 4 |
\alias{conf_int} |
| 5 |
\title{Calculate confidence intervals for all or selected regression coefficients in |
| 6 |
a fitted model} |
| 7 |
\usage{ |
| 8 |
conf_int( |
| 9 |
obj, |
| 10 |
vcov, |
| 11 |
level = 0.95, |
| 12 |
test = "Satterthwaite", |
| 13 |
coefs = "All", |
| 14 |
..., |
| 15 |
p_values = FALSE |
| 16 |
) |
| 17 |
} |
| 18 |
\arguments{ |
| 19 |
\item{obj}{Fitted model for which to calculate confidence intervals.} |
| 20 |
|
| 21 |
\item{vcov}{Variance covariance matrix estimated using \code{vcovCR} or a |
| 22 |
character string specifying which small-sample adjustment should be used to |
| 23 |
calculate the variance-covariance.} |
| 24 |
|
| 25 |
\item{level}{Desired coverage level for confidence intervals.} |
| 26 |
|
| 27 |
\item{test}{Character vector specifying which small-sample corrections to |
| 28 |
calculate. \code{"z"} returns a z test (i.e., using a standard normal |
| 29 |
reference distribution). \code{"naive-t"} returns a t test with \code{m - |
| 30 |
1} degrees of freedom, where \code{m} is the number of unique clusters. |
| 31 |
\code{"naive-tp"} returns a t test with \code{m - p} degrees of freedom, |
| 32 |
where \code{p} is the number of regression coefficients in \code{obj}. |
| 33 |
\code{"Satterthwaite"} returns a Satterthwaite correction. Unlike in |
| 34 |
\code{coef_test()}, \code{"saddlepoint"} is not currently supported in |
| 35 |
\code{conf_int()} because saddlepoint confidence intervals do not have a |
| 36 |
closed-form solution.} |
| 37 |
|
| 38 |
\item{coefs}{Character, integer, or logical vector specifying which |
| 39 |
coefficients should be tested. The default value \code{"All"} will test all |
| 40 |
estimated coefficients.} |
| 41 |
|
| 42 |
\item{...}{Further arguments passed to \code{\link{vcovCR}}, which are only |
| 43 |
needed if \code{vcov} is a character string.} |
| 44 |
|
| 45 |
\item{p_values}{Logical indicating whether to report p-values. The default |
| 46 |
value is \code{TRUE}.} |
| 47 |
} |
| 48 |
\value{ |
| 49 |
A data frame containing estimated regression coefficients, standard |
| 50 |
errors, confidence intervals, and (optionally) p-values. |
| 51 |
} |
| 52 |
\description{ |
| 53 |
\code{conf_int} reports confidence intervals for each coefficient estimate in |
| 54 |
a fitted linear regression model, using a sandwich estimator for the standard |
| 55 |
errors and a small sample correction for the critical values. The |
| 56 |
small-sample correction is based on a Satterthwaite approximation. |
| 57 |
} |
| 58 |
\examples{ |
| 59 |
|
| 60 |
data("ChickWeight", package = "datasets") |
| 61 |
lm_fit <- lm(weight ~ Diet * Time, data = ChickWeight) |
| 62 |
diet_index <- grepl("Diet.:Time", names(coef(lm_fit))) |
| 63 |
conf_int(lm_fit, vcov = "CR2", cluster = ChickWeight$Chick, coefs = diet_index) |
| 64 |
|
| 65 |
V_CR2 <- vcovCR(lm_fit, cluster = ChickWeight$Chick, type = "CR2") |
| 66 |
conf_int(lm_fit, vcov = V_CR2, level = .99, coefs = diet_index) |
| 67 |
|
| 68 |
} |
| 69 |
\seealso{ |
| 70 |
\code{\link{vcovCR}} |
| 71 |
} |