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

Predicted Values for glm #282

Closed
tegedik opened this issue Aug 31, 2022 · 2 comments
Closed

Predicted Values for glm #282

tegedik opened this issue Aug 31, 2022 · 2 comments
Labels
bug 🐛 Something isn't working

Comments

@tegedik
Copy link

tegedik commented Aug 31, 2022

I saw this issue and encountered an error for glm using easystats::model_dashboard.

df <- carData::Mroz
glmfit <- glm(lfp ~ k618 + wc + hc + inc, df, family=binomial(link="logit"))
easystats::model_dashboard(glmfit)

Now, this model returns an error for plot under predicted values tab:

Error in if (ncol(vcovmat) < ncol(mm)) {: argument is of length zero
Error in lapply(text_modelbased, function(i) {: object 'text_modelbased' not found
Error in is.ggplot(x): object 'all_plots' not found

And for tabular summary:

Error in eval(expr, envir, enclos): object 'text_modelbased' not found

Screen Shot 2022-08-31 at 10 25 26 AM

I realized that this has to do with the outcome (lfp) being a factor. When I convert it into numeric:

df$lfp <- as.numeric(df$lfp) -1

The problem disappears:

Screen Shot 2022-08-31 at 10 31 31 AM

I don't think this is a serious issue but I want to let you know.

@strengejacke
Copy link
Member

Minimal reprex:

library(insight)
library(modelbased)

df <- carData::Mroz
model <- glm(lfp ~ k618 + wc + hc + inc, df, family = binomial(link = "logit"))

grid <- insight::get_datagrid(model, at = "k618", range = "grid", preserve_range = FALSE, verbose = FALSE)
modelbased::estimate_expectation(model, data = grid, verbose = FALSE)
#> Warning in `[<-.factor`(`*tmp*`, ri, value = c(0, 0, 0, 0, 0, 0, 0, 0, 0, :
#> invalid factor level, NA generated
#> Error in if (ncol(vcovmat) < ncol(mm)) {: argument is of length zero

Created on 2022-08-31 with reprex v2.0.2

@strengejacke
Copy link
Member

Thanks, should be fixed once we merge easystats/insight#627 - you need to update easystats, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants