tests/testthat/test-asm.R

test_that("test empty model", {


})


test_that("gaussian covariate, gaussian error", {
  n = 100
  p = 2
  X = matrix(rnorm(n*p), n, p)
  beta0 = rep(0, p)
  noise = rnorm(n)
  y = X %*% beta0 + noise
  mydf = data.frame(y, X)
  colnames(mydf) = c("y", paste0("X", 1:p))
  asm_res = asm(y ~ ., data = mydf)

  betahat = coef(asm_res)
  expect_equal(length(betahat), p+1)

  ## expect that the true beta is close to the estimated beta
  expect_true(all(abs(betahat[2:(p+1)] - beta0) < 1))
})

Try the asm package in your browser

Any scripts or data that you put into this service are public.

asm documentation built on April 12, 2025, 1:41 a.m.