tests/testthat/test-cprViaSql.R

library("testthat")

context("test-cprViaSql.R")

test_that("Try loading cohort via SQL", {
   load(system.file("extdata/cpr_test.RData",
                    package="Cyclops")) # loads "test" and "cov"

   test$TIME[which(test$TIME == 0)] <- 1

   cd <- createSqlCyclopsData(modelType="cpr")

   appendSqlCyclopsData(cd, test$STRATUM_ID, test$ROW_ID,
                    test$Y,
                    test$TIME,
                    #rep(1, length(test$Y)),
                    cov$ROW_ID, cov$COVARIATE_ID,
                    cov$COVARIATE_VALUE)

   finalizeSqlCyclopsData(cd,
                          useOffsetCovariate=-1,
                          addIntercept=FALSE)

   fit <- fitCyclopsModel(cd, prior = createPrior("laplace",0.1))
   coef(fit)[which(coef(fit) != 0)]
})

Try the Cyclops package in your browser

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

Cyclops documentation built on Nov. 2, 2023, 6:03 p.m.