ttesti: T-test Given Descriptive Statistics with Improved Layout

Description Usage Arguments Details Value Author(s) Examples

View source: R/ttesti.R

Description

Produces table of relevant descriptive statistics and inference for either one- or two-sample t-test. In the two-sample case, the user can specify whether or not equal variances should be presumed. Can also perform a test of equality of proportions, with the appropriate Wald or exact binomial based confidence intervals.

Usage

1
2
3
4
## Method with the appropriate defaults filled in
ttesti(obs, mean, sd, obs2=NA, mean2=NA, sd2=NA, 
       null.hyp = 0, level=.95, alternative="two.sided", 
       var.eq = FALSE, prop=FALSE, exact=FALSE)

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.hyp

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

alternative

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

level

confidence level of the test. Defaults to 95/100.

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. Also controls robust standard errors.

prop

if TRUE, performs a test of equality of proportions with Wald based confidence intervals.

exact

must be FALSE if prop=FALSE. If true, performs a test of equality of proportions with Exact Binomial based confidence intervals.

Details

Values must be placed in the specified spaces, in place of the defaults. If obs2, mean2, or sd2 is specified, then all three must be specified and a two-sample t-test is run.

Value

Prints a summary of the data and the corresponding t-test.

Variable

x in a one-sample test, or x and y in a two sample test. The first set of descriptives entered goes to x.

Obs

Number of observations of each variable: includes missing values.

Mean

the sample mean; also, the estimated difference in means in a two-sample test.

Std.Err.

the estimated standard error of the mean and of the difference in the two-sample test.

Std.Dev.

standard deviation estimates.

CI

a confidence interval for the means, and for the difference in the two-sample test. This is at the confidence level specified in the argument. If prop and/or exact are specified, also returns the appropriate Wald or Exact Binomial based confidence interval.

Null hypothesis

a statement of the null hypothesis.

Alternative hypothesis

a statement of the alternative hypothesis.

t

value of the t-statistic.

df

the degrees of freedom for the test.

Pr

a p-value for inference on the corresponding hypothesis test.

Author(s)

Scott S. Emerson, M.D., Ph.D., Andrew J. Spieker, Brian D. Williamson, Travis Y. Hee Wai, Solomon Lim

Examples

1
2
3
4
5
#- T-test given sample descriptives -#
ttesti(24, 175, 35, null.hyp=230)

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

uwIntroStats documentation built on May 2, 2019, 4:34 a.m.