param.t.test: T-test using describing parameters of data

View source: R/param_t_test.R

param.t.testR Documentation

T-test using describing parameters of data

Description

Performs one and two sample t-tests using describing parameters (i.e., mean, variance, length) of data

Usage

param.t.test(mean_x,var_x,n_x,mean_y=NA,var_y=NA,n_y=NA,
             mu=0,paired=FALSE,var.equal=FALSE,
             alternative=c("two.sided","less","greater"),conf.level=0.95,
             name_x="x",name_y="y")

Arguments

mean_x

The mean of the x data

var_x

The variance of the x data

n_x

The number of observations of the x data

mean_y

Optional. The mean of the y data

var_y

Optional. The variance of the y data

n_y

Optional. The number of observations of the y data

mu

The value of the true mean of x (if only x is provided) of the value of the differences between the true means of x and y (if both x and y are provided). By default set to 0

paired

A logical indicating whether one wants a paired t-test. By default set to FALSE

var.equal

A logical indicating whether the variances of x and y are assumed to be equal or not. By default set to FALSE

alternative

A character indicating the alternative hypothesis. By default, the t-test is bilateral and H1 is that there is a difference no matter its sign ("two.sided"). Otherwise, can be an unilateral test with H1 being that the difference is negative ("less") or positive ("greater")

conf.level

The confidence level of the interval. By default set to 95%

name_x

The name of the x data to be outputted in the test result

name_y

The name of the y data to be outputted in the test result

Value

As for t.test, a list with class "htest" containing the following components:

statistic

the value of the t-statistic

parameter

the degrees of freedom of the t-statistic

p.value

the p-value for the test

conf.int

a confidence interval for the mean appropriate to the specified alternative hypothesis

estimate

the (inputted) estimated mean or means depending on whether it was a one-sample or a two-sample test

null.value

the specified hypothesized value of the mean or mean difference depending on whether it was a one-sample or a two-sample test

stderr

the standard error of the mean/difference, used as denominator in the t-statistic formula

alternative

a character string describing the alternative hypothesis

method

a character string indicating what type of t-test was performed

data.name

a character string giving the (inputted) name(s) of the data

See Also

t.test

Examples

## Define data
set.seed(1)
A<-runif(10,0,100)
B<-runif(10,50,150)

mean_x<-mean(A)
var_x<-var(A)
n_x<-length(A)
mean_y<-mean(B)
var_y<-var(B)
n_y<-length(B)

## One sample t-test
t.test(A)
param.t.test(mean_x=mean_x,var_x=var_x,n_x=n_x)

## Two sample t-test with equal variances
t.test(A,B,var.equal=TRUE)
param.t.test(mean_x,var_x,n_x,mean_y,var_y,n_y,var.equal=TRUE)

## Two sample t-test with unequal variances
t.test(A,B)
param.t.test(mean_x,var_x,n_x,mean_y,var_y,n_y)


jacobmaugoust/ULT documentation built on May 16, 2023, 1:29 p.m.