Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed printing error for formula used with glm.nb #20

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion R/description-glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ descript.GLMModelResult <- function(x, ...){
} else {
etype <- "g-computation-type"
}

if(is.character(x$settings$g_family)){
if(x$settings$g_family == "nb"){
family <- "negative binomial with unknown dispersion"
Expand All @@ -20,7 +21,16 @@ descript.GLMModelResult <- function(x, ...){

if(!is.null(x$data$formula)){

form <- x$mod$formula
if(is.character(x$settings$g_family)){
if(x$settings$g_family == "nb"){
form <- x$data$formula
} else {
form <- x$mod$formula
}
} else {
form <- x$mod$formula
}

output <- c(
output,
sprintf("Treatment group mean estimates from a GLM working model of family %s and link %s using formula: \n",
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ test_that("GLM full function -- NEGATIVE binomial, permuted block", {
covariate_to_include_strata=TRUE)
expect_equal(class(non), "GLMModelResult")

non

# Test with formula
non <- robincar_glm2(
df=DATA2,
response_col="y",
treat_col="A",
car_strata_cols=c("z1"),
formula="y ~ A + z1",
car_scheme="permuted-block",
g_family="nb",
g_accuracy=7)

non

})

test_that("GLM Settings", {
Expand Down
Loading