parameters icon indicating copy to clipboard operation
parameters copied to clipboard

Plotting model_parameters() output for gam objects

Open fabianstamp opened this issue 2 years ago • 0 comments

Calling plot(model_parameters(model)) for generalized additive models does not seem to be supported so far. Is there any way to make this work?

# example data
df <- tibble::tibble(
 name = rep(c("name1",
                      "name2",
                      "name3",
                      "name4",
                      "name5"),
                      times = 200),
 Y= sample(x = 1000000:10000000, size = 1000),
 A = rep(c(0, 1), times = 500),
 B = rep(c(1, 2, 3, 4, 5,6,7,8,9,10), times = 100),
 C = rep(c(10, 20, 30, 40, 50,60,70,80,90,100), times = 100))


# linear model
model_lm <- stats::lm(Y~ B + C, data = df)

# parameters
model_parameters(
  model_lm)

# plot parameters
plot(model_parameters(
  model_lm))

# gam
model_gam <- mgcv::gam(Y~ s(B) + s(C), data = df)

# parameters
model_parameters(
  model_gam)

# plot parameters (this does not work)
plot(model_parameters(
  model_gam))`

Running this will returns

Error in if (all(x$group == "TRUE")) { : missing value where TRUE/FALSE needed

fabianstamp avatar Jul 18 '23 13:07 fabianstamp