Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using estimatePeriodPrevalence #2

Closed
rfherrerac opened this issue Jul 26, 2023 · 11 comments
Closed

Error when using estimatePeriodPrevalence #2

rfherrerac opened this issue Jul 26, 2023 · 11 comments

Comments

@rfherrerac
Copy link

Describe the bug
I created my cohorts as mentioned in the package. When using the function estimatePeriodPrevalence
prev <- estimatePeriodPrevalence(cdm = cdm,
denominatorTable = "denominatorfull",
outcomeTable = "outcome",
interval = "years",
fullContribution = FALSE,
completeDatabaseIntervals =TRUE,
outcomeLookbackDays = NULL)

I am getting this error
Error in UseMethod("cohortCount") :
no applicable method for 'cohortCount' applied to an object of class "cdm_reference"

R version 4.2.3 (2023-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.7 (Ootpa)

other attached packages:
[1] IncidencePrevalence_0.4.1 dbplyr_2.3.2
[3] dplyr_1.1.2 DatabaseConnector_6.1.0
[5] RPostgres_1.4.5 CDMConnector_0.5.1

Additional context
Add any other context about the problem here.

@edward-burn
Copy link
Collaborator

Hi @rfherrerac, could you try updating CDMConnector to the latest cran version?

@rfherrerac
Copy link
Author

Thanks @edward-burn. I did it. Now the error changed to:
Getting prevalence for analysis 1 of 12
Error in seq.Date(from = s, to = e, by = i) : 'from' must be of length 1

My reference cohort is defined as:
cdm <- generateDenominatorCohortSet(
cdm = cdm,
name = "denominator",
cohortDateRange = c(as.Date("2021-01-01"), as.Date("2023-01-01")),
ageGroup = list(c(0,100),c(0,17), c(18,74),
c(75,100)),
sex = c("Male", "Female", "Both"),
daysPriorHistory = 0,
requirementInteractions=TRUE
)

@edward-burn
Copy link
Collaborator

Hmmm sorry about that uninformative error message @rfherrerac. I think it is indicating that it is not finding any full years to estimate period prevalence for (as you have the requirement completeDatabaseIntervals =TRUE). What is your earliest observation period start date and latest observation period end date in your database?

@rfherrerac
Copy link
Author

thanks for seeing this. I was checking and in the getPrevalence.R line 74, when doing

start date

start <- studyPop %>%
dplyr::summarise(min(.data$cohort_start_date, na.rm = TRUE)) %>%
dplyr::pull() %>%
as.Date()
Is getting NULL. When removing the na.rm =TRUE and putting na.rm=FALSE works. Any suggestion?

@edward-burn
Copy link
Collaborator

Hmm that's odd, what database management system are you using?

@rfherrerac
Copy link
Author

redshift

@edward-burn
Copy link
Collaborator

Thanks @rfherrerac, looking into this there was a slight change in behaviour since dplyr v1.1 that has caused this problem for redshift. I'm going to do a quick update and release of IncidencePrevalence with a fix for this (I have a fix working locally, but just need to go through a few steps to get the release out).

@rfherrerac
Copy link
Author

Super! thanks a lot.

@edward-burn
Copy link
Collaborator

@rfherrerac could you please try with the latest version here on github?
remotes::install_github("darwin-eu/IncidencePrevalence")

@rfherrerac
Copy link
Author

Perfect! Worked. Thanks a lot!

1 similar comment
@rfherrerac
Copy link
Author

Perfect! Worked. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants