apa_interval: Typeset Interval Estimate

View source: R/apa_interval.R

apa_intervalR Documentation

Typeset Interval Estimate

Description

Creates a character string to report interval estimates, such as frequentist confidence or Bayesian credible intervals.

Usage

apa_interval(
  x,
  ...,
  conf.int = NULL,
  interval_type = NULL,
  enclose_math = FALSE
)

print_interval(
  x,
  ...,
  conf.int = NULL,
  interval_type = NULL,
  enclose_math = FALSE
)

## S3 method for class 'numeric'
apa_interval(
  x,
  y = NULL,
  conf.int = NULL,
  interval_type = NULL,
  enclose_math = FALSE,
  ...
)

## S3 method for class 'matrix'
apa_interval(
  x,
  conf.int = NULL,
  interval_type = NULL,
  enclose_math = FALSE,
  ...
)

## S3 method for class 'data.frame'
apa_interval(x, ...)

## S3 method for class 'list'
apa_interval(x, ...)

apa_confint(x, ..., interval_type = "CI")

print_confint(x, ..., interval_type = "CI")

apa_hdint(x, ..., interval_type = "HDI")

print_hdint(x, ..., interval_type = "HDI")

Arguments

x

Numeric. A vector (of length 2, unless y is also specified) with, a two-column matrix, or a data.frame, which can coerced to a matrix.

...

Arguments passed on to apa_num

conf.int

Numeric. Confidence level of the interval. Ignored if level can be inferred from attributes of x, see Details.

interval_type

Character. Abbreviation indicating the type of interval estimate, e.g. CI.

enclose_math

Logical. Indicates whether the interval should be enclosed in $ (i.e., a math environment).

y

Numeric. An optional vector of the same length as x.

Details

If possible the confidence level of the interval is inferred from attributes of x. For a vector of length 2, the attribute conf.level is is consulted; for a matrix or data.frame the column names are used, if they are of the format "2.5 \

If x is a matrix or data.frame the row names are used as names for the returned list of intervals.

Value

A single interval is returned as a character vector of length 1; multiple intervals are returned as a named list of character vectors of length 1.

See Also

apa_num()

Examples

apa_confint(1, 2, conf.int = 0.95)
apa_confint(c(1, 2), conf.int = 0.95)
apa_confint(matrix(c(1, 2), ncol = 2), conf.int = 0.95)
apa_confint(confint(lm(cars)))
apa_confint(confint(lm(cars)), digits = 3)

papaja documentation built on Sept. 29, 2023, 9:07 a.m.