Skip to content

Commit

Permalink
fixed #60
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Feb 14, 2025
1 parent 3643e8f commit fd893f7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SimDesign
Title: Structure for Organizing Monte Carlo Simulation Designs
Version: 2.18.3
Version: 2.18.4
Authors@R: c(person("Phil", "Chalmers", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID="0000-0001-5332-2810")),
person("Matthew", "Sigal", role = c("ctb")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# NEWS file for SimDesign

## Changes in SimDesign 2.19

- Multiple parameter `bias()` returned incorrect behavior/errors
for `relative` and `abs_relative` types (see #60)

## Changes in SimDesign 2.18

- Objects built by `createDesign()` gain `[]` and `rbind()` S3 functions for
Expand Down
6 changes: 4 additions & 2 deletions R/summary_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
#' # different parameter associated with each column
#' mat <- cbind(M1=rnorm(1000, 2, sd = 0.25), M2 = rnorm(1000, 3, sd = .25))
#' bias(mat, parameter = c(2,3))
#' bias(mat, parameter = c(2,3), type='relative')
#' bias(mat, parameter = c(2,3), type='standardized')
#'
#' # same, but with data.frame
#' df <- data.frame(M1=rnorm(100, 2, sd = 0.5), M2 = rnorm(100, 2, sd = 1))
Expand Down Expand Up @@ -128,8 +130,8 @@ bias <- function(estimate, parameter = NULL, type = 'bias', abs = FALSE,
if(!equal_len)
stopifnot(ncol(estimate) == length(parameter))
diff <- t(t(estimate) - parameter)
ret <- if(type == 'relative') colMeans(diff / parameter)
else if(type == 'abs_relative') colMeans(diff / abs(parameter))
ret <- if(type == 'relative') rowMeans(t(diff) / parameter)
else if(type == 'abs_relative') rowMeans(t(diff) / abs(parameter))
else if(type == 'standardized') colMeans(diff) / colSDs(estimate)
else colMeans(diff)
if(abs) ret <- abs(ret)
Expand Down
1 change: 1 addition & 0 deletions SimDesign.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: fe769c1e-d77f-4cb0-8cc9-a5d4a1fc8243

RestoreWorkspace: No
SaveWorkspace: No
Expand Down
8 changes: 4 additions & 4 deletions man/SimFunctions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/bias.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fd893f7

Please sign in to comment.