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

Plotting from estimate_means() with a poisson model fails #231

Open
pcinereus opened this issue Jul 20, 2023 · 3 comments
Open

Plotting from estimate_means() with a poisson model fails #231

pcinereus opened this issue Jul 20, 2023 · 3 comments

Comments

@pcinereus
Copy link

I suspect the reason is that .clean_names_frequentist() should also include names(means)[names(means) == "rate"] <- "Mean".

set.seed(123)
dat <- data.frame(y =  rpois(100, 3), F =  gl(4, 20, 100))
dat_glm <- glm(y ~ F, data =  dat, family = poisson(link =  "log"))
dat_glm |> estimate_means() |> plot()
@strengejacke
Copy link
Member

Can you create a reprex that includes the error message, or post the traceback?

@pcinereus
Copy link
Author

Thanks for looking into this...

18: stop("Discrete value supplied to continuous scale", call. = FALSE)
17: train_continuous(x, self$range)
16: self$range$train(x)
15: train(..., self = self)
14: scales[[i]][[method]](data[[var]][scale_index[[i]]])
13: FUN(X[[i]], ...)
12: lapply(seq_along(scales), function(i) {
        scales[[i]][[method]](data[[var]][scale_index[[i]]])
    })
11: FUN(X[[i]], ...)
10: lapply(vars, function(var) {
        pieces <- lapply(seq_along(scales), function(i) {
            scales[[i]][[method]](data[[var]][scale_index[[i]]])
        })
        pieces[lengths(pieces) == 0] <- NULL
        o <- order(unlist(scale_index))[seq_len(sum(lengths(pieces)))]
        vec_c(!!!pieces)[o]
    })
9: scale_apply(layer_data, y_vars, "train", SCALE_Y, y_scales)
8: train_scales(...)
7: self$facet$train_scales(self$panel_scales_x, self$panel_scales_y, 
       layout, data, self$facet_params)
6: train_position(..., self = self)
5: layout$train_position(data, scale_x(), scale_y())
4: ggplot_build.ggplot(x)
3: ggplot_build(x)
2: print.ggplot(x)
1: (function (x, ...) 
   UseMethod("print"))(x)

@strengejacke
Copy link
Member

strengejacke commented Oct 12, 2023

hm, I get a completely different error here:

library(modelbased)
set.seed(123)
dat <- data.frame(y =  rpois(100, 3), FC =  gl(4, 20, 100))
dat_glm <- glm(y ~ FC, data =  dat, family = poisson(link =  "log"))
dat_glm |> estimate_means() |> plot()
#> We selected `at = c("FC")`.
#> Error in `rlang::sym()`:
#> ! Can't convert a character vector to a symbol.
#> Backtrace:
#>      ▆
#>   1. ├─base::plot(estimate_means(dat_glm))
#>   2. └─modelbased:::plot.estimate_means(estimate_means(dat_glm))
#>   3.   ├─graphics::plot(layers)
#>   4.   ├─datawizard:::plot.visualisation_recipe(layers)
#>   5.   ├─base::NextMethod()
#>   6.   └─see:::plot.see_visualisation_recipe(layers)
#>   7.     └─see::geoms_from_list(x, ...)
#>   8.       └─see::geom_from_list(x[[i]])
#>   9.         ├─base::do.call(ggplot2::aes, lapply(x$aes, .str_to_sym))
#>  10.         └─base::lapply(x$aes, .str_to_sym)
#>  11.           └─see (local) FUN(X[[i]], ...)
#>  12.             └─rlang::sym(x)
#>  13.               └─rlang:::abort_coercion(x, "a symbol")
#>  14.                 └─rlang::abort(msg, call = call)

Created on 2023-10-12 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants