ttesti: T-test Given Summary Statistics with Improved Layout

View source: R/ttesti.R

ttestiR Documentation

T-test Given Summary Statistics with Improved Layout

Description

Performs a one- or two-sample t-test given summary statistics. In the two-sample case, the user can specify whether or not equal variances should be presumed.

Usage

ttesti(
  obs,
  mean,
  sd,
  obs2 = NA,
  mean2 = NA,
  sd2 = NA,
  null.hypoth = 0,
  conf.level = 0.95,
  alternative = "two.sided",
  var.eq = FALSE,
  more.digits = 0
)

Arguments

obs

number of observations for the first sample.

mean

the sample mean of the first sample.

sd

the sample standard deviation of the first sample.

obs2

number of observations for the second sample (this is optional).

mean2

if obs2 is supplied, then sample mean of the second sample must be supplied.

sd2

if obs2 is supplied, then sample standard deviation of the second sample must be supplied.

null.hypoth

a number specifying the null hypothesis for the mean (or difference in means if performing a two-sample test). Defaults to zero.

conf.level

confidence level of the test. Defaults to 0.95.

alternative

a string: one of "less", "two.sided", or "greater" specifying the form of the test. Defaults to a two-sided test.

var.eq

a logical value, either TRUE or FALSE (default), specifying whether or not equal variances should be presumed in a two-sample t-test.

more.digits

a numeric value specifying whether or not to display more or fewer digits in the output. Non-integers are automatically rounded down.

Details

If obs2, mean2, or sd2 is specified, then all three must be specified and a two-sample t-test is run.

Value

a list of class ttesti. The print method lays out the information in an easy-to-read format.

tab

A formatted table of descriptive and inferential statistics (number of observations, mean, standard error of the mean estimate, standard deviation), along with a confidence interval for the mean.

df

Degrees of freedom for the t-test.

p

P-value for the t-test.

tstat

Test statistic for the t-test.

par

A vector of information about the type of test (null hypothesis, alternative hypothesis, etc.)

twosamp

A logical value indicating whether a two-sample test was performed.

call

The call made to the ttesti function.

Examples


# t-test given sample descriptives
ttesti(24, 175, 35, null.hypoth=230)

# two-sample test
ttesti(10, -1.6, 1.5, 30, -.7, 2.1)


rigr documentation built on Sept. 7, 2022, 1:05 a.m.