Learn R Programming

EstimDiagnostics (version 0.0.3)

expect_mean_equal: Test a mean-value using t-test

Description

Expectation checking whether values from a given sample have a certain mean or that two samples have the same mean. The underlying procedure is Student's t-test t.test. The expectation throws an error when the test's p-value is smaller than the threshold p-value.

Usage

expect_mean_equal(p_value = 0.001, ...)

Arguments

p_value

threshold p-value of the test

...

parameters to pass to t.test function including data sample(s)

Value

Invisibly returns a p-value of the test

Examples

Run this code
# NOT RUN {
# This test doesn't pass
# }
# NOT RUN {
x<-1:1e3
expect_mean_equal(x=x)
# }
# NOT RUN {
# This one passes, but shouldn't
x<-rnorm(1e3) + 0.01
expect_mean_equal(x=x)

x<-rnorm(1e3)
expect_mean_equal(x=x)

# check if 2 samples have the same mean
x<-rnorm(1e3, mean=10)
y<-rnorm(1e3, mean=10)
expect_mean_equal(x=x, y=y)
# }

Run the code above in your browser using DataLab