carriedaymont / growthcleanr

R package for cleaning anthropometric (height and weight) data from electronic health record systems.
Other
12 stars 7 forks source link

height.tolerance.cm parameter not behaving as expected #134

Open SamuelMcEwan opened 1 year ago

SamuelMcEwan commented 1 year ago

Hello, I recently QC'd longitudinal growth data and made an interesting observation. Despite setting the 'height.tolerance.cm' parameter to 1, Growthcleanr did not flag sequential height drops > 1.5cm.

Here is a reproducible example: I have simulated data in which a subsequent height measurement drops by 1.5cm.

Generate Data

library(growthcleanr); library(dplyr); library(magrittr)

set.seed(101)
df <- lapply(LETTERS[1:5], function(id){      
  offset = rnorm(1, sd = 10)
  age = 1:20
  ht = age*5 + offset + rnorm(20)
  data.frame(id, age, ht)
}) %>% do.call(rbind,.) %>% mutate(sex = 'M')

Create a spurious datapoint

df$ht[10] <- df$ht[9] - 1.5

Impose loose & strict QC

df <- df %>% mutate(
  qc_default = with(df,         
                    cleangrowth(
                      subjid = id,
                      param = 'HEIGHTCM',
                      agedays = 365.25*age,
                      sex = sex,
                      measurement = ht,
                      height.tolerance.cm=2.5
                    )
  ),
  qc_strict = with(df, 
                   cleangrowth(
                      subjid = id,
                      param = 'HEIGHTCM',
                      agedays = 365.25*age,
                      sex = sex,
                      measurement = ht,
                      height.tolerance.cm=1
                    )
  )
  )

Results

df[10,]

The datapoint d[10,] is not flagged by a strict QC process where height.tolerance.cm=1

This seems unintended, and I'd appreciate some help or just spreading the word. Sorry if I have misinterpreted the functionalities of growthcleanr.

Kind regards

carriedaymont commented 1 month ago

Thank you very much for flagging this, and I apologize for the delay in getting back to you. We are getting ready to do some updates/improvements soon (hopefully) and will look at this as soon as we can.

Thank you for your interest in our package!