From 6ee48ab58b04474bf37e2c89839b73ea510af0d3 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 22 Jun 2023 22:30:48 -0400 Subject: [PATCH 1/9] Spelling updates --- R/nlmixr2output.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/nlmixr2output.R b/R/nlmixr2output.R index a7f9ef629..4f14cd0ee 100644 --- a/R/nlmixr2output.R +++ b/R/nlmixr2output.R @@ -91,8 +91,8 @@ #' @param .env Environment where the indicators of `.sdOnly`, `.cvOnly` are stored so the column name can be changed to match the data #' @param .ome Omega fixed vector #' @param .muRefCurEval The current mu ref evaluation. This determines if the ETA is logit normal and %CV should be calculated. -#' @param .sigdig is the number of significant digits used in the evaulation -#' @return Data frame row with ch= the charaacter representation and v is the vector representation of the CV or sd +#' @param .sigdig is the number of significant digits used in the evaluation +#' @return Data frame row with ch= the character representation and v is the vector representation of the CV or sd #' @author Matthew L. Fidler #' @noRd .updateParFixedGetEtaRow <- function(.eta, .env, .ome, .omegaFix, .muRefCurEval, .sigdig) { @@ -120,7 +120,7 @@ } } -#' This will add the between subject varaibility to the mu-referenced theta. It also expands the table to include non-mu referenced ETAs +#' This will add the between subject variability to the mu-referenced theta. It also expands the table to include non-mu referenced ETAs #' #' #' @param .ret The focei return environment From 236306a4b80427df8a7e54c7ee112c3366689225 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 22 Jun 2023 22:31:14 -0400 Subject: [PATCH 2/9] Add failing test --- tests/testthat/test-nlmixr2output.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/testthat/test-nlmixr2output.R diff --git a/tests/testthat/test-nlmixr2output.R b/tests/testthat/test-nlmixr2output.R new file mode 100644 index 000000000..6336da68e --- /dev/null +++ b/tests/testthat/test-nlmixr2output.R @@ -0,0 +1,13 @@ +test_that(".updateParFixedGetEtaRow returns correct values", { + expect_equal( + .updateParFixedGetEtaRow( + .eta = "iivemax", + .env = new.env(), + .ome = matrix(25, nrow = 1, dimnames = list("iivemax", "iivemax")), + .omegaFix = c(iivemax = FALSE), + .muRefCurEval = data.frame(parameter = "iivemax", curEval = "", low = NA_real_, hi = NA_real_), + .sigdig = 3L + ), + data.frame(.ch = "5.00", .v = 25) + ) +}) From dce87c2469b7869dc0dd0a6976534e3b5cd119d4 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 22 Jun 2023 22:32:56 -0400 Subject: [PATCH 3/9] Correct the names for the failing test --- tests/testthat/test-nlmixr2output.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-nlmixr2output.R b/tests/testthat/test-nlmixr2output.R index 6336da68e..977abf8b7 100644 --- a/tests/testthat/test-nlmixr2output.R +++ b/tests/testthat/test-nlmixr2output.R @@ -8,6 +8,6 @@ test_that(".updateParFixedGetEtaRow returns correct values", { .muRefCurEval = data.frame(parameter = "iivemax", curEval = "", low = NA_real_, hi = NA_real_), .sigdig = 3L ), - data.frame(.ch = "5.00", .v = 25) + data.frame(ch = "5.00", v = 25) ) }) From 9e5176ad67b09fc7e44a4e1a15ceef5bd53bcb96 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 22 Jun 2023 22:33:39 -0400 Subject: [PATCH 4/9] Ensure that standard deviation text value is returned --- R/nlmixr2output.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/nlmixr2output.R b/R/nlmixr2output.R index 4f14cd0ee..166c734f9 100644 --- a/R/nlmixr2output.R +++ b/R/nlmixr2output.R @@ -113,7 +113,7 @@ return(data.frame( ch = paste0( ifelse(.omegaFix[.eta], "fix(", ""), - formatC(signif(sqrt(.w), digits = .sigdig), + formatC(signif(sqrt(.v), digits = .sigdig), digits = .sigdig, format = "fg", flag = "#"), ifelse(.omegaFix[.eta], ")", "")), v = .v)) From 1993ccaea6d06c9d59bcddff2d596bb5ec83af71 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 22 Jun 2023 22:39:49 -0400 Subject: [PATCH 5/9] Complete testing of .updateParFixedGetEtaRow --- tests/testthat/test-nlmixr2output.R | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-nlmixr2output.R b/tests/testthat/test-nlmixr2output.R index 977abf8b7..05f97dc81 100644 --- a/tests/testthat/test-nlmixr2output.R +++ b/tests/testthat/test-nlmixr2output.R @@ -1,8 +1,9 @@ test_that(".updateParFixedGetEtaRow returns correct values", { + envPrep <- new.env() expect_equal( .updateParFixedGetEtaRow( .eta = "iivemax", - .env = new.env(), + .env = envPrep, .ome = matrix(25, nrow = 1, dimnames = list("iivemax", "iivemax")), .omegaFix = c(iivemax = FALSE), .muRefCurEval = data.frame(parameter = "iivemax", curEval = "", low = NA_real_, hi = NA_real_), @@ -10,4 +11,19 @@ test_that(".updateParFixedGetEtaRow returns correct values", { ), data.frame(ch = "5.00", v = 25) ) + expect_false(envPrep$.cvOnly) + + envPrep <- new.env() + expect_equal( + .updateParFixedGetEtaRow( + .eta = "iivemax", + .env = envPrep, + .ome = matrix(0.4, nrow = 1, dimnames = list("iivemax", "iivemax")), + .omegaFix = c(iivemax = FALSE), + .muRefCurEval = data.frame(parameter = "iivemax", curEval = "exp", low = NA_real_, hi = NA_real_), + .sigdig = 3L + ), + data.frame(ch = "70.1", v = sqrt(exp(0.4) - 1) * 100) + ) + expect_false(envPrep$.sdOnly) }) From 83a9f85107095de5277437828fe300cb8746a7f8 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 22 Jun 2023 22:46:27 -0400 Subject: [PATCH 6/9] Function simplification --- NEWS.md | 2 ++ R/nlmixr2output.R | 35 ++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/NEWS.md b/NEWS.md index 521d039f8..237b4143a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,8 @@ - Printing models with correlated omega values and omega values fixed to zero no longer fails (#359) +- Values in $parFixed for BSV without exponential transformation are now + correctly shown (#366) # nlmixr2est 2.1.6 diff --git a/R/nlmixr2output.R b/R/nlmixr2output.R index 166c734f9..0c9a84c3a 100644 --- a/R/nlmixr2output.R +++ b/R/nlmixr2output.R @@ -100,24 +100,29 @@ .w <- which(.muRefCurEval$parameter == .eta) if (.muRefCurEval$curEval[.w] == "exp") { assign(".sdOnly", FALSE, envir=.env) - return(data.frame( - ch = paste0( - ifelse(.omegaFix[.eta], "fix(", ""), - formatC(signif(sqrt(exp(.v) - 1) * 100, digits = .sigdig), - digits = .sigdig, format = "fg", flag = "#"), - ifelse(.omegaFix[.eta], ")", "") - ), - v = sqrt(exp(.v) - 1) * 100)) + valNumber <- sqrt(exp(.v) - 1) * 100 + valCharPrep <- valNumber } else { assign(".cvOnly", FALSE, envir=.env) - return(data.frame( - ch = paste0( - ifelse(.omegaFix[.eta], "fix(", ""), - formatC(signif(sqrt(.v), digits = .sigdig), - digits = .sigdig, format = "fg", flag = "#"), - ifelse(.omegaFix[.eta], ")", "")), - v = .v)) + valNumber <- .v + valCharPrep <- sqrt(.v) } + if (.omegaFix[.eta]) { + charPrefix <- "fix(" + charSuffix <- ")" + } else { + charPrefix <- "" + charSuffix <- "" + } + valChar <- + formatC( + signif(valCharPrep, digits = .sigdig), + digits = .sigdig, format = "fg", flag = "#" + ) + data.frame( + ch = paste0(charPrefix, valChar, charSuffix), + v = valNumber + ) } #' This will add the between subject variability to the mu-referenced theta. It also expands the table to include non-mu referenced ETAs From f215a63ed0f0491286e0be9663e9699dd28f1c78 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Thu, 22 Jun 2023 22:55:27 -0400 Subject: [PATCH 7/9] Correct spelling --- R/nlmixr2output.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/nlmixr2output.R b/R/nlmixr2output.R index 0c9a84c3a..1cc899e48 100644 --- a/R/nlmixr2output.R +++ b/R/nlmixr2output.R @@ -39,7 +39,7 @@ #' This applies the manually specified back-transformations #' #' @param .ret focei environment -#' @return Nothing, called for side effecs +#' @return Nothing, called for side effects #' @author Matthew L. Fidler #' @noRd .updateParFixedApplyManualBacktransformations <- function(.ret, .ui) { From 292b22ddec15cf0271b444d7b8bbcbf57a189059 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Fri, 23 Jun 2023 08:38:05 -0500 Subject: [PATCH 8/9] Fix style and add Bill's name --- R/nlmixr2output.R | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/R/nlmixr2output.R b/R/nlmixr2output.R index 1cc899e48..925bcdec2 100644 --- a/R/nlmixr2output.R +++ b/R/nlmixr2output.R @@ -93,35 +93,35 @@ #' @param .muRefCurEval The current mu ref evaluation. This determines if the ETA is logit normal and %CV should be calculated. #' @param .sigdig is the number of significant digits used in the evaluation #' @return Data frame row with ch= the character representation and v is the vector representation of the CV or sd -#' @author Matthew L. Fidler +#' @author Matthew L. Fidler and Bill Denney #' @noRd .updateParFixedGetEtaRow <- function(.eta, .env, .ome, .omegaFix, .muRefCurEval, .sigdig) { .v <- .ome[.eta, .eta] .w <- which(.muRefCurEval$parameter == .eta) if (.muRefCurEval$curEval[.w] == "exp") { assign(".sdOnly", FALSE, envir=.env) - valNumber <- sqrt(exp(.v) - 1) * 100 - valCharPrep <- valNumber + .valNumber <- sqrt(exp(.v) - 1) * 100 + .valCharPrep <- .valNumber } else { assign(".cvOnly", FALSE, envir=.env) - valNumber <- .v - valCharPrep <- sqrt(.v) + .valNumber <- .v + .valCharPrep <- sqrt(.v) } if (.omegaFix[.eta]) { - charPrefix <- "fix(" - charSuffix <- ")" + .charPrefix <- "fix(" + .charSuffix <- ")" } else { - charPrefix <- "" - charSuffix <- "" + .charPrefix <- "" + .charSuffix <- "" } - valChar <- + .valChar <- formatC( - signif(valCharPrep, digits = .sigdig), + signif(.valCharPrep, digits = .sigdig), digits = .sigdig, format = "fg", flag = "#" ) data.frame( - ch = paste0(charPrefix, valChar, charSuffix), - v = valNumber + ch = paste0(.charPrefix, .valChar, .charSuffix), + v = .valNumber ) } From 3dd6939ca5a4d7738c88ca45145f6b07ad43a4db Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Fri, 23 Jun 2023 08:39:45 -0500 Subject: [PATCH 9/9] Some stylistic fix for news --- NEWS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 237b4143a..c796d8181 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,7 +8,8 @@ - Printing models with correlated omega values and omega values fixed to zero no longer fails (#359) -- Values in $parFixed for BSV without exponential transformation are now + +- Values in `$parFixed` for BSV without exponential transformation are now correctly shown (#366) # nlmixr2est 2.1.6 @@ -27,7 +28,7 @@ - `augPred()` now consistently uses the simulation model (instead of the inner model used for `CWRES` calculation). - + ## Other changes - Dropped dependence on orphaned package `ucminf`