Reputation: 1897
Is there a way to get the standard errors and p-values for logistic regression in tidy models?
I can get the coefficients by the following code below.. but I want to calculate odds ratios for each feature and I will need the standard errors as well..
glm.fit <-
logistic_reg(mode = "classification") %>%
set_engine(engine = "glm") %>%
fit(Species ~ ., data = iris)
glm.fit$fit$coefficients
Usually you can do this by calling summary()
on a glm object, but I'm trying to use tidymodels here.
Upvotes: 3
Views: 1422
Reputation: 39605
You can try:
library(broom)
library(tidymodels)
glm.fit <-
logistic_reg(mode = "classification") %>%
set_engine(engine = "glm") %>%
fit(Species ~ ., data = iris)
tidy(glm.fit)
# A tibble: 5 x 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 16.9 457457. 0.0000370 1.00
2 Sepal.Length -11.8 130504. -0.0000901 1.00
3 Sepal.Width -7.84 59415. -0.000132 1.00
4 Petal.Length 20.1 107725. 0.000186 1.00
5 Petal.Width 21.6 154351. 0.000140 1.00
Upvotes: 7