# PND FOR SINGLE-CASE RESEARCH (2016, AUGUST) # Citation: Tarlow, K. R., & Penland, A. (2016, August). # PND for single-case research (R code). Retrieved # from http://ktarlow.com/stats/ # R SYNTAX COPYRIGHT (C) 2016 KEVIN R. TARLOW & ANDREW PENLAND # url: http://www.ktarlow.com/stats # email: krtarlow@gmail.com # adapted from: Tarlow, K. R., & Pendland, A. (2016). Outcome # assessment and inference with the Percentage # of Nonoverlapping Data (PND) single-case # statistic. Practice Innovations, 1(4), # 221-233. # This work is licensed under the Creative Commons # Attribution-NonCommercial 3.0 Unported License. # To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/3.0/deed.en_US # # You are free to copy, distribute, transmit, and adapt # the work under the following conditions: # # Attribution - You must attribute the work in the manner # specified by the author, KEVIN R. TARLOW (but not in any way # that suggests that the author endorses you or your use # of the work). # # Noncommercial You may not use this work for commercial # purposes. C <- function(n, k) { return(factorial(n) / (factorial(n - k) * factorial(k))) } pnd <- function(nA, nB, k) { n <- nA + nB p <- 0 i <- k while (i < (nB + 1)) { M <- 1 while (M < (n + 1)) { r <- 1 while (r < (nA + 1)) { p <- p + C(nA, r) * (M - 1)^(nA - r) * C(nB, i) * (n - M)^i * M^(nB - i) r <- r + 1 } M <- M + 1 } i <- i + 1 } p <- p / n^n PND <- k / nB * 100 results <- data.frame(PND, p) return(results) }