Skip to content

smooth_estimates() sometimes disagrees with predict() when discrete = TRUE #387

Description

@dlmdata

Hi Gavin!

I have noticed that in some cases smooth_estimates() can disagree with predict(m, type = "terms") when fitting models with bam using discrete = TRUE.

library("tidyverse")
library("mgcv")
library("gratia")

m1 <- bam(price ~ s(color, clarity, bs = "re"), data = diamonds, discrete = FALSE)
bind_cols(smooth_estimates(m1), predict(m1, smooth_estimates(m1), type = "terms"))

m2 <- bam(price ~ s(color, clarity, bs = "re"), data = diamonds, discrete = TRUE)
bind_cols(smooth_estimates(m2), predict(m2, smooth_estimates(m2), type = "terms"))

In the first model, .estimate is identical to s(color,clarity), but in the second model it is not.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions