library(testthat)
library(jeksterslabRboot)
context("Test wald.")

Parameters

thetahat <- 0.860
sehat <- 0.409
sqrt_wald <- 2.10
p <- 0.036

Results

result_01 <- sqrt_wald_test(
  thetahat = thetahat,
  sehat = sehat,
  null = 0,
  dist = "z"
)
result_01
#>  statistic          p 
#> 2.10268949 0.03549292
result_02 <- sqrt_wald_test(
  thetahat = thetahat,
  sehat = sehat,
  null = 0,
  dist = "t",
  df = 1000
)
result_02
#>  statistic          p 
#> 2.10268949 0.03574239
result_03 <- wald_test(
  thetahat = thetahat,
  varhat = sehat^2
)
result_03
#>  statistic          p 
#> 4.42130308 0.07098584

testthat

test_that("statistic", {
  expect_equivalent(
    result_01[1],
    result_02[1],
    sqrt(result_03[1]),
    sqrt_wald
  )
})
test_that("p", {
  expect_equivalent(
    round(
      result_01[2],
      digits = 3
    ),
    round(
      result_02[2],
      digits = 3
    ),
    p
  )
})