Skip to content

Commit

Permalink
Merge pull request #149 from OHDSI/fitOutcomeModel-tests
Browse files Browse the repository at this point in the history
Fit outcome model tests
  • Loading branch information
schuemie committed Nov 8, 2023
2 parents c93d0fb + ba25a6b commit f953bad
Show file tree
Hide file tree
Showing 4 changed files with 1,250 additions and 170 deletions.
10 changes: 7 additions & 3 deletions R/OutcomeModels.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ fitOutcomeModel <- function(population,
)) {
errorMessages <- checkmate::makeAssertCollection()
checkmate::assertDataFrame(population, null.ok = TRUE, add = errorMessages)
checkmate::assertNames(names(population), must.include = c("rowId", "outcomeCount", "treatment", "timeAtRisk", "personSeqId"), add = errorMessages)
if (!is.null(cohortMethodData)) {
checkmate::assertNames(names(cohortMethodData), must.include = c("analysisRef", "cohorts", "covariateRef", "covariates", "outcomes"), add = errorMessages)
}
checkmate::assertClass(cohortMethodData, "CohortMethodData", null.ok = TRUE, add = errorMessages)
checkmate::assertChoice(modelType, c("logistic", "poisson", "cox"), add = errorMessages)
checkmate::assertLogical(stratified, len = 1, add = errorMessages)
Expand All @@ -96,9 +100,6 @@ fitOutcomeModel <- function(population,
if (stratified && nrow(population) > 0 && is.null(population$stratumId)) {
stop("Requested stratified analysis, but no stratumId column found in population. Please use matchOnPs or stratifyByPs to create strata.")
}
if (is.null(population$outcomeCount)) {
stop("No outcome variable found in population object. Use createStudyPopulation to create variable.")
}
if (is.null(cohortMethodData) && useCovariates) {
stop("Requested all covariates for model, but no cohortMethodData object specified")
}
Expand All @@ -108,6 +109,9 @@ fitOutcomeModel <- function(population,
if (any(excludeCovariateIds %in% interactionCovariateIds)) {
stop("Can't exclude covariates that are to be used for interaction terms")
}
if (any(includeCovariateIds %in% excludeCovariateIds)) {
stop("Can't exclude covariates that are to be included")
}
if (inversePtWeighting && is.null(population$iptw)) {
stop("Requested inverse probability weighting, but no IPTW are provided. Use createPs to generate them")
}
Expand Down
167 changes: 0 additions & 167 deletions tests/testthat/setup-runCmAnalyses.R

This file was deleted.

Loading

0 comments on commit f953bad

Please sign in to comment.