{"action":"closed","issue":{"url":"https://api.github.com/repos/OHDSI/CohortMethod/issues/25","labels_url":"https://api.github.com/repos/OHDSI/CohortMethod/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/OHDSI/CohortMethod/issues/25/comments","events_url":"https://api.github.com/repos/OHDSI/CohortMethod/issues/25/events","html_url":"https://github.com/OHDSI/CohortMethod/issues/25","id":56245099,"number":25,"title":"createPs returns NaN","user":{"login":"ApproximateIdentity","id":2095718,"avatar_url":"https://avatars.githubusercontent.com/u/2095718?v=3","gravatar_id":"","url":"https://api.github.com/users/ApproximateIdentity","html_url":"https://github.com/ApproximateIdentity","followers_url":"https://api.github.com/users/ApproximateIdentity/followers","following_url":"https://api.github.com/users/ApproximateIdentity/following{/other_user}","gists_url":"https://api.github.com/users/ApproximateIdentity/gists{/gist_id}","starred_url":"https://api.github.com/users/ApproximateIdentity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ApproximateIdentity/subscriptions","organizations_url":"https://api.github.com/users/ApproximateIdentity/orgs","repos_url":"https://api.github.com/users/ApproximateIdentity/repos","events_url":"https://api.github.com/users/ApproximateIdentity/events{/privacy}","received_events_url":"https://api.github.com/users/ApproximateIdentity/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-02T14:47:55Z","updated_at":"2015-02-03T02:33:52Z","closed_at":"2015-02-03T02:33:52Z","body":"If I run the script below, the auc that is returned is NaN. It's not the same problem as in issue https://github.com/OHDSI/CohortMethod/issues/24 because in this case getdrugfromindication() is actually returning some ids.\r\n\r\n```R\r\nlibrary(SqlRender)\r\nlibrary(Cyclops)\r\nlibrary(CohortMethod)\r\n\r\n\r\n# Login info.\r\nconnectionDetails <- createConnectionDetails(\r\n    dbms = \"redshift\",\r\n    user = Sys.getenv(\"USER\"),\r\n    password = Sys.getenv(\"MYPGPASSWORD\"), \r\n    server = \"omop-datasets.cqlmv7nlakap.us-east-1.redshift.amazonaws.com/truven\",\r\n    schema = \"mslr_cdm4\",\r\n    port = \"5439\")\r\n\r\n\r\n# The function that does the analysis.\r\ntest <- function() {\r\n    drug_concept_id <- 1342001\r\n    drug_concept_name <- \"Enalaprilat\"\r\n    comparator_drug_concept_id <- 974166\r\n    comparator_drug_concept_name <- \"Hydrochlorothiazide\"\r\n    indication_concept_id <- 21001432\r\n    indication_concept_name <- \"Hypertension\"\r\n\r\n    lowBackPain = 194133\r\n\r\n    # Get SNOMED-CT drug_concept_id from indication.\r\n    drug_indication_concept_ids <- getdrugfromindication(\r\n        connectionDetails,\r\n        indication_concept_id)\r\n\r\n    num_ids <- length(unique(drug_indication_concept_ids))\r\n    print(num_ids)\r\n\r\n    # Cohort Method.\r\n    cohortdata <- getDbCohortData(\r\n        connectionDetails,\r\n        cdmSchema = connectionDetails$schema,\r\n        resultsSchema = connectionDetails$schema,\r\n        targetDrugConceptId = drug_concept_id,\r\n        comparatorDrugConceptId = comparator_drug_concept_id,\r\n        indicationConceptIds = drug_indication_concept_ids)\r\n\r\n    num_persons <- length(unique(cohortdata$cohorts$personId))\r\n    print(num_persons)\r\n    num_covariates <- length(unique(cohortdata$covariates$covariateId))\r\n    print(num_covariates)\r\n\r\n    ps <- createPs(\r\n        cohortdata,\r\n        lowBackPain)\r\n\r\n    auc <- computePsAuc(ps)\r\n    print(auc)\r\n\r\n    return(auc)\r\n}\r\n\r\n\r\ngetdrugfromindication <- function(connectionDetails, indication_concept_id) {\r\n    sql <- \"\r\n    SELECT DISTINCT\r\n        c2.concept_id\r\n    FROM (\r\n        SELECT\r\n            *\r\n        FROM vocabulary.concept\r\n        WHERE\r\n            concept_id = @indication_concept_id\r\n        ) t1 INNER JOIN vocabulary.concept_relationship cr1\r\n            ON t1.concept_id = cr1.concept_id_1\r\n        INNER JOIN vocabulary.concept c1\r\n            ON cr1.concept_id_2 = c1.concept_id\r\n            AND c1.vocabulary_id = 1\r\n        INNER JOIN vocabulary.concept_ancestor ca1\r\n            ON c1.concept_id = ca1.ancestor_concept_id\r\n        INNER JOIN vocabulary.concept c2\r\n            ON ca1.descendant_concept_id = c2.concept_id\r\n            AND c2.vocabulary_id = 1\r\n    ;\r\n    \"\r\n\r\n    sql <- renderSql(\r\n        sql = sql,\r\n        indication_concept_id = indication_concept_id)$sql\r\n\r\n    conn <- connect(connectionDetails)\r\n    data <- dbGetQuery(conn, sql)\r\n    dbDisconnect(conn)\r\n\r\n    data$concept_id\r\n}\r\n\r\n\r\nauc <- test()\r\n```"}}