R/KernelTest.R

Defines functions KernelTest

Documented in KernelTest

KernelTest <-
  function(pos,    # x values
           X2,     # Chi-square values, each with 'df' degrees of freedom
           lambda,     # Smoothing bandwidth
           df = 1  # 'nu'
           )
  {
    # Local kernel sums
    j <- KernelSums(x = pos, y = X2, scale = lambda)
    sky <- j[,'sky']
    sk <- j[,'sk']
    skk <- j[,'skk']
    
    # Satterthwaite approximation
    a <- df*skk/sk
    b <- sk*sk/skk
    
    outX2 <- sky/a # Approx. chi-square with b degrees of freedom
    
    P <- pchisq(outX2, df = b, lower.tail = FALSE)
    
    P
  }
timpeters82/DMRcate-devel documentation built on Oct. 2, 2024, 10:33 a.m.