inst/tests/test-ttest.R

context('t-test')

data('ToothGrowth')

test_that('ttest works', {
    ttestBF(ToothGrowth$len, ToothGrowth$dose)
    ttestBF(formula=len~supp, data=ToothGrowth)
})

test_that('rejects bad input', {
    expect_error(
        ttestBF(formula=len~dose, data=ToothGrowth),
        'Indep. groups t test requires a factor with exactly 2 levels.',
        fixed=TRUE
    )
    expect_error(
        ttestBF(formula=len~dose+supp, data=ToothGrowth),
        'Indep. groups t test can only support 1 factor as predictor.',
        fixed=TRUE
    )
    expect_error(
        ttestBF(formula=len~dose:supp, data=ToothGrowth),
        'Interaction terms are not allowed in t test.',
        fixed=TRUE
    )
})

Try the BayesFactor package in your browser

Any scripts or data that you put into this service are public.

BayesFactor documentation built on Sept. 22, 2023, 1:06 a.m.