-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skpr v1.2.1: Rename and export
normalize_design()
- Loading branch information
1 parent
2e111f3
commit 817bf07
Showing
12 changed files
with
119 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: skpr | ||
Title: Design of Experiments Suite: Generate and Evaluate Optimal Designs | ||
Date: 2023-01-20 | ||
Version: 1.2.0 | ||
Version: 1.2.1 | ||
Authors@R: c(person("Tyler", "Morgan-Wall", email = "[email protected]", role = c("aut", "cre")), | ||
person("George", "Khoury", email = "[email protected]", role = c("aut"))) | ||
Description: Generates and evaluates D, I, A, Alias, E, T, and G optimal designs. Supports generation and evaluation of blocked and split/split-split/.../N-split plot designs. Includes parametric and Monte Carlo power evaluation functions, and supports calculating power for censored responses. Provides a framework to evaluate power using functions provided in other packages or written by the user. Includes a Shiny graphical user interface that displays the underlying code used to create and evaluate the design to improve ease-of-use and make analyses more reproducible. For details, see Morgan-Wall et al. (2021) <doi:10.18637/jss.v099.i01>. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#'@title Normalize Design | ||
#' | ||
#'@description Normalizes the numeric columns in the design to -1 to 1. This is important to do if your model has interaction or polynomial terms, | ||
#'as these terms can introduce multi-collinearity and standardizing the numeric columns can reduce this problem. | ||
#' | ||
#'@param design The design matrix. | ||
#'@param augmented Default `NULL`. If augmenting an existing design, this should be the pre-existing design. The column types must match design | ||
#' | ||
#'@return Normalized design matrix | ||
#'@export | ||
#'@examples | ||
#'#Normalize a design | ||
#'\dontrun{ | ||
#'cand_set = expand.grid(temp = c(100,300,500), | ||
#' altitude = c(10000,20000), | ||
#' offset = seq(-10,-5,by=1), | ||
#' type = c("A","B", "C")) | ||
#'design = gen_design(cand_set, ~., 24) | ||
#'#Un-normalized design | ||
#'design | ||
#' | ||
#'#Normalized design | ||
#'normalize_design(design) | ||
#'} | ||
normalize_design = function(design, augmented = NULL) { | ||
if(!is.null(augmented)) { | ||
all_equal_classes = all(identical(lapply(design,class), unlist(lapply(augmented,class)))) | ||
if(!all_equal_classes) { | ||
stop("Design to be augmented and new design must have identical column classes") | ||
} | ||
for (column in 1:ncol(design)) { | ||
if (is.numeric(design[, column])) { | ||
midvalue = mean(c(max(c(design[, column],augmented[,column])), min(c(design[, column],augmented[,column])))) | ||
design[, column] = (design[, column] - midvalue) / (max(c(design[, column],augmented[,column])) - midvalue) | ||
} | ||
} | ||
} else { | ||
for (column in 1:ncol(design)) { | ||
if (is.numeric(design[, column])) { | ||
midvalue = mean(c(max(design[, column]), min(design[, column]))) | ||
design[, column] = (design[, column] - midvalue) / (max(design[, column]) - midvalue) | ||
} | ||
} | ||
} | ||
return(design) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
#'@title Normalize Run Matrix | ||
#'@title Normalize Design | ||
#' | ||
#'@description Normalizes the numeric columns in the runmatrix | ||
#'@param RunMatrix The run matrix | ||
#'@description Normalizes the numeric columns in the design to -1 to 1. This is important to do if your model has interaction or polynomial terms, | ||
#'as these terms can introduce multi-collinearity and standardizing the numeric columns can reduce this problem. | ||
#' | ||
#'@param design The design matrix. | ||
#'@param augmented Default `NULL`. If | ||
#'@return Normalized run matrix | ||
#'@keywords internal | ||
normalize_numeric_runmatrix = function(RunMatrix, augmented = NULL) { | ||
normalize_design = function(design, augmented = NULL) { | ||
if(!is.null(augmented)) { | ||
for (column in 1:ncol(RunMatrix)) { | ||
if (is.numeric(RunMatrix[, column])) { | ||
midvalue = mean(c(max(c(RunMatrix[, column],augmented[,column])), min(c(RunMatrix[, column],augmented[,column])))) | ||
RunMatrix[, column] = (RunMatrix[, column] - midvalue) / (max(c(RunMatrix[, column],augmented[,column])) - midvalue) | ||
for (column in 1:ncol(design)) { | ||
if (is.numeric(design[, column])) { | ||
midvalue = mean(c(max(c(design[, column],augmented[,column])), min(c(design[, column],augmented[,column])))) | ||
design[, column] = (design[, column] - midvalue) / (max(c(design[, column],augmented[,column])) - midvalue) | ||
} | ||
} | ||
} else { | ||
for (column in 1:ncol(RunMatrix)) { | ||
if (is.numeric(RunMatrix[, column])) { | ||
midvalue = mean(c(max(RunMatrix[, column]), min(RunMatrix[, column]))) | ||
RunMatrix[, column] = (RunMatrix[, column] - midvalue) / (max(RunMatrix[, column]) - midvalue) | ||
for (column in 1:ncol(design)) { | ||
if (is.numeric(design[, column])) { | ||
midvalue = mean(c(max(design[, column]), min(design[, column]))) | ||
design[, column] = (design[, column] - midvalue) / (max(design[, column]) - midvalue) | ||
} | ||
} | ||
} | ||
return(RunMatrix) | ||
return(design) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.