Learn R Programming

mosaic (version 0.10.0)

confint.numeric: Confidence interval methods for output of resampling

Description

Methods for confint to compute confidence intervals on numerical vectors and numerical components of data frames.

Usage

## S3 method for class 'numeric':
confint(object, parm, level = 0.95, ...,
  method = "stderr", margin.of.error = "stderr" \%in\% method == "stderr")

## S3 method for class 'do.data.frame': confint(object, parm, level = 0.95, ..., method = "stderr", margin.of.error = "stderr" \%in\% method, df = Inf)

## S3 method for class 'data.frame': confint(object, parm, level = 0.95, ...)

## S3 method for class 'summary.lm': confint(object, parm, level = 0.95, ...)

Arguments

object
and R object
parm
a vector of parameters
level
a confidence level
...
additional arguments
method
either "stderr" (default) or "quantile". ("se" and "percentile" are allowed as aliases) or a vector containing both.
margin.of.error
if true, report intervals as a center and margin of error.
df
degrees for freedom. This is required when object was produced using link{do} when using the standard error to compute the confidence interval since typically this information is not recorded in these objects. The default (

Value

  • When applied to a data frame, returns a data frame giving the confidence interval for each variable in the data frame using t.test or binom.test, unless the data frame was produced using do, in which case it is assumed that each variable contains resampled statistics that serve as an estimated sampling distribution from which a confidence interval can be computed using either a central proportion of this distribution or using the standard error as estimated by the standard deviation of the estimated sampling distribution. For the standard error method, the user must supply the correct degrees of freedom for the t distribution since this information is typically not available in the output of do.

    When applied to a numerical vector, returns a vector.

Details

The methods of producing confidence intervals from bootstrap distributions are currently quite naive. In particular, when using the standard error, assistance is required with the degrees of freedom, and it may not be possible to provide a correct value in all situations.

Examples

Run this code
if (require(mosaicData)) {
  bootstrap <- do(500) * diffmean( age ~ sex, data=resample(HELPrct) )
  confint(bootstrap)
  confint(bootstrap, df=nrow(HELPrct) - 1)
  confint(bootstrap, method="quantile")
  confint(bootstrap, margin.of.error=FALSE, df=nrow(HELPrct) - 1)
  confint(bootstrap, margin.of.error=TRUE, level=0.99,
    df=nrow(HELPrct) - 1,
    method=c("se", "quant") )
  bootstrap2 <- do(500)*mean( resample(1:10) )
  confint(bootstrap2)
  confint(bootstrap2, df=9)
}
if (require(mosaicData)) {
confint( summary(lm(width ~ length * sex, data=KidsFeet)) )
}

Run the code above in your browser using DataLab