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

Implement carried-forward string handling option 4 #70

Open
wants to merge 25 commits into
base: upd-v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1a9781a
Figure out closest includes for carried-forward
delosh653 Sep 30, 2021
fd01462
Add option 4 (sweep strategy for carried forwards)
delosh653 Sep 30, 2021
fd81c2e
Update documentation
delosh653 Sep 30, 2021
c4b7b4b
Run check/update documentation
delosh653 Sep 30, 2021
cb18bc8
Add original ordering to acf results
delosh653 Sep 30, 2021
b2e81d3
Merge branch 'main' into acf-opt-4
delosh653 Oct 1, 2021
6017210
Update documentation for option 4
delosh653 Oct 1, 2021
8047fec
Fix small bug on option 3
delosh653 Oct 1, 2021
03e3951
Fix bug for no include after string of CFs
delosh653 Oct 13, 2021
dabc377
Add option 5 (use sweep strategy of 4 with acf-answers)
delosh653 Oct 23, 2021
66fceb5
Simplified min_ht of "definitely keep" criteria
delosh653 Nov 1, 2021
ac27719
Round height difference down to 0 if <= .05
delosh653 Nov 1, 2021
c72774c
Filter out observations for ages less than two years old
delosh653 Nov 1, 2021
4f8fc3a
Fix filtering bug
delosh653 Nov 1, 2021
cc7d394
Update tanner height velocity 2sd files
delosh653 Nov 4, 2021
3b56f96
Fix when misordered data is entered
delosh653 Nov 4, 2021
0735f40
Update criteria for absolution inclusion in option 5
delosh653 Nov 10, 2021
49be927
Integrate adjustcarryforward into cleangrowth
delosh653 Nov 15, 2021
739e625
Integrate adjustcarryforward into pediatric algorithm
delosh653 Nov 15, 2021
55747cc
Fix warnings related to unbound variables
delosh653 Nov 15, 2021
e744ebe
Add debugging for adjustcarryforward
delosh653 Dec 3, 2021
3a06a40
Fix bug with filtering out <= 2 years old
delosh653 Dec 3, 2021
565e867
Fix debugging for adjustcarryforward
delosh653 Dec 3, 2021
2bd8dd7
Update documentation
delosh653 Dec 3, 2021
c56ccd3
Add two new rules for maxdiff next ht inclusion criteria
delosh653 Jun 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ importFrom(stats,pnorm)
importFrom(stats,qnorm)
importFrom(stats,runif)
importFrom(stats,setNames)
importFrom(utils,head)
importFrom(utils,read.csv)
importFrom(utils,read.table)
importFrom(utils,tail)
Expand Down
1,137 changes: 772 additions & 365 deletions R/adjustcarryforward.R

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion R/extdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ NULL
#'
#' @name tanner_ht_vel_2sd
#'
#' @section tanner_ht_vel.csv:
#' @section tanner_ht_vel_int_2sd.csv:
#'
#' Used in function `acf_answers()`
#'
Expand Down
23 changes: 20 additions & 3 deletions R/growth.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
#' @param adult_columns_filename Name of file to save original adult data, with additional output columns to
#' as CSV. Defaults to "", for which this data will not be saved. Useful
#' for post-analysis. For more information on this output, please see README.
#' @param reinclude.ht.cf Logical (TRUE/FALSE) on whether or not to run step 18 (adjustcarryfoward). This will reconsider height carried forward values for inclusions. If reincluded, marked with "Include-Carried-Forward." Defaults to FALSE.
#' @param debug logical indicating debugging for adjustcarryforward step. Defaults to FALSE
#' @param debug_filename adjustcarryforward debugging file name. will save each iteration as paste0(tolower(debug_filename), "_sweep_position_X") as output to CSV.
#'
#' @return Vector of exclusion codes for each of the input measurements.
#'
Expand Down Expand Up @@ -152,7 +155,10 @@ cleangrowth <- function(subjid,
quietly = T,
adult_cutpoint = 20,
weight_cap = Inf,
adult_columns_filename = "") {
adult_columns_filename = "",
reinclude.ht.cf = FALSE,
debug = FALSE,
debug_filename = "") {
# avoid "no visible binding" warnings
N <- age_years <- batch <- exclude <- index <- line <- NULL
newbatch <- sd.median <- sd.orig <- tanner.months <- tbc.sd <- NULL
Expand Down Expand Up @@ -203,6 +209,7 @@ cleangrowth <- function(subjid,
# enumerate the different exclusion levels
exclude.levels <- c(
'Include',
'Include-Carried-Forward',
'Unit-Error-High',
'Unit-Error-Low',
'Unit-Error-Possible',
Expand Down Expand Up @@ -515,6 +522,7 @@ cleangrowth <- function(subjid,
measurement.to.z = measurement.to.z,
ewma.fields = ewma.fields,
ewma.exp = ewma.exp,
ref.data.path,
recover.unit.error = recover.unit.error,
include.carryforward = include.carryforward,
sd.extreme = sd.extreme,
Expand All @@ -524,7 +532,10 @@ cleangrowth <- function(subjid,
who.ht.vel = who.ht.vel,
lt3.exclude.mode = lt3.exclude.mode,
error.load.threshold = error.load.threshold,
error.load.mincount = error.load.mincount)
error.load.mincount = error.load.mincount,
reinclude.ht.cf = reinclude.ht.cf,
debug = debug,
debug_filename = debug_filename)
} else {
# create log directory if necessary
if (!is.na(log.path)) {
Expand All @@ -537,13 +548,15 @@ cleangrowth <- function(subjid,
.(batch),
cleanbatch,
.parallel = parallel,
.progress = "text",
.paropts = list(.packages = "data.table"),
log.path = log.path,
quietly = quietly,
parallel = parallel,
measurement.to.z = measurement.to.z,
ewma.fields = ewma.fields,
ewma.exp = ewma.exp,
ref.data.path,
recover.unit.error = recover.unit.error,
include.carryforward = include.carryforward,
sd.extreme = sd.extreme,
Expand All @@ -553,7 +566,10 @@ cleangrowth <- function(subjid,
who.ht.vel = who.ht.vel,
lt3.exclude.mode = lt3.exclude.mode,
error.load.threshold = error.load.threshold,
error.load.mincount = error.load.mincount
error.load.mincount = error.load.mincount,
reinclude.ht.cf = reinclude.ht.cf,
debug = debug,
debug_filename = debug_filename
)
stopCluster(cl)
}
Expand Down Expand Up @@ -623,6 +639,7 @@ cleangrowth <- function(subjid,
.(newbatch),
cleanadult,
.parallel = parallel,
.progress = "text",
.paropts = list(.packages = "data.table"),
weight_cap = weight_cap
)
Expand Down
Loading