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

Request for broom to work with scam package #186

Closed
SimonCoulombe opened this issue Jan 18, 2017 · 4 comments
Closed

Request for broom to work with scam package #186

SimonCoulombe opened this issue Jan 18, 2017 · 4 comments

Comments

@SimonCoulombe
Copy link

SimonCoulombe commented Jan 18, 2017

The scam package is an extension of the mgcv package, which adds the ability to constrain the shape of the splines (for example, they can be forced to be monotonously increasing).

@bkmontgom
Copy link

bkmontgom commented Feb 11, 2017

Me too. This would be a great addition. The structure of the scam model is similar to gam.

@IndrajeetPatil
Copy link
Contributor

IndrajeetPatil commented Jun 9, 2020

@simonpcouch This is currently not supported in broom, but since the class of the object is glm/lm, those tidiers are called.

library(scam)
#> Loading required package: mgcv
#> Loading required package: nlme
#> This is mgcv 1.8-31. For overview type 'help("mgcv-package")'.
#> This is scam 1.2-5.
set.seed(0)

n <- 200
x1 <- runif(n) * 6 - 3
f1 <- 3 * exp(-x1^2) # unconstrained term
f1 <- (f1 - min(f1)) / (max(f1) - min(f1)) # function scaled to have range [0,1]
x2 <- runif(n) * 4 - 1
f2 <- exp(4 * x2) / (1 + exp(4 * x2)) # monotone increasing smooth
f2 <- (f2 - min(f2)) / (max(f2) - min(f2)) # function scaled to have range [0,1]
f <- f1 + f2
y <- f + rnorm(n) * 0.1
dat <- data.frame(x1 = x1, x2 = x2, y = y)

## fit model, results, and plot...
b <- scam(y ~ s(x1, k = 15, bs = "cr", m = 2) + s(x2, k = 25, bs = "mpi", m = 2),
  family = gaussian(link = "identity"), data = dat, not.exp = FALSE
)

class(b)
#> [1] "scam" "glm"  "lm"

broom::tidy(b)
#> Error: Join columns must be present in data.
#> x Problem with `term` and `estimate`.

Created on 2020-06-09 by the reprex package (v0.3.0)

@simonpcouch
Copy link
Collaborator

simonpcouch commented Jun 9, 2020

Thanks for noting this, @IndrajeetPatil! I'm currently assigning the default tidier methods to scam objects so that they will error more informatively.

We’ve decided that, in general, we won’t be adding new tidier methods to broom after the upcoming 0.7.0 release in favor of asking the model-owning package (in this case, scam) to write and export the tidiers. We’ve written some documentation on how to make this happen and have also provided a much lighter-weight dependency than broom, r-lib/generics, to supply the tidier generics. We'll keep that tidymodels.org article linked above up to date with current resources to help in the process. If the scam package ends up being able to supply those methods, let us know and we'll deprecate these new ones so there aren't namespace conflicts.🙂

@github-actions
Copy link

github-actions bot commented Mar 7, 2021

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants