diff --git a/DESCRIPTION b/DESCRIPTION index 17d09fd88..637645eb9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.23.0 +Version: 0.23.0.1 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", @@ -157,6 +157,7 @@ Suggests: survey, survival, svglite, + systemfit, systemfonts, tibble, tictoc, @@ -262,6 +263,7 @@ Collate: 'methods_stats.R' 'methods_survey.R' 'methods_survival.R' + 'methods_systemfit.R' 'methods_tidymodels.R' 'methods_tobit1.R' 'modelarchive.R' diff --git a/NAMESPACE b/NAMESPACE index 65b52754f..34459db6d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,6 +28,7 @@ S3method(get_coef,polr) S3method(get_coef,scam) S3method(get_coef,selection) S3method(get_coef,svyolr) +S3method(get_coef,systemfit) S3method(get_coef,workflow) S3method(get_group_names,bracl) S3method(get_group_names,brmsfit) @@ -109,6 +110,7 @@ S3method(get_vcov,orm) S3method(get_vcov,pstpm2) S3method(get_vcov,scam) S3method(get_vcov,stpm2) +S3method(get_vcov,systemfit) S3method(get_vcov,workflow) S3method(glance,comparisons) S3method(glance,hypotheses) diff --git a/NEWS.md b/NEWS.md index dcc096708..d13deb546 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # News +## Development + +Bugs: + +* `systemfit` models returned no standard errors when the same variables entered in different parts of the model. Thanks to @mronkko for report #1233. + ## 0.23.0 Breaking change: diff --git a/R/methods_systemfit.R b/R/methods_systemfit.R new file mode 100644 index 000000000..96c6c0bea --- /dev/null +++ b/R/methods_systemfit.R @@ -0,0 +1,13 @@ +#' @rdname get_coef +#' @export +get_coef.systemfit <- function(model, ...) { + out <- stats::coef(model) + return(out) +} + +#' @rdname get_vcov +#' @export +get_vcov.systemfit <- function(model, ...) { + out <- stats::vcov(model) + return(out) +} diff --git a/inst/tinytest/test-pkg-survfit.R b/inst/tinytest/test-pkg-survfit.R new file mode 100644 index 000000000..2dc952738 --- /dev/null +++ b/inst/tinytest/test-pkg-survfit.R @@ -0,0 +1,22 @@ +source("helpers.R") +using("marginaleffects") +requiet("systemfit") +requiet("MASS") + +# issue #1233: duplicated coefficient names +set.seed(12345) +N <- 100 +C <- matrix(c(1, .3, .3, + .3, 1, .3, + .3, .3, 1), 3, 3) +colnames(C) <- rownames(C) <- c("x1", "x2", "x3") +data <- as.data.frame(mvrnorm(N, rep(0, 3), C)) +sys <- with(data, { + y1 <- 2 * x1 + 3 * x2 + x3 + 10 * rnorm(N) + m1 <- lm(y1 ~ x1 + x2 + x3) + y2 <- x1 + 3 * x2 + 2 * x3 + 10 * rnorm(N) + m2 <- lm(y2 ~ x1 + x2 + x3) + systemfit(list(formula(m1), formula(m2)), data = data) +}) +h <- hypotheses(sys) +expect_false(anyNA(h$std.error)) diff --git a/man/get_coef.Rd b/man/get_coef.Rd index 3ac9bda4f..e9b728af3 100644 --- a/man/get_coef.Rd +++ b/man/get_coef.Rd @@ -6,7 +6,7 @@ % R/methods_glmtoolbox.R, R/methods_lme4.R, R/methods_mclogit.R, % R/methods_mgcv.R, R/methods_mlm.R, R/methods_sampleSelection.R, % R/methods_scam.R, R/methods_stats.R, R/methods_survey.R, -% R/methods_tidymodels.R +% R/methods_systemfit.R, R/methods_tidymodels.R \name{get_coef} \alias{get_coef} \alias{get_coef.default} @@ -32,6 +32,7 @@ \alias{get_coef.scam} \alias{get_coef.nls} \alias{get_coef.svyolr} +\alias{get_coef.systemfit} \alias{get_coef.workflow} \title{Get a named vector of coefficients from a model object (internal function)} \usage{ @@ -83,6 +84,8 @@ get_coef(model, ...) \method{get_coef}{svyolr}(model, ...) +\method{get_coef}{systemfit}(model, ...) + \method{get_coef}{workflow}(model, ...) } \arguments{ diff --git a/man/get_vcov.Rd b/man/get_vcov.Rd index e944e9360..d50762d16 100644 --- a/man/get_vcov.Rd +++ b/man/get_vcov.Rd @@ -3,7 +3,7 @@ % R/methods_afex.R, R/methods_aod.R, R/methods_biglm.R, R/methods_brms.R, % R/methods_dbarts.R, R/methods_gamlss.R, R/methods_glmmTMB.R, % R/methods_mhurdle.R, R/methods_mlr3.R, R/methods_rms.R, R/methods_rstpm2.R, -% R/methods_scam.R, R/methods_tidymodels.R +% R/methods_scam.R, R/methods_systemfit.R, R/methods_tidymodels.R \name{get_vcov} \alias{get_vcov} \alias{get_vcov.default} @@ -23,6 +23,7 @@ \alias{get_vcov.gsm} \alias{get_vcov.aft} \alias{get_vcov.scam} +\alias{get_vcov.systemfit} \alias{get_vcov.model_fit} \alias{get_vcov.workflow} \title{Get a named variance-covariance matrix from a model object (internal function)} @@ -63,6 +64,8 @@ get_vcov(model, ...) \method{get_vcov}{scam}(model, vcov = NULL, ...) +\method{get_vcov}{systemfit}(model, ...) + \method{get_vcov}{model_fit}(model, type = NULL, ...) \method{get_vcov}{workflow}(model, type = NULL, ...)