tests/testthat/test-tabelle-sig-test.R

context("test-tabelle-sig-test.R")

test_that("auto sig test", {


  res <-
    Tabelle(
      warpbreaks,
      breaks,
      tension,
      by =  ~ wool,
      APA = TRUE,
      include.test = TRUE
    )
  res2 <-
    Tabelle(breaks + tension ~ wool,
            warpbreaks,
            APA = TRUE,
            include.test = TRUE
            )

  res3 <- APA2(breaks
              + tension
                  ~ wool,
               warpbreaks,
               test = TRUE,
               output = FALSE)




  expect_true(is.list(res))

  expect_true(is.data.frame(res[[1]]))


  expect_equal(
    res[[1]]$statistics,
    c(
      "F(1, 52)=1.33, p=.253",
      "X2(2)=0.00, p=1.000",
      "",
      "",
      ""
    )
  )

  expect_equal(res[[1]]$statistics,
               res2[[1]]$statistics)

  expect_equal(res2[[1]]$statistics[1],
               res3[[1]]$sig.Test[1])
})





test_that("eigene sig test", {



  expect_equal(
    Tabelle(
      warpbreaks,
      breaks,
      by =  ~ wool,
      APA = TRUE,
      test = "t.test"
    )[[1]]$statistics,
    "T(42)=1.63, p=.110"
  )


  expect_equal(
    Tabelle(
      warpbreaks,
      breaks,
      by =  ~ wool,
      APA = TRUE,
      test = "anova"
    )[[1]]$statistics,
    "F(1, 52)=2.67, p=.108"
  )

  # https://stats.stackexchange.com/questions/231738/clarification-on-mann-whitney-wilcoxon-test
  # Finally, note that the "Warning" from wilcox.test was just that:
  # a warning rather than an indication that your results are incorrect.
  # The test was OK, reporting a p-value based on a normal approximation
  # rather than an exact p-value based on the data values. If you had 50
  # or more cases, your call to wilcox.test would not even have tried to
  # calculate exact p-values. The coin package in R has a wilcox_test
  # function that can calculate exact p-values in the presence of ties,
  # but I see no need here for an exact p-value.


  expect_warning( expect_equal(
    Tabelle(
      warpbreaks,
      breaks,
      by =  ~ wool,
      APA = TRUE,
      test = "wilcox.test"
    )[[1]]$statistics,
    "U=431.00, p=.253"
  ))

  expect_warning( expect_equal(
    Tabelle(
      warpbreaks,
      breaks,
      by =  ~ wool,
      APA = TRUE,
      test = "u.test"
    )[[1]]$statistics,
    "U=431.00, p=.253"
  ))



  expect_equal(
    Tabelle(
      warpbreaks,
      breaks,
      by =  ~ wool,
      APA = TRUE,
      test = "kruskal.test"
    )[[1]]$statistics,
    "H(1)=1.33, p=.250"
  )




  expect_equal(
    Tabelle(
      warpbreaks,
      breaks,
      by =  ~ wool,
      APA = TRUE,
      test = "h.test"
    )[[1]]$statistics,
    "H(1)=1.33, p=.250"
  )





  # expect_equal(
  #   Tabelle(
  #     warpbreaks,
  #     breaks,
  #     by =  ~ wool,
  #     APA = TRUE,
  #     test = "chisq.test"
  #   )[[1]]$statistics,
  #   "chisq.test"
  # )


  expect_equal(
    Tabelle(
      warpbreaks,
      breaks,
      by =  ~ wool,
      APA = TRUE,
      test = "Hmisc"
    )[[1]]$statistics,
    "F(1, 52)=1.33, p=.253"
  )





  # expect_equal(
  #   Tabelle(
  #     warpbreaks,
  #     breaks,
  #     by =  ~ wool,
  #     APA = TRUE,
  #     test = "SPSS"
  #   )[[1]]$statistics,
  #   "H(1)=1.33, p=.250"
  # )
  #
  #





  expect_equal(
    Tabelle(warpbreaks,
            breaks ,
            APA = TRUE,
            test = "shapiro.test")$shapiro.test,
    "W=0.89, p<.001"
  )





  expect_warning(expect_equal(Tabelle(warpbreaks,
                       breaks ,
                       APA = TRUE,
                       test = "ks.test")$ks.test,
               "W=0.17, p=.100"))


})
stp4/stp25stat documentation built on Sept. 17, 2021, 2:03 p.m.