Skip to content

Commit

Permalink
Merge pull request #143 from OHDSI/is140-fitOutcomeModel
Browse files Browse the repository at this point in the history
Is140 fit outcome model
  • Loading branch information
schuemie committed Jun 7, 2023
2 parents f591d6e + 067e5dd commit 158bc82
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions R/OutcomeModels.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ fitOutcomeModel <- function(population,
collect()
} else {
# TODO: check if main effect covariate exists in data
mainEffectTermsCheck <- !is.null(covariateData$covariates %>%
distinct(.data$covariateId) %>%
inner_join(covariateData$covariateRef, by = "covariateId") %>%
select(id = "covariateId", name = "covariateName") %>%
collect())

if (!mainEffectTermsCheck) {
stop("No main effects exist.")
}
}

# Create interaction terms
Expand Down Expand Up @@ -279,11 +288,12 @@ fitOutcomeModel <- function(population,
if (any(separability)) {
removeCovariateIds <- as.numeric(names(separability)[separability])
# Add main effects of separable interaction effects, and the other way around:
# TODO: don't remove main effect is useCovariates = TRUE
removeCovariateIds <- unique(c(
removeCovariateIds,
interactionTerms$covariateId[interactionTerms$interactionId %in% removeCovariateIds]
))
if (!useCovariates) {
removeCovariateIds <- unique(c(
removeCovariateIds,
interactionTerms$covariateId[interactionTerms$interactionId %in% removeCovariateIds]
))
}
removeCovariateIds <- unique(c(
removeCovariateIds,
interactionTerms$interactionId[interactionTerms$covariateId %in% removeCovariateIds]
Expand Down

0 comments on commit 158bc82

Please sign in to comment.