tests/testthat/test_jmodelMult.R

cat("\nTests for 'jmodelMult'")

myEps <- if (capabilities("long.double")) .Machine$double.eps else 1e-9
 
fitLME <- lme(sqrt(CD4) ~ bs(obstime, 4, Boundary.knots = c(0, 21.5)), random =~ 1 | ID, data = aids)
fitCOX <- coxph(Surv(start, stop, event) ~ drug, data = aids, x = TRUE)
control <- list( max.iter = 50, nknot = 3, tol.L = 1e-08, tol.P = 1e-04)

test_that(" basic jmodelMult test with for aids data model = 1, rho = 1 ", { 
  m_MULT <- jmodelMult(fitLME, fitCOX, aids, model = 1, rho = 1, timeVarY = 'obstime', control = control)
  expect_equal( m_MULT$coefficients$lgLik, -2543.368, tolerance = (10 ^ 12) * myEps, scale = 1)
  expect_equal( mean(m_MULT$coefficients$lamb$bashaz), 0.0906141, tolerance = (10 ^ 7) * myEps, scale = 1)
})

test_that(" basic jmodelMult test with for aids data model = 2, rho = 1 ", { 
  m_MULT <- jmodelMult(fitLME, fitCOX, aids, model = 2, rho = 1, timeVarY = 'obstime', control = control)
  expect_equal( m_MULT$coefficients$lgLik, -2542.776, tolerance = (10 ^ 12) * myEps, scale = 1)
  expect_equal( mean(m_MULT$coefficients$lamb$bashaz), 0.1073857, tolerance = (10 ^ 9) * myEps, scale = 1)
})

Try the JSM package in your browser

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

JSM documentation built on Sept. 4, 2020, 1:08 a.m.