-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
glmtoolbox::glmgee()
(#1207)
* support glmtoolbox::glmgee() * fixup test * test fixup * supported models
- Loading branch information
1 parent
25b3b4f
commit eb9a3c4
Showing
11 changed files
with
84 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#' @include get_coef.R | ||
#' @rdname get_coef | ||
#' @export | ||
get_coef.glmgee <- function(model, ...) { | ||
b <- model$coefficients | ||
b <- setNames(as.vector(b), row.names(b)) | ||
return(b) | ||
} | ||
|
||
#' @include set_coef.R | ||
#' @rdname set_coef | ||
#' @export | ||
set_coef.glmgee <- function(model, coefs, ...) { | ||
out <- model | ||
idx <- match(row.names(out$coefficients), names(coefs)) | ||
out$coefficients[, 1] <- coefs[idx] | ||
return(out) | ||
} | ||
|
||
#' @include get_predict.R | ||
#' @rdname get_predict | ||
#' @export | ||
get_predict.glmgee <- function(model, newdata, ...) { | ||
Yhat <- predict(model, newdata = newdata, type = "response") | ||
out <- data.frame( | ||
rowid = seq_len(nrow(Yhat)), | ||
estimate = as.vector(Yhat)) | ||
return(out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
source("helpers.R") | ||
using("marginaleffects") | ||
requiet("glmtoolbox") | ||
|
||
data(spruces) | ||
mod <- size ~ poly(days,4) + treat | ||
fit <- glmgee(mod, id=tree, family=Gamma(log), corstr="AR-M-dependent(1)", data=spruces) | ||
|
||
s <- avg_slopes(fit) | ||
expect_inherits(s, "slopes") | ||
p <- avg_predictions(fit, by = "treat") | ||
expect_inherits(p, "predictions") | ||
k <- avg_comparisons(fit) | ||
expect_inherits(k, "comparisons") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.