Skip to content

Commit

Permalink
Clean up, add factor levels, and fix tiny SDe bug
Browse files Browse the repository at this point in the history
  • Loading branch information
delosh653 committed Aug 1, 2023
1 parent 05e0afd commit afddde0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
22 changes: 22 additions & 0 deletions R/growth.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,26 @@ cleangrowth <- function(subjid,
'Exclude-SDE-All-Extreme',
'Exclude-SDE-EWMA',
'Exclude-SDE-One-Day',
"Exclude-EWMA2-middle",
"Exclude-EWMA2-birth-WT",
"Exclude-EWMA-2-birth-WT-ext",
"Exclude-EWMA-2-first",
"Exclude-EWMA-2-first-ext",
"Exclude-EWMA2-last",
"Exclude-EWMA2-last-high",
"Exclude-EWMA2-last-ext",
"Exclude-EWMA2-last-ext-high",
"Exclude-EWMA2-birth-HT-HC",
"Exclude-EWMA2-birth-HT-HC-ext",
"Exclude-Min-diff",
"Exclude-Max-diff",
"Exclude-2-meas->1-year",
"Exclude-2-meas-<1-year",
"Exclude-1-meas",
"Exclude-Error-load",

# old

'Exclude-EWMA-8',
'Exclude-EWMA-9',
'Exclude-EWMA-10',
Expand All @@ -259,6 +279,8 @@ cleangrowth <- function(subjid,
'Exclude-Single-Outlier',
'Exclude-Too-Many-Errors',
'Exclude-Too-Many-Errors-Other-Parameter',

#new
"Exclude-Absolute-BIV",
"Exclude-Standardized-BIV",
"Exclude-Evil-Twin",
Expand Down
32 changes: 28 additions & 4 deletions R/infants_clean.R
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ cleanbatch_infants <- function(data.df,
if (s_df$agedays[1]%%2 == 0){
which.min(s_df$v)
} else {
which.max(s_df$v == max(s_df$v[order(med_diff)[1:2]]))
which.max(s_df$v)
}
rem_ids <- c(rem_ids, s_df$index[-keep_val])
}
Expand All @@ -855,7 +855,11 @@ cleanbatch_infants <- function(data.df,

# 15: moderate EWMA ----

# THINK ABOUT NNTE FULL HERE
if (!quietly)
cat(sprintf(
"[%s] Exclude moderate EWMA...\n",
Sys.time()
))

# create the valid set
# we only running carried forwards on valid values, non NNTE values,
Expand Down Expand Up @@ -1113,6 +1117,12 @@ cleanbatch_infants <- function(data.df,

# 16: moderate EWMA for birth HT and HC ----

if (!quietly)
cat(sprintf(
"[%s] Exclude moderate EWMA for birth height and head circumference...\n",
Sys.time()
))

# create the valid set
# we only running carried forwards on valid values, non NNTE values,
# and non single values, and non weight
Expand Down Expand Up @@ -1260,7 +1270,11 @@ cleanbatch_infants <- function(data.df,

# 17: raw differences ----

# NOTE: ADD STEP OUTPUT PRINT
if (!quietly)
cat(sprintf(
"[%s] Exclude raw differences...\n",
Sys.time()
))

# read in tanner data
tanner_ht_vel_rev_path <- ifelse(
Expand Down Expand Up @@ -1568,7 +1582,11 @@ cleanbatch_infants <- function(data.df,

# 19: 1 or 2 measurements ----

# NOTE: ADD STEP OUTPUT PRINT
if (!quietly)
cat(sprintf(
"[%s] Exclude 1 or 2 measurements...\n",
Sys.time()
))

# create the valid set
# we only running carried forwards on valid values, non NNTE values,
Expand Down Expand Up @@ -1667,6 +1685,12 @@ cleanbatch_infants <- function(data.df,

# 21: error load ----

if (!quietly)
cat(sprintf(
"[%s] Exclude error load...\n",
Sys.time()
))

valid_set <- !data.df$nnte_full

data.df[valid_set,
Expand Down

0 comments on commit afddde0

Please sign in to comment.