tests/testthat/test-riskreg.R

testthat::context("Risk regression")

set.seed(1)
m <- lava::lvm(a[-2] ~ 1*x+z,
               linpred.target[1] ~ 1,
               linpred.nuisance[-1] ~ 2*x+z)
lava::distribution(m,~a) <- lava::binomial.lvm("logit")
m <- lava::binomial.rr(m, "y","a","linpred.target","linpred.nuisance")
d <- lava::sim(m,1e3)


testthat::test_that("MLE convergence", {
    fit <- targeted::riskreg(y ~ a | 1 | x+z | 1, data=d, type="rr")
    influ <- lava::IC(fit)
    val <- colMeans(influ)^2
    testthat::expect_true(val<1e-3)
})

Try the targeted package in your browser

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

targeted documentation built on Oct. 26, 2022, 1:09 a.m.