Skip to contents

[Maturing]

Converts a TOSTER result object of class 'TOSTt' or 'TOSTnp' to a list of class 'htest', making it compatible with standard R hypothesis testing functions and workflows.

Usage

as_htest(TOST)

Arguments

TOST

A TOSTER result object of class 'TOSTt' or 'TOSTnp'.

Value

Returns a list of class 'htest' containing the following components:

  • statistic: The value of the test statistic (t for TOSTt, WMW for TOSTnp).

  • parameter: The degrees of freedom of the test statistic (df for TOSTt, NULL for TOSTnp).

  • p.value: The p-value of the test.

  • estimate: Estimated difference in raw units.

  • null.value: Equivalence bounds.

  • alternative: A character string describing the alternative hypothesis ("equivalence" or "minimal.effect").

  • method: A character string indicating the performed test.

  • data.name: A character string giving the names of the data.

  • conf.int: The confidence interval of the difference.

Details

This function allows you to convert the specialized TOSTER result objects to the standard 'htest' class used by most R hypothesis testing functions (e.g., t.test(), cor.test()). This enables:

  • Integration with other statistical functions that expect 'htest' objects

  • Using helper functions like df_htest() or describe_htest()

  • Consistent reporting and interpretation of results

See also

Other htest: htest-helpers, simple_htest()

Examples

# Example 1: Converting TOST t-test results to htest
res1 <- t_TOST(formula = extra ~ group, data = sleep, eqb = .5, smd_ci = "goulet")
htest_result <- as_htest(res1)
htest_result  # Print the htest object
#> 
#> 	Welch Two Sample t-test
#> 
#> data:  extra by group
#> t = -1.2719, df = 17.776, p-value = 0.8901
#> alternative hypothesis: equivalence
#> null values:
#> mean difference mean difference 
#>            -0.5             0.5 
#> 90 percent confidence interval:
#>  -3.0533815 -0.1066185
#> sample estimates:
#> mean difference 
#>           -1.58 
#> 

# Example 2: Using the converted result with htest helpers
describe_htest(htest_result)
#> [1] "The Welch Two Sample t-test is not statistically significant (t(17.776) = -1.27, p = 0.89, mean difference = -1.58, 90% C.I.[-3.05, -0.107]) at a 0.05 alpha-level. The null hypothesis cannot be rejected. At the desired error rate, it cannot be stated that the true mean difference is between -0.5 and 0.5."
df_htest(htest_result)
#>                    method         t       df p.value mean difference  lower.ci
#> 1 Welch Two Sample t-test -1.271948 17.77647 0.89011           -1.58 -3.053381
#>     upper.ci conf.level alternative null1 null2
#> 1 -0.1066185        0.9 equivalence  -0.5   0.5

# Example 3: Converting a non-parametric TOST result
res2 <- wilcox_TOST(extra ~ group, data = sleep, eqb = 2)
as_htest(res2)
#> 
#> 	Wilcoxon rank sum test with continuity correction
#> 
#> data:  extra by group
#> WMW = 59, p-value = 0.2601
#> alternative hypothesis: equivalence
#> null values:
#> location shift location shift 
#>             -2              2 
#> 90 percent confidence interval:
#>  -3.39996507 -0.09995341
#> sample estimates:
#> location shift 
#>      -1.346388 
#>