Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.34 KB | None | 0 0
  1.  mf <- model.frame(formula)
  2.     }
  3.     else {
  4.         mf <- model.frame(formula, data)
  5.     }
  6.     cl <- match.call()
  7.     xy <- split(model.extract(mf, "response"), mf[, 2])
  8.     faclevels <- names(xy)
  9.     x <- xy[[1]]
  10.     y <- xy[[2]]
  11.     if (tr == 0.5)
  12.         warning("Comparing medians should not be done with this function!")
  13.     alpha <- 0.05
  14.     if (is.null(y)) {
  15.         if (is.matrix(x) || is.data.frame(x)) {
  16.             y = x[, 2]
  17.             x = x[, 1]
  18.         }
  19.         if (is.list(x)) {
  20.             y = x[[2]]
  21.             x = x[[1]]
  22.         }
  23.     }
  24.     if (tr > 0.25)
  25.         print("Warning: with tr>.25 type I error control might be poor")
  26.     x <- x[!is.na(x)]
  27.     y <- y[!is.na(y)]
  28.     h1 <- length(x) - 2 * floor(tr * length(x))
  29.     h2 <- length(y) - 2 * floor(tr * length(y))
  30.     q1 <- (length(x) - 1) * winvar(x, tr)/(h1 * (h1 - 1))
  31.     q2 <- (length(y) - 1) * winvar(y, tr)/(h2 * (h2 - 1))
  32.     df <- (q1 + q2)^2/((q1^2/(h1 - 1)) + (q2^2/(h2 - 1)))
  33.     crit <- qt(1 - alpha/2, df)
  34.     dif <- mean(x, tr) - mean(y, tr)
  35.     low <- dif - crit * sqrt(q1 + q2)
  36.     up <- dif + crit * sqrt(q1 + q2)
  37.     test <- abs(dif/sqrt(q1 + q2))
  38.     yuen <- 2 * (1 - pt(test, df))
  39.     result <- list(test = test, conf.int = c(low, up), p.value = yuen,
  40.         df = df, diff = dif, call = cl)
  41.     class(result) <- "yuen"
  42.     result
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement