Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jul 16, 2023
1 parent 2c4f5e4 commit 08981ab
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 22 deletions.
4 changes: 2 additions & 2 deletions R/comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ comparisons <- function(model,
p_adjust = NULL,
df = Inf,
eps = NULL,
numderiv = "richardson",
numderiv = "fdforward",
...) {


Expand Down Expand Up @@ -646,7 +646,7 @@ avg_comparisons <- function(model,
p_adjust = NULL,
df = Inf,
eps = NULL,
numderiv = "richardson",
numderiv = "fdforward",
...) {

# order of the first few paragraphs is important
Expand Down
2 changes: 1 addition & 1 deletion R/hypotheses.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ hypotheses <- function(
joint = FALSE,
joint_test = "f",
FUN = NULL,
numderiv = "richardson",
numderiv = "fdforward",
...) {

if (!isFALSE(joint)) {
Expand Down
2 changes: 1 addition & 1 deletion R/marginal_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ marginal_means <- function(model,
df = Inf,
wts = "equal",
by = NULL,
numderiv = "richardson",
numderiv = "fdforward",
...) {


Expand Down
4 changes: 2 additions & 2 deletions R/predictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ predictions <- function(model,
equivalence = NULL,
p_adjust = NULL,
df = Inf,
numderiv = "richardson",
numderiv = "fdforward",
...) {


Expand Down Expand Up @@ -690,7 +690,7 @@ avg_predictions <- function(model,
equivalence = NULL,
p_adjust = NULL,
df = Inf,
numderiv = "richardson",
numderiv = "fdforward",
...) {

# order of the first few paragraphs is important
Expand Down
2 changes: 1 addition & 1 deletion R/sanitize_numderiv.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sanitize_numderiv <- function(numderiv) {
} else if (numderiv[[1]] == "richardson") {
valid <- c("eps", "d", "zero_tol", "size", "r", "v")
if (any(!names(numderiv)[2:length(numderiv)] %in% valid)) {
stop(sprintf("The only valid arguments for this numeric differentiation method are: %s", paste(valid, collapse = ", ")), call. = FALSE)
stop(sprintf("The only valid arguments for this numeric differentiation method are: %s. See `?numDeriv::grad` for details.", paste(valid, collapse = ", ")), call. = FALSE)
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions R/slopes.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
#' the maximum and minimum values of the variable with respect to which we
#' are taking the derivative. Changing `eps` may be necessary to avoid
#' numerical problems in certain models.
#' @param numderiv string or list of strings indicating the method to use to for the numeric differentiation used in to compute delta method standard errors.
#' + "fdforward": finite difference method with forward differences
#' + "fdcenter": finite difference method with central differences (default)
#' + "richardson": Richardson extrapolation method
#' + Extra arguments can be specified by passing a list to the `numDeriv` argument, with the name of the method first and named arguments following, ex: `numderiv=list("fdcenter", eps = 1e-5)`. When an unknown argument is used, `marginaleffects` prints the list of valid arguments for each method.
#' @param ... Additional arguments are passed to the `predict()` method
#' supplied by the modeling package.These arguments are particularly useful
#' for mixed-effects or bayesian models (see the online vignettes on the
Expand Down Expand Up @@ -211,7 +216,7 @@ slopes <- function(model,
p_adjust = NULL,
df = Inf,
eps = NULL,
numderiv = "richardson",
numderiv = "fdforward",
...) {


Expand Down Expand Up @@ -359,7 +364,7 @@ avg_slopes <- function(model,
p_adjust = NULL,
df = Inf,
eps = NULL,
numderiv = "richardson",
numderiv = "fdforward",
...) {

# order of the first few paragraphs is important
Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test-eps.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ expect_error(slopes(mod, eps = 0))
# Issue #840
df <- causaldata::restaurant_inspections
m1 <- glm(Weekend ~ Year, data = df, family = binomial)
z <- avg_slopes(m1, variables = "Year")$statistic
z <- avg_slopes(m1, variables = "Year", numderiv = "richardson")$statistic
expect_equivalent(z, -2.06834167185815, tol = 1e-5)


Expand Down
12 changes: 10 additions & 2 deletions man/comparisons.Rd

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

2 changes: 1 addition & 1 deletion man/deltamethod.Rd

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

10 changes: 9 additions & 1 deletion man/hypotheses.Rd

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

10 changes: 9 additions & 1 deletion man/marginal_means.Rd

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

2 changes: 1 addition & 1 deletion man/marginaleffects.Rd

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

10 changes: 9 additions & 1 deletion man/marginalmeans.Rd

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

2 changes: 1 addition & 1 deletion man/meffects.Rd

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

12 changes: 10 additions & 2 deletions man/predictions.Rd

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

12 changes: 10 additions & 2 deletions man/slopes.Rd

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

0 comments on commit 08981ab

Please sign in to comment.