Non-inferiority testing.

#1
Hello all!

I am struggling to understand a non-inferiority analysis described in a paper by Meijer et al. 2009 for HPV-testing validation guidelines. The paper describes the test to be used as:

Screen 2018-10-21 11,46,46.jpg
Screen 2018-10-21 11,47,02.jpg

I've tried writing a function in R for this test, but the numbers I get are wildly off; maybe someone here can help me to get this right?

For the sensitivity test - a=65, b=5, c=3, d=0 (n=73)
For the specificity test - a=23, b=2, c=24, d=682 (n=731)

Thanks in advance!
 
#3
Code:
spec_func <- function(a,b,c,n){
  aa <- (n * (1 + 0.98))
  bb <- ((a + c) * (0.98 ^2) - (a + b + 2 * c))
  cc <- (c * (1 - 0.98) * (a + b + c) / n)
  f <- ((sqrt((bb^2 - 4 * aa * cc) - bb) / (2 * aa)))
  t <- ((a + b - (a + c) * 0.98) / sqrt(n * ((1 + 0.98) * f + (a + b + c) * (0.98 - 1) / n)))
  return(t)
}

sens_func <- function(a,b,c,n){
  aa <- (n * (1 + 0.9))
  bb <- ((a + c) *(0.9 ^2) - (a + b + 2 * c))
  cc <- (c * (1 - 0.9) * (a + b + c) / n)
  f <- ((sqrt((bb^2 - 4 * aa * cc) - bb) / (2 * aa)))
  t <- ((a + b - (a + c) * 0.9) / sqrt(n * ((1 + 0.9) * f + (a + b + c) * (0.9 - 1) / n)))
  return(t)
}
I want to apologize for the code in advance. This is the first time I am using R, and the first time coding since middle school qBasic coding...
 

hlsmith

Not a robit
#6
I was working on adding more uppercase parenthesis to you code but got stressed so stopped. In particular I don't think the sqrt covers the B in the f calculation, but you have it under it. There may be other issues. I prefer more "()" then implied ordering.
 
#7
Actually, I think that did the trick... I am a bit ashamed to have not seen that simple error. Getting z-values that are on the right scale. Thanks!