-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add glm engine for linear_reg()
#624
Conversation
We can pass in expressions to the library(parsnip)
spec1 <-
linear_reg() %>%
set_engine("glm", family = statmod::tweedie)
spec1 %>% translate()
#> Linear Regression Model Specification (regression)
#>
#> Engine-Specific Arguments:
#> family = statmod::tweedie
#>
#> Computational engine: glm
#>
#> Model fit template:
#> stats::glm(formula = missing_arg(), data = missing_arg(), weights = missing_arg(),
#> family = statmod::tweedie)
spec1 %>% fit(breaks ~ ., data = warpbreaks)
#> parsnip model object
#>
#>
#> Call: stats::glm(formula = breaks ~ ., family = ~statmod::tweedie,
#> data = data)
#>
#> Coefficients:
#> (Intercept) woolB tensionM tensionH
#> 39.278 -5.778 -10.000 -14.722
#>
#> Degrees of Freedom: 53 Total (i.e. Null); 50 Residual
#> Null Deviance: 9233
#> Residual Deviance: 6748 AIC: NA
spec2 <-
linear_reg() %>%
set_engine("glm", family = stats::poisson(link = "sqrt"))
spec2 %>% translate()
#> Linear Regression Model Specification (regression)
#>
#> Engine-Specific Arguments:
#> family = stats::poisson(link = "sqrt")
#>
#> Computational engine: glm
#>
#> Model fit template:
#> stats::glm(formula = missing_arg(), data = missing_arg(), weights = missing_arg(),
#> family = stats::poisson(link = "sqrt"))
spec2 %>% fit(breaks ~ ., data = warpbreaks)
#> parsnip model object
#>
#>
#> Call: stats::glm(formula = breaks ~ ., family = ~stats::poisson(link = "sqrt"),
#> data = data)
#>
#> Coefficients:
#> (Intercept) woolB tensionM tensionH
#> 6.2620 -0.5059 -0.8545 -1.3644
#>
#> Degrees of Freedom: 53 Total (i.e. Null); 50 Residual
#> Null Deviance: 297.4
#> Residual Deviance: 212.7 AIC: 495.3 Created on 2021-12-13 by the reprex package (v2.0.1) |
I added a tiny |
This pull request 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. |
Closes #623
Created on 2021-12-13 by the reprex package (v2.0.1)