Skip to content

Commit

Permalink
fixing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Jul 31, 2024
1 parent de02fee commit 82ed599
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 10 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Title: Marginal Effects for Model Objects
Description: An R port of the margins command from 'Stata', which can be used to
calculate marginal (or partial) effects from model objects.
License: MIT + file LICENSE
Version: 0.3.27
Version: 0.3.28
Authors@R: c(person("Thomas J.", "Leeper",
role = c("aut"),
comment = c(ORCID = "0000-0003-4097-6326")),
Expand Down Expand Up @@ -47,4 +47,5 @@ Enhances:
survey
ByteCompile: true
VignetteBuilder: knitr
RoxygenNote: 7.1.0
Encoding: UTF-8
RoxygenNote: 7.3.2
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ S3method(dydx,default)
S3method(dydx,factor)
S3method(dydx,logical)
S3method(dydx,ordered)
S3method(find_terms_in_model,default)
S3method(find_terms_in_model,lmerMod)
S3method(find_terms_in_model,merMod)
S3method(gradient_factory,default)
S3method(image,glm)
S3method(image,lm)
S3method(image,loess)
Expand Down Expand Up @@ -44,6 +48,12 @@ S3method(persp,loess)
S3method(plot,margins)
S3method(print,margins)
S3method(print,summary.margins)
S3method(reset_coefs,betareg)
S3method(reset_coefs,default)
S3method(reset_coefs,glm)
S3method(reset_coefs,lm)
S3method(reset_coefs,lmerMod)
S3method(reset_coefs,merMod)
S3method(summary,margins)
S3method(vcov,margins)
export(cplot)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## margins 0.3.28

* CRAN issues only (documentation, vignette support)

## margins 0.3.27

* version bump and resubmission to recover from `prediction` archive cascade
Expand Down
2 changes: 1 addition & 1 deletion R/cplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @param vcov A matrix containing the variance-covariance matrix for estimated model coefficients, or a function to perform the estimation with \code{model} as its only argument.
#' @param at Currently ignored.
#' @param n An integer specifying the number of points across \code{x} at which to calculate the predicted value or marginal effect, when \code{x} is numeric. Ignored otherwise.
#' @param xvals A numeric vector of values at which to calculate predictions or marginal effects, if \code{x} is numeric. By default, it is calculated from the data using \code{\link{seq_range}}. If \code{x} is a factor, this is ignored, as is \code{n}.
#' @param xvals A numeric vector of values at which to calculate predictions or marginal effects, if \code{x} is numeric. By default, it is calculated from the data using \code{\link[prediction]{seq_range}}. If \code{x} is a factor, this is ignored, as is \code{n}.
#' @param level The confidence level required (used to draw uncertainty bounds).
#' @param draw A logical (default \code{TRUE}), specifying whether to draw the plot. If \code{FALSE}, the data used in drawing are returned as a list of data.frames. This might be useful if you want to plot using an alternative plotting package (e.g., ggplot2). Also, if set to value \dQuote{add}, then the resulting data is added to the existing plot.
#' @param xlab A character string specifying the value of \code{xlab} in \code{\link[graphics]{plot}}.
Expand Down
3 changes: 3 additions & 0 deletions R/find_terms_in_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ find_terms_in_model <- function(model, variables = NULL) {
UseMethod("find_terms_in_model")
}

#' @export
find_terms_in_model.default <- function(model, variables = NULL) {

# identify classes of terms in `model`
Expand Down Expand Up @@ -71,6 +72,7 @@ find_terms_in_model.default <- function(model, variables = NULL) {
return(vars)
}

#' @export
find_terms_in_model.merMod <- function(model, variables = NULL) {

# require lme4 package in order to identify random effects terms
Expand All @@ -85,6 +87,7 @@ find_terms_in_model.merMod <- function(model, variables = NULL) {
varslist
}

#' @export
find_terms_in_model.lmerMod <- find_terms_in_model.merMod

# call gsub_bracket on all common formula operations
Expand Down
1 change: 1 addition & 0 deletions R/gradient_factory.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gradient_factory <- function(data, model, variables = NULL, type = "response", w
UseMethod("gradient_factory", model)
}

#' @export
gradient_factory.default <- function(data, model, variables = NULL, type = "response", weights = NULL, eps = 1e-7, varslist = NULL, ...) {

# identify classes of terms in `model`
Expand Down
6 changes: 6 additions & 0 deletions R/reset_coefs.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ reset_coefs <- function(model, coefs) {
UseMethod("reset_coefs")
}

#' @export
reset_coefs.default <- function(model, coefs) {
# in basic model classes coefficients are named vector
model[["coefficients"]][names(coefs)] <- coefs
model
}

#' @export
reset_coefs.lm <- function(model, coefs) {
# in lm coefficients are named vector
model[["coefficients"]][names(coefs)] <- coefs
model
}

#' @export
reset_coefs.glm <- function(model, coefs) {
# in glm coefficients are named vector
model[["coefficients"]][names(coefs)] <- coefs
Expand All @@ -25,12 +28,14 @@ reset_coefs.glm <- function(model, coefs) {
model
}

#' @export
reset_coefs.betareg <- function(model, coefs) {
# in betareg, coefficients are a two-element list. We want to substitute the first element!
model[["coefficients"]]$mean[names(coefs)] <- coefs
model
}

#' @export
reset_coefs.merMod <- function(model, coefs) {
# in 'merMod', predictions work the slot called "beta", which is unnamed
# `fixef(model)` returns the same thing named
Expand All @@ -41,4 +46,5 @@ reset_coefs.merMod <- function(model, coefs) {
model
}

#' @export
reset_coefs.lmerMod <- reset_coefs.merMod
14 changes: 7 additions & 7 deletions man/cplot.Rd

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

1 change: 1 addition & 0 deletions man/margins.Rd

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

0 comments on commit 82ed599

Please sign in to comment.