Lakens / TOSTER

TOST equivalence test and power functions
35 stars 18 forks source link

Paired equivalence testing issue #89

Closed azh05 closed 2 months ago

azh05 commented 2 months ago

Hi, thanks for creating the TOSTER package! It's been a great help.

I was running the t_TOST function with these parameters t_TOST(x = c(0, 0, 0, 0, 0), hypothesis = "EQU", y = c(1, 1, 1, 1, 0.5), paired = TRUE, eqb = c(-0.5, 0.5), alpha = 0.05) and I get this error:

Error in get_ncp_t2(t_stat, d_df, conf.level = 1 - alpha * 2) : object 'Best.Low' not found

It also occurs when I swap the values forx and y, but not when paired = FALSE. Changing the var.equal parameter also doesn't fix the bug. Am I using the function correctly?

arcaldwell49 commented 2 months ago

You have an SD of zero in the "x" condition. The SMD cannot be estimated for paired samples in this case. You can get the results to run with smd_ci set to z or t.

Example:

# warning: bogus result interpretation
t_TOST(x = c(0, 0, 0, 0, 0), 
hypothesis = "EQU", 
y = c(1, 1, 1, 1, 0.5), paired = TRUE, eqb = c(-0.5, 0.5), alpha = 0.05, 
smd_ci = "z")

If this data is "real" however, I do not think I would recommend doing this. If you're trying to test whether the change from some baseline (x = 0) is greater than 0.5, I'd suggest just using a one-tailed Wilcoxon signed rank test (i'm making a lot of assumptions here).

wilcox.test(
  x =  c(1, 1, 1, 1, 0.5) - c(0, 0, 0, 0, 0),
  mu = 0.5, alternative = "greater"
)

Using the describe_htest function we can get the following description.

TOSTER::describe_htest(wilcox.test( + x = c(1, 1, 1, 1, 0.5) - c(0, 0, 0, 0, 0), + mu = 0.5, alternative = "greater" + )) No alpha level set or confidence interval provided. Defaulting to 0.05 [1]

"The Wilcoxon signed rank test with continuity correction is statistically significant (V = 10, p = 0.036) at a 0.05 alpha-level. The null hypothesis can be rejected. At the desired error rate, it can be stated that the true location is greater than 0.5."