Skip to content

Commit

Permalink
finish up?
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jul 16, 2023
1 parent 897f6d2 commit 2c4f5e4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/get_jacobian.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ get_jacobian <- function(func, x, numderiv) {
}


get_jacobian_fdforward <- function(func, x, eps) {
get_jacobian_fdforward <- function(func, x, eps = NULL) {
# old version. probably not optimal. Keep for posterity.
# h <- max(1e-8, 1e-4 * min(abs(x), na.rm = TRUE))
baseline <- func(x)
Expand All @@ -42,7 +42,7 @@ get_jacobian_fdforward <- function(func, x, eps) {
}


get_jacobian_fdcenter <- function(func, x, eps) {
get_jacobian_fdcenter <- function(func, x, eps = NULL) {
baseline <- func(x)
df <- matrix(NA_real_, length(baseline), length(x))
for (i in seq_along(x)) {
Expand Down
2 changes: 1 addition & 1 deletion R/sanitize_numderiv.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sanitize_numderiv <- function(numderiv) {

if (length(numderiv) > 1) {
if (numderiv[[1]] %in% c("fdforward", "fdcenter")) {
if (any(names(numderiv)[2:length(numderiv)] %in% "eps")) {
if (any(!names(numderiv)[2:length(numderiv)] %in% "eps")) {
stop("The only valid argument for this numeric differentiation method is `eps`.")
}
} else if (numderiv[[1]] == "richardson") {
Expand Down
1 change: 1 addition & 0 deletions R/slopes.R
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ avg_slopes <- function(model,
p_adjust = p_adjust,
df = df,
eps = eps,
numderiv = numderiv,
...)

return(out)
Expand Down
2 changes: 0 additions & 2 deletions inst/tinytest/test-elasticity.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ source("helpers.R")
using("marginaleffects")
set.seed(1024)

options(marginaleffects_numDeriv = "richardson")

tol <- tolse <- 1e-4

results <- readRDS(testing_path("stata/stata.rds"))
Expand Down

0 comments on commit 2c4f5e4

Please sign in to comment.