Skip to content

Commit

Permalink
cran fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed May 12, 2023
1 parent 0dacc3a commit d274974
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ S3method(get_group_names,mblogit)
S3method(get_group_names,mlm)
S3method(get_group_names,multinom)
S3method(get_group_names,polr)
S3method(get_model_matrix,default)
S3method(get_predict,MCMCglmm)
S3method(get_predict,afex_aov)
S3method(get_predict,betareg)
Expand All @@ -48,6 +49,7 @@ S3method(get_predict,glimML)
S3method(get_predict,glm)
S3method(get_predict,glmmPQL)
S3method(get_predict,glmmTMB)
S3method(get_predict,hxlr)
S3method(get_predict,inferences_simulation)
S3method(get_predict,lm)
S3method(get_predict,lmerMod)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# marginaleffects 0.11.2

* `vcov()` and `coef()` methods for `marginaleffects` objects.
* Strings in `wts` are accepted with the `by` argument.
* `predictions()` and `avg_predictions()` no longer use an automatic backtransformation for GLM models unless `hypothesis` is `NULL`.
* `vcov()` can be used to retrieve a full variance-covariance matrix from objects produced by `comparisons()`, `slopes()`, `predictions()`, or `marginal_means()` objects.
Expand Down
11 changes: 6 additions & 5 deletions R/get_model_matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ get_model_matrix <- function(model, newdata) {

#' @rdname get_model_matrix
#' @keywords internal
get_model_matrix.default <- function(object, newdata) {
#' @export
get_model_matrix.default <- function(model, newdata) {

# faster
if (class(object)[1] %in% c("lm", "glm")) {
out <- hush(stats::model.matrix(object, data = newdata))
if (class(model)[1] %in% c("lm", "glm")) {
out <- hush(stats::model.matrix(model, data = newdata))
# more general
} else {
out <- hush(insight::get_modelmatrix(object, data = newdata))
out <- hush(insight::get_modelmatrix(model, data = newdata))
}

beta <- get_coef(object)
beta <- get_coef(model)
if (!isTRUE(nrow(out) == nrow(newdata)) || !isTRUE(ncol(out) == length(beta))) {
return(NULL)
} else {
Expand Down
10 changes: 5 additions & 5 deletions R/methods.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @noRd
#' @export
vcov.comparisons <- function(x) {
attr(x, "jacobian") %*% attr(x, "vcov") %*% t(attr(x, "jacobian"))
vcov.comparisons <- function(object, ...) {
attr(object, "jacobian") %*% attr(object, "vcov") %*% t(attr(object, "jacobian"))
}


Expand All @@ -22,9 +22,9 @@ vcov.marginalmeans <- vcov.comparisons

#' @export
#' @noRd
coef.comparisons <- function(x) {
if (!is.null(x$estimate)) {
return(x$estimate)
coef.comparisons <- function(object, ...) {
if (!is.null(object$estimate)) {
return(object$estimate)
} else {
stop("The input object does not contain an 'estimate' element.")
}
Expand Down
2 changes: 2 additions & 0 deletions R/methods_crch.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ set_coef.hxlr <- function(model, coefs, ...) {
}


#' @export
#' @noRd
get_predict.hxlr <- get_predict.crch
2 changes: 1 addition & 1 deletion man/get_model_matrix.Rd

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

0 comments on commit d274974

Please sign in to comment.