Closed themichjam closed 2 years ago
You'll want to use extract_workflow()
on your final fit object, and then you can pipe to the gtsummary functions:
library(tidymodels)
data(two_class_dat)
my_split <- initial_split(two_class_dat)
glm_fit <-
workflow(Class ~ ., logistic_reg()) %>%
last_fit(my_split)
glm_fit
#> # Resampling results
#> # Manual resampling
#> # A tibble: 1 Γ 6
#> splits id .metrics .notes .predictions .workflow
#> <list> <chr> <list> <list> <list> <list>
#> 1 <split [593/198]> train/test split <tibble> <tibble> <tibble> <workflow>
extract_workflow(glm_fit) %>%
gtsummary::tbl_regression(exponentiate = TRUE) %>%
gtsummary::as_kable()
#> To take full advantage of model formatting, e.g. grouping categorical variables,
#> please add the following argument to the `workflows::add_model()` call:
#> `blueprint = hardhat::default_formula_blueprint(indicators = 'none')`
#> Extracting {workflows} model fit with `workflows::extract_fit_parsnip(x) %>% tbl_regression(...)`
#> Extracting {parsnip} model fit with `tbl_regression(x = x$fit, ...)`
Characteristic | OR | 95% CI | p-value |
---|---|---|---|
A | 0.28 | 0.19, 0.42 | \<0.001 |
B | 43.8 | 23.9, 85.4 | \<0.001 |
Created on 2022-06-17 by the reprex package (v2.0.1)
You can check out all the possibility for object extraction here: https://hardhat.tidymodels.org/reference/hardhat-extract.html
You'll want to use
extract_workflow()
on your final fit object, and then you can pipe to the gtsummary functions:library(tidymodels) data(two_class_dat) my_split <- initial_split(two_class_dat) glm_fit <- workflow(Class ~ ., logistic_reg()) %>% last_fit(my_split) glm_fit #> # Resampling results #> # Manual resampling #> # A tibble: 1 Γ 6 #> splits id .metrics .notes .predictions .workflow #> <list> <chr> <list> <list> <list> <list> #> 1 <split [593/198]> train/test split <tibble> <tibble> <tibble> <workflow> extract_workflow(glm_fit) %>% gtsummary::tbl_regression(exponentiate = TRUE) %>% gtsummary::as_kable() #> To take full advantage of model formatting, e.g. grouping categorical variables, #> please add the following argument to the `workflows::add_model()` call: #> `blueprint = hardhat::default_formula_blueprint(indicators = 'none')` #> Extracting {workflows} model fit with `workflows::extract_fit_parsnip(x) %>% tbl_regression(...)` #> Extracting {parsnip} model fit with `tbl_regression(x = x$fit, ...)`
Characteristic OR 95% CI p-value A 0.28 0.19, 0.42 <0.001 B 43.8 23.9, 85.4 <0.001 Created on 2022-06-17 by the reprex package (v2.0.1)
You can check out all the possibility for object extraction here: https://hardhat.tidymodels.org/reference/hardhat-extract.html
Hi @juliasilge, thanks for this. When I ran this` I got this error:
x Unable to identify the list of variables.
This is usually due to an error calling `stats::model.frame(x)`or `stats::model.matrix(x)`.
It could be the case if that type of model does not implement these methods.
Rarely, this error may occur if the model object was created within
a functional programming framework (e.g. using `lappy()`, `purrr::map()`, etc.).
and the table looks like this
|**Characteristic** | **exp(Beta)** |
|:------------------------------|:-------------:|
|(Intercept) | |
|(Intercept) | 0.72 |
|(Intercept) | 0.76 |
|(Intercept) | 0.79 |
(theres 1,000 rows)
A table was produced, but with (intercept) where all the variables would be and and exp(Beta) as a column?
Can you create a reprex (a minimal reproducible example) to demonstrate your problem? The goal of a reprex is to make it easier for us to recreate your problem so that we can understand it and/or fix it. If you've never heard of a reprex before, you may want to start with the tidyverse.org help page. Thanks! π
Hi @juliasilge here is a reprex that shows the above error when running the gtsummary object:
Error
Extracting {workflows} model fit with `workflows::extract_fit_parsnip(x) %>% tbl_regression(...)`
Extracting {parsnip} model fit with `tbl_regression(x = x$fit, ...)`
x Unable to identify the list of variables.
This is usually due to an error calling `stats::model.frame(x)`or `stats::model.matrix(x)`.
It could be the case if that type of model does not implement these methods.
Rarely, this error may occur if the model object was created within
a functional programming framework (e.g. using `lappy()`, `purrr::map()`, etc.).
Reprex Code
# reprex
#
model_sample <- tibble::tribble(
~res_sex, ~age10yr, ~cmd_type, ~smi_type, ~edqual5, ~sc, ~ethnic4, ~phys_health, ~trtment, ~service_use, ~dvilo,
"Male", "45 - 54", "None", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "Foreign/Other", "IV Partly Skilled", "Black", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Gen Anx & Dep", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Female", "35 - 44", "Panic Dis", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "A Level", "I Professional", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Gen Anx & Dep", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Used", "inactive",
"Male", "45 - 54", "Mixed Anx & Dep", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "Vocational*", "II Managerial and Technical", "Mixed or other", "Not Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Vocational*", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "A Level", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "Mixed Anx & Dep", "Eating Disorder", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Female", "55 - 64", "None", "None", "GCSE/Equivalent", "V Unskilled", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Female", "16 - 24", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "None", "None", "IIIM Skilled Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "Degree", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "Eating Disorder", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "Vocational*", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "Specific Phob", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "16 - 24", "None", "Eating Disorder", "None", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "Depression", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Vocational*", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "A Level", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "Vocational*", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "Psychosis Condition", "None", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Used", "active",
"Male", "65 - 74", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "Degree", "IIIM Skilled Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "Mixed Anx & Dep", "None", "A Level", "VI Armed Forces", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "None", "IIIM Skilled Non-Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "Gen Anx & Dep", "PTSD", "GCSE/Equivalent", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "Gen Anx & Dep", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "PTSD", "GCSE/Equivalent", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Mixed Anx & Dep", "None", "None", "IV Partly Skilled", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "None", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "16 - 24", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Depression", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "Both", "Used", "inactive",
"Female", "45 - 54", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "PTSD", "A Level", "IV Partly Skilled", "Black", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "Counselling Only", "Not Used", "active",
"Female", "65 - 74", "Mixed Anx & Dep", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "Mixed Anx & Dep", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "75+", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "Depression", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "South Asian (Indian, Pakistani or Bangladeshi)", "Not Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "75+", "None", "Eating Disorder", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "16 - 24", "None", "PTSD", "Vocational*", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Depression", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "None", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "Gen Anx & Dep", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "Degree", "II Managerial and Technical", "Mixed or other", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "Mixed Anx & Dep", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "Counselling Only", "Not Used", "inactive",
"Female", "75+", "None", "PTSD", "None", "IV Partly Skilled", "Black", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "45 - 54", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "Foreign/Other", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "Eating Disorder", "Degree", "II Managerial and Technical", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "Mixed Anx & Dep", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "35 - 44", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Female", "65 - 74", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "Vocational*", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "Mixed Anx & Dep", "PTSD", "Vocational*", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Foreign/Other", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "Foreign/Other", "IV Partly Skilled", "Mixed or other", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "Vocational*", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Vocational*", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "Foreign/Other", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Male", "75+", "None", "Eating Disorder", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Male", "25 - 34", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "Mixed Anx & Dep", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Degree", "I Professional", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "A Level", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "Vocational*", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "Depression", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "Vocational*", "II Managerial and Technical", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "Degree", "II Managerial and Technical", "South Asian (Indian, Pakistani or Bangladeshi)", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Mixed Anx & Dep", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "Degree", "II Managerial and Technical", "Mixed or other", "Not Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "None", "Degree", "IIIM Skilled Non-Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Male", "65 - 74", "None", "PTSD", "None", "IV Partly Skilled", "Black", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "PTSD", "Foreign/Other", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "Mixed or other", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "Mixed or other", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "Mixed Anx & Dep", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "A Level", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "Mixed Anx & Dep", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "Eating Disorder", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "Gen Anx & Dep", "None", "Degree", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "Panic Dis", "PTSD", "None", "V Unskilled", "Black", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "75+", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "PTSD", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "Eating Disorder", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "None", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "Panic Dis", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Used", "inactive",
"Female", "25 - 34", "None", "None", "Vocational*", "II Managerial and Technical", "Black", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "16 - 24", "Gen Anx & Dep", "PTSD", "Vocational*", "II Managerial and Technical", "Mixed or other", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "Vocational*", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Foreign/Other", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "PTSD", "None", "V Unskilled", "Black", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "Vocational*", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "PTSD", "Foreign/Other", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "Mixed Anx & Dep", "PTSD", "A Level", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "Vocational*", "II Managerial and Technical", "Black", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "Mixed Anx & Dep", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "Mixed Anx & Dep", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "Depression", "Eating Disorder", "GCSE/Equivalent", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "45 - 54", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "Mixed Anx & Dep", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "Mixed Anx & Dep", "None", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "75+", "None", "PTSD", "Foreign/Other", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "Gen Anx & Dep", "None", "Vocational*", "IIIM Skilled Manual", "Mixed or other", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "Mixed Anx & Dep", "None", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "PTSD", "Degree", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "A Level", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "75+", "None", "None", "None", "I Professional", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "PTSD", "A Level", "IIIM Skilled Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Male", "45 - 54", "None", "None", "Degree", "IIIM Skilled Non-Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Not Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "Mixed Anx & Dep", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "A Level", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "Mixed Anx & Dep", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "None", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "Vocational*", "II Managerial and Technical", "Black", "Not Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "PTSD", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "PTSD", "Vocational*", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "A Level", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "Gen Anx & Dep", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "Mixed Anx & Dep", "Eating Disorder", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "Specific Phob", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "Eating Disorder", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "A Level", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "Foreign/Other", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "None", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "None", "V Unskilled", "White", "Not Mentioned", "Medication Only", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "Gen Anx & Dep", "PTSD", "Degree", "I Professional", "White", "Mentioned", "Both", "Not Used", "active",
"Male", "35 - 44", "Mixed Anx & Dep", "PTSD", "Degree", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "Mixed Anx & Dep", "PTSD", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "Mixed Anx & Dep", "PTSD", "Foreign/Other", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "16 - 24", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "PTSD", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Female", "75+", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "Degree", "IIIM Skilled Non-Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "Mixed Anx & Dep", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "Gen Anx & Dep", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Depression", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "V Unskilled", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "Depression", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "Counselling Only", "Not Used", "active",
"Male", "16 - 24", "None", "PTSD", "Degree", "IIIM Skilled Non-Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "Mixed Anx & Dep", "Borderline Personality Disorder", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "Panic Dis", "Eating Disorder", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "16 - 24", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "Mixed Anx & Dep", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "Eating Disorder", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "Gen Anx & Dep", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Used", "active",
"Male", "55 - 64", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "Depression", "Eating Disorder", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "None", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "Mixed Anx & Dep", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "Degree", "IV Partly Skilled", "White", "Not Mentioned", "Medication Only", "Not Used", "active",
"Female", "75+", "None", "Eating Disorder", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "Mixed Anx & Dep", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "Mixed Anx & Dep", "None", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "Vocational*", "IV Partly Skilled", "White", "Mentioned", "Counselling Only", "Not Used", "active",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "Mixed Anx & Dep", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "None", "Degree", "II Managerial and Technical", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "Vocational*", "II Managerial and Technical", "Black", "Not Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "None", "Foreign/Other", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "None", "A Level", "I Professional", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "Mixed Anx & Dep", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Used", "inactive",
"Female", "55 - 64", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "A Level", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Foreign/Other", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "Eating Disorder", "None", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Female", "65 - 74", "Mixed Anx & Dep", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "Degree", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "Gen Anx & Dep", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "Mixed Anx & Dep", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "Depression", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Female", "25 - 34", "Mixed Anx & Dep", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Mixed Anx & Dep", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "Mixed Anx & Dep", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "Both", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Not Mentioned", "Both", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "PTSD", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Female", "25 - 34", "None", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "Mixed Anx & Dep", "PTSD", "Vocational*", "II Managerial and Technical", "Mixed or other", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "Depression", "None", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "Depression", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "OCD", "PTSD", "A Level", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "Gen Anx & Dep", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "A Level", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "Specific Phob", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "Both", "Used", "active",
"Male", "45 - 54", "Mixed Anx & Dep", "PTSD", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "None", "A Level", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "Degree", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "16 - 24", "None", "PTSD", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "16 - 24", "None", "None", "A Level", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "16 - 24", "None", "None", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "GCSE/Equivalent", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "Foreign/Other", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "16 - 24", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Not Mentioned", "Medication Only", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "None", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "Depression", "None", "None", "IV Partly Skilled", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Female", "75+", "None", "PTSD", "None", "V Unskilled", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "Vocational*", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "Gen Anx & Dep", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "Black", "Not Mentioned", "None", "Not Used", "active",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "Vocational*", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active"
)
model_split <- initial_split(model_sample,
strata = dvilo)
model_train <- model_split %>%
training()
model_test <- model_split %>%
testing()
model_rec <- recipe(dvilo ~ .,
data = model_train) %>%
step_dummy(all_nominal_predictors())
val_set <- validation_split(model_train,
strata = dvilo,
prop = 0.80)
val_set
lr_mod <-
logistic_reg(penalty = tune(), mixture = 1) %>%
set_engine("glmnet")
lr_workflow <-
workflow() %>%
add_model(lr_mod) %>%
add_recipe(model_rec)
lr_reg_grid <- tibble(penalty = 10^seq(-4, -1, length.out = 30))
lr_reg_grid %>% top_n(-5) # lowest penalty values
lr_reg_grid %>% top_n(5) # highest penalty values
lr_res <-
lr_workflow %>%
tune_grid(val_set,
grid = lr_reg_grid,
control = control_grid(save_pred = TRUE),
metrics = metric_set(roc_auc))
lr_res %>%
collect_metrics() %>%
ggplot(aes(x = penalty, y = mean)) +
geom_point() +
geom_line() +
ylab("Area under the ROC Curve") +
xlab("Penalty") +
scale_x_log10(labels = scales::label_number())
top_models <-
lr_res %>%
select_best("roc_auc", n = 15) %>%
arrange(penalty)
top_models
lr_best <-
lr_res %>%
collect_metrics() %>%
arrange(penalty) %>%
slice(21)
lr_best
lr_res %>%
collect_predictions(parameters = lr_best) %>%
roc_curve(dvilo, .pred_inactive) %>%
mutate(model = "Logistic Regression")
autoplot(lr_auc)
last_lr_mod <- logistic_reg(penalty = 0.0117, mixture = 1) %>%
set_engine("glmnet") %>%
set_mode("classification")
# the last workflow
last_lr_workflow <-
lr_workflow %>%
update_model(last_lr_mod)
# the last fit
last_lr_fit <-
last_lr_workflow %>%
last_fit(model_split)
last_lr_fit
last_lr_fit %>%
collect_metrics()
last_lr_fit %>%
extract_fit_parsnip() %>%
vip(num_features = 20)
last_lr_fit %>%
collect_predictions() %>%
roc_curve(dvilo, .pred_inactive) %>%
autoplot()
extract_workflow(last_lr_fit) %>%
gtsummary::tbl_regression(exponentiate = TRUE) %>%
gtsummary::as_kable()
Could you update your reproducible example to use the reprex package, and only the code that is necessary? Using reprex makes it easier to see both the input and output, and for us to re-run the code in a local session. Thanks! π
I believe this should work as expected for glmnet:
library(tidymodels)
data(two_class_dat)
my_split <- initial_split(two_class_dat)
glmnet_fit <-
workflow(Class ~ ., logistic_reg(penalty = 0.1, mixture = 1)) %>%
last_fit(my_split)
extract_workflow(glmnet_fit) %>%
gtsummary::tbl_regression(exponentiate = TRUE) %>%
gtsummary::as_kable()
#> To take full advantage of model formatting, e.g. grouping categorical variables,
#> please add the following argument to the `workflows::add_model()` call:
#> `blueprint = hardhat::default_formula_blueprint(indicators = 'none')`
#> Extracting {workflows} model fit with `workflows::extract_fit_parsnip(x) %>% tbl_regression(...)`
#> Extracting {parsnip} model fit with `tbl_regression(x = x$fit, ...)`
Characteristic | OR | 95% CI | p-value |
---|---|---|---|
A | 0.24 | 0.15, 0.37 | \<0.001 |
B | 55.2 | 29.1, 112 | \<0.001 |
Created on 2022-06-17 by the reprex package (v2.0.1)
If the problem is with last_fit()
or extraction, we only need this code to see it.
Hi @juliasilge reprex is below. I'm still getting an error message with gtsummary
. Thanks!
# reprex
#
library(tidyverse)
library(tidymodels)
model_sample <- tibble::tribble(
~res_sex, ~age10yr, ~cmd_type, ~smi_type, ~edqual5, ~sc, ~ethnic4, ~phys_health, ~trtment, ~service_use, ~dvilo,
"Male", "45 - 54", "None", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "Foreign/Other", "IV Partly Skilled", "Black", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Gen Anx & Dep", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Female", "35 - 44", "Panic Dis", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "A Level", "I Professional", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Gen Anx & Dep", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Used", "inactive",
"Male", "45 - 54", "Mixed Anx & Dep", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "Vocational*", "II Managerial and Technical", "Mixed or other", "Not Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Vocational*", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "A Level", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "Mixed Anx & Dep", "Eating Disorder", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Female", "55 - 64", "None", "None", "GCSE/Equivalent", "V Unskilled", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Female", "16 - 24", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "None", "None", "IIIM Skilled Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "A Level", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Not Used", "active",
"Male", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "55 - 64", "None", "None", "Degree", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "25 - 34", "None", "Eating Disorder", "GCSE/Equivalent", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "Vocational*", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Male", "45 - 54", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "Specific Phob", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "16 - 24", "None", "Eating Disorder", "None", "IV Partly Skilled", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "75+", "None", "None", "None", "V Unskilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "Depression", "None", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "PTSD", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Vocational*", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "None", "None", "A Level", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "Vocational*", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "None", "None", "IIIM Skilled Manual", "White", "Not Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "Psychosis Condition", "None", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Used", "active",
"Male", "65 - 74", "None", "None", "GCSE/Equivalent", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "None", "PTSD", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "Degree", "IIIM Skilled Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "inactive",
"Female", "65 - 74", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "45 - 54", "None", "None", "Degree", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "Mixed Anx & Dep", "None", "A Level", "VI Armed Forces", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "None", "None", "IIIM Skilled Non-Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Male", "45 - 54", "Gen Anx & Dep", "PTSD", "GCSE/Equivalent", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "55 - 64", "Gen Anx & Dep", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "Medication Only", "Used", "inactive",
"Female", "45 - 54", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "55 - 64", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Manual", "South Asian (Indian, Pakistani or Bangladeshi)", "Mentioned", "None", "Not Used", "active",
"Male", "75+", "None", "None", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "A Level", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "PTSD", "GCSE/Equivalent", "V Unskilled", "White", "Mentioned", "None", "Not Used", "active",
"Female", "25 - 34", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "16 - 24", "None", "None", "None", "IIIM Skilled Non-Manual", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "55 - 64", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "Degree", "I Professional", "White", "Mentioned", "None", "Not Used", "active",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "None", "Vocational*", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "65 - 74", "None", "PTSD", "None", "IV Partly Skilled", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "25 - 34", "None", "None", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Female", "45 - 54", "Mixed Anx & Dep", "None", "None", "IV Partly Skilled", "White", "Mentioned", "Medication Only", "Not Used", "inactive",
"Male", "35 - 44", "None", "None", "Degree", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Male", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "IIIM Skilled Non-Manual", "White", "Mentioned", "None", "Not Used", "active",
"Female", "75+", "None", "PTSD", "None", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "inactive",
"Female", "35 - 44", "None", "PTSD", "GCSE/Equivalent", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active",
"Female", "65 - 74", "None", "PTSD", "None", "IIIM Skilled Manual", "White", "Mentioned", "None", "Not Used", "inactive",
"Male", "25 - 34", "None", "PTSD", "None", "II Managerial and Technical", "White", "Not Mentioned", "None", "Not Used", "active",
"Male", "16 - 24", "None", "PTSD", "A Level", "II Managerial and Technical", "White", "Mentioned", "None", "Not Used", "active"
)
model_split <- initial_split(model_sample,
strata = dvilo
)
model_train <- model_split %>%
training()
model_test <- model_split %>%
testing()
model_rec <- recipe(dvilo ~ .,
data = model_train
) %>%
step_dummy(all_nominal_predictors())
val_set <- validation_split(model_train,
strata = dvilo,
prop = 0.80
)
val_set
#> # Validation Set Split (0.8/0.2) using stratification
#> # A tibble: 1 x 2
#> splits id
#> <list> <chr>
#> 1 <split [57/16]> validation
lr_mod <-
logistic_reg(penalty = tune(), mixture = 1) %>%
set_engine("glmnet")
lr_workflow <-
workflow() %>%
add_model(lr_mod) %>%
add_recipe(model_rec)
lr_reg_grid <- tibble(penalty = 10^seq(-4, -1, length.out = 30))
lr_reg_grid %>% top_n(-5) # lowest penalty values
#> Selecting by penalty
#> # A tibble: 5 x 1
#> penalty
#> <dbl>
#> 1 0.0001
#> 2 0.000127
#> 3 0.000161
#> 4 0.000204
#> 5 0.000259
lr_reg_grid %>% top_n(5) # highest penalty values
#> Selecting by penalty
#> # A tibble: 5 x 1
#> penalty
#> <dbl>
#> 1 0.0386
#> 2 0.0489
#> 3 0.0621
#> 4 0.0788
#> 5 0.1
lr_res <-
lr_workflow %>%
tune_grid(val_set,
grid = lr_reg_grid,
control = control_grid(save_pred = TRUE),
metrics = metric_set(roc_auc)
)
#> New names:
#> New names:
#> * `age10yr_X25...34` -> `age10yr_X25`
#> * `age10yr_X35...44` -> `age10yr_X35`
#> * `age10yr_X45...54` -> `age10yr_X45`
#> * `age10yr_X55...64` -> `age10yr_X55`
#> * `age10yr_X65...74` -> `age10yr_X65`
lr_res %>%
collect_metrics() %>%
ggplot(aes(x = penalty, y = mean)) +
geom_point() +
geom_line() +
ylab("Area under the ROC Curve") +
xlab("Penalty") +
scale_x_log10(labels = scales::label_number())
top_models <-
lr_res %>%
select_best("roc_auc", n = 15) %>%
arrange(penalty)
top_models
#> # A tibble: 1 x 2
#> penalty .config
#> <dbl> <chr>
#> 1 0.0788 Preprocessor1_Model29
lr_best <-
lr_res %>%
collect_metrics() %>%
arrange(penalty) %>%
slice(21)
lr_best
#> # A tibble: 1 x 7
#> penalty .metric .estimator mean n std_err .config
#> <dbl> <chr> <chr> <dbl> <int> <dbl> <chr>
#> 1 0.0117 roc_auc binary 0.889 1 NA Preprocessor1_Model21
lr_res %>%
collect_predictions(parameters = lr_best) %>%
roc_curve(dvilo, .pred_inactive) %>%
mutate(model = "Logistic Regression")
#> # A tibble: 18 x 4
#> .threshold specificity sensitivity model
#> <dbl> <dbl> <dbl> <chr>
#> 1 -Inf 0 1 Logistic Regression
#> 2 0.0278 0 1 Logistic Regression
#> 3 0.176 0 0.889 Logistic Regression
#> 4 0.220 0 0.778 Logistic Regression
#> 5 0.242 0 0.667 Logistic Regression
#> 6 0.245 0 0.556 Logistic Regression
#> 7 0.247 0 0.444 Logistic Regression
#> 8 0.293 0.143 0.444 Logistic Regression
#> 9 0.359 0.143 0.333 Logistic Regression
#> 10 0.556 0.143 0.222 Logistic Regression
#> 11 0.662 0.286 0.222 Logistic Regression
#> 12 0.927 0.286 0.111 Logistic Regression
#> 13 0.938 0.429 0.111 Logistic Regression
#> 14 0.941 0.429 0 Logistic Regression
#> 15 0.955 0.571 0 Logistic Regression
#> 16 0.957 0.714 0 Logistic Regression
#> 17 0.958 0.857 0 Logistic Regression
#> 18 Inf 1 0 Logistic Regression
autoplot(lr_auc)
#> Error in autoplot(lr_auc): object 'lr_auc' not found
last_lr_mod <- logistic_reg(penalty = 0.0117, mixture = 1) %>%
set_engine("glmnet") %>%
set_mode("classification")
# the last workflow
last_lr_workflow <-
lr_workflow %>%
update_model(last_lr_mod)
# the last fit
last_lr_fit <-
last_lr_workflow %>%
last_fit(model_split)
#> New names:
#> New names:
#> ! train/test split: preprocessor 1/1, model 1/1 (predictions): There are new
#> levels in a fac...
#> * `age10yr_X25...34` -> `age10yr_X25`
#> * `age10yr_X35...44` -> `age10yr_X35`
#> * `age10yr_X45...54` -> `age10yr_X45`
#> * `age10yr_X55...64` -> `age10yr_X55`
#> * `age10yr_X65...74` -> `age10yr_X65`
last_lr_fit
#> # Resampling results
#> # Manual resampling
#> # A tibble: 1 x 6
#> splits id .metrics .notes .predictions .workflow
#> <list> <chr> <list> <list> <list> <list>
#> 1 <split [73/26]> train/test split <tibble> <tibble> <tibble> <workflow>
#>
#> There were issues with some computations:
#>
#> - Warning(s) x1: There are new levels in a factor: Psychosis Condition, There are ...
#>
#> Use `collect_notes(object)` for more information.
last_lr_fit %>%
collect_metrics()
#> # A tibble: 2 x 4
#> .metric .estimator .estimate .config
#> <chr> <chr> <dbl> <chr>
#> 1 accuracy binary 0.667 Preprocessor1_Model1
#> 2 roc_auc binary 0.713 Preprocessor1_Model1
last_lr_fit %>%
extract_fit_parsnip() %>%
vip(num_features = 20)
#> Error in vip(., num_features = 20): could not find function "vip"
last_lr_fit %>%
collect_predictions() %>%
roc_curve(dvilo, .pred_active) %>%
autoplot()
extract_workflow(last_lr_fit) %>%
gtsummary::tbl_regression(exponentiate = TRUE)
#> Extracting {workflows} model fit with `workflows::extract_fit_parsnip(x) %>% tbl_regression(...)`
#> Extracting {parsnip} model fit with `tbl_regression(x = x$fit, ...)`
#> x Unable to identify the list of variables.
#>
#> This is usually due to an error calling `stats::model.frame(x)`or `stats::model.matrix(x)`.
#> It could be the case if that type of model does not implement these methods.
#> Rarely, this error may occur if the model object was created within
#> a functional programming framework (e.g. using `lappy()`, `purrr::map()`, etc.).
#> Warning: The `fmt_missing()` function is deprecated and will soon be removed
#> * Use the `sub_missing()` function instead
The tbl again looks like the below, wether passing kable or the more traditional gtsummary output (the actual output can't be posted as it's too long for here:
|**Characteristic** | **exp(Beta)** |
|:------------------------------|:-------------:|
|(Intercept) | |
|(Intercept) | 0.72 |
|(Intercept) | 0.76 |
|(Intercept) | 0.79 |
(theres 1,000 rows)
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#> setting value
#> version R version 4.1.3 (2022-03-10)
#> os Windows 10 x64 (build 22000)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United Kingdom.1252
#> ctype English_United Kingdom.1252
#> tz Europe/London
#> date 2022-06-17
#> pandoc 2.18 @ C:/PROGRA~3/chocolatey/bin/ (via rmarkdown)
#>
#> - Packages -------------------------------------------------------------------
#> package * version date (UTC) lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.2)
#> backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.2)
#> broom * 0.8.0 2022-04-13 [1] CRAN (R 4.1.3)
#> broom.helpers 1.6.0 2022-01-12 [1] CRAN (R 4.1.2)
#> cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.1.2)
#> checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.1.2)
#> class 7.3-20 2022-01-13 [1] CRAN (R 4.1.2)
#> cli 3.2.0 2022-02-14 [1] CRAN (R 4.1.2)
#> codetools 0.2-18 2020-11-04 [2] CRAN (R 4.1.3)
#> colorspace 2.0-3 2022-02-21 [1] CRAN (R 4.1.3)
#> commonmark 1.8.0 2022-03-09 [1] CRAN (R 4.1.3)
#> crayon 1.5.1 2022-03-26 [1] CRAN (R 4.1.3)
#> curl 4.3.2 2021-06-23 [1] CRAN (R 4.1.2)
#> DBI 1.1.2 2021-12-20 [1] CRAN (R 4.1.2)
#> dbplyr 2.1.1 2021-04-06 [1] CRAN (R 4.1.2)
#> dials * 0.1.0 2022-01-31 [1] CRAN (R 4.1.2)
#> DiceDesign 1.9 2021-02-13 [1] CRAN (R 4.1.2)
#> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.2)
#> dplyr * 1.0.8 2022-02-08 [1] CRAN (R 4.1.2)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.2)
#> evaluate 0.15 2022-02-18 [1] CRAN (R 4.1.2)
#> fansi 1.0.3 2022-03-24 [1] CRAN (R 4.1.3)
#> farver 2.1.0 2021-02-28 [1] CRAN (R 4.1.2)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.2)
#> forcats * 0.5.1 2021-01-27 [1] CRAN (R 4.1.2)
#> foreach 1.5.2 2022-02-02 [1] CRAN (R 4.1.2)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.2)
#> furrr 0.2.3 2021-06-25 [1] CRAN (R 4.1.2)
#> future 1.24.0 2022-02-19 [1] CRAN (R 4.1.3)
#> future.apply 1.8.1 2021-08-10 [1] CRAN (R 4.1.2)
#> generics 0.1.2 2022-01-31 [1] CRAN (R 4.1.2)
#> ggplot2 * 3.3.5 2021-06-25 [1] CRAN (R 4.1.2)
#> glmnet * 4.1-4 2022-04-15 [1] CRAN (R 4.1.3)
#> globals 0.14.0 2020-11-22 [1] CRAN (R 4.1.1)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.3)
#> gower 1.0.0 2022-02-03 [1] CRAN (R 4.1.2)
#> GPfit 1.0-8 2019-02-08 [1] CRAN (R 4.1.2)
#> gt 0.6.0 2022-05-24 [1] CRAN (R 4.1.3)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 4.1.2)
#> gtsummary 1.5.2 2022-01-29 [1] CRAN (R 4.1.2)
#> hardhat 0.2.0 2022-01-24 [1] CRAN (R 4.1.2)
#> haven 2.4.3 2021-08-04 [1] CRAN (R 4.1.2)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.1.2)
#> hms 1.1.1 2021-09-26 [1] CRAN (R 4.1.2)
#> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.2)
#> httr 1.4.2 2020-07-20 [1] CRAN (R 4.1.2)
#> infer * 1.0.0 2021-08-13 [1] CRAN (R 4.1.2)
#> ipred 0.9-12 2021-09-15 [1] CRAN (R 4.1.2)
#> iterators 1.0.14 2022-02-05 [1] CRAN (R 4.1.2)
#> jsonlite 1.8.0 2022-02-22 [1] CRAN (R 4.1.3)
#> knitr 1.39 2022-04-26 [1] CRAN (R 4.1.3)
#> labeling 0.4.2 2020-10-20 [1] CRAN (R 4.1.1)
#> lattice 0.20-45 2021-09-22 [2] CRAN (R 4.1.3)
#> lava 1.6.10 2021-09-02 [1] CRAN (R 4.1.2)
#> lhs 1.1.5 2022-03-22 [1] CRAN (R 4.1.3)
#> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.2)
#> listenv 0.8.0 2019-12-05 [1] CRAN (R 4.1.2)
#> lubridate 1.8.0 2021-10-07 [1] CRAN (R 4.1.2)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.3)
#> MASS 7.3-55 2022-01-13 [1] CRAN (R 4.1.2)
#> Matrix * 1.4-0 2021-12-08 [2] CRAN (R 4.1.3)
#> mime 0.12 2021-09-28 [1] CRAN (R 4.1.1)
#> modeldata * 0.1.1 2021-07-14 [1] CRAN (R 4.1.2)
#> modelr 0.1.8 2020-05-19 [1] CRAN (R 4.1.2)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.2)
#> nnet 7.3-17 2022-01-13 [1] CRAN (R 4.1.2)
#> parallelly 1.30.0 2021-12-17 [1] CRAN (R 4.1.2)
#> parsnip * 0.2.1.9000 2022-03-29 [1] Github (tidymodels/parsnip@9ce41c8)
#> pillar 1.7.0 2022-02-01 [1] CRAN (R 4.1.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.2)
#> plyr 1.8.7 2022-03-24 [1] CRAN (R 4.1.3)
#> pROC 1.18.0 2021-09-03 [1] CRAN (R 4.1.2)
#> prodlim 2019.11.13 2019-11-17 [1] CRAN (R 4.1.2)
#> purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.1.2)
#> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.2)
#> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.1)
#> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.1)
#> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.2)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.2)
#> Rcpp 1.0.8.3 2022-03-17 [1] CRAN (R 4.1.3)
#> readr * 2.1.2 2022-01-30 [1] CRAN (R 4.1.2)
#> readxl 1.3.1 2019-03-13 [1] CRAN (R 4.1.2)
#> recipes * 0.2.0 2022-02-18 [1] CRAN (R 4.1.2)
#> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.2)
#> rlang 1.0.2 2022-03-04 [1] CRAN (R 4.1.3)
#> rmarkdown 2.14 2022-04-25 [1] CRAN (R 4.1.3)
#> rpart 4.1.16 2022-01-24 [1] CRAN (R 4.1.2)
#> rsample * 0.1.1 2021-11-08 [1] CRAN (R 4.1.2)
#> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.2)
#> rvest 1.0.2 2021-10-16 [1] CRAN (R 4.1.2)
#> sass 0.4.1 2022-03-23 [1] CRAN (R 4.1.3)
#> scales * 1.2.0 2022-04-13 [1] CRAN (R 4.1.3)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2)
#> shape 1.4.6 2021-05-19 [1] CRAN (R 4.1.1)
#> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.2)
#> stringr * 1.4.0 2019-02-10 [1] CRAN (R 4.1.2)
#> styler 1.7.0 2022-03-13 [1] CRAN (R 4.1.3)
#> survival 3.2-13 2021-08-24 [2] CRAN (R 4.1.3)
#> tibble * 3.1.6 2021-11-07 [1] CRAN (R 4.1.2)
#> tidymodels * 0.2.0 2022-03-19 [1] CRAN (R 4.1.3)
#> tidyr * 1.2.0 2022-02-01 [1] CRAN (R 4.1.2)
#> tidyselect 1.1.2 2022-02-21 [1] CRAN (R 4.1.3)
#> tidyverse * 1.3.1 2021-04-15 [1] CRAN (R 4.1.2)
#> timeDate 3043.102 2018-02-21 [1] CRAN (R 4.1.1)
#> tune * 0.2.0.9000 2022-03-29 [1] Github (tidymodels/tune@6ed30a4)
#> tzdb 0.2.0 2021-10-27 [1] CRAN (R 4.1.2)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.2)
#> vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.1.3)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.3)
#> workflows * 0.2.6 2022-03-18 [1] CRAN (R 4.1.3)
#> workflowsets * 0.2.1 2022-03-15 [1] CRAN (R 4.1.3)
#> xfun 0.30 2022-03-02 [1] CRAN (R 4.1.3)
#> xml2 1.3.3 2021-11-30 [1] CRAN (R 4.1.2)
#> yaml 2.3.5 2022-02-21 [1] CRAN (R 4.1.2)
#> yardstick * 0.0.9 2021-11-22 [1] CRAN (R 4.1.2)
#>
#> [1] C:/Users/rmkja/Documents/R/win-library/4.1
#> [2] C:/Program Files/R/R-4.1.3/library
#>
#> ------------------------------------------------------------------------------
Ah OK, something is happening in how the data stored in the glmnet model is being tidied by gtsummary. This isn't anything that has gone wrong with the tidymodels code; it seems like gtsummary doesn't account for the transformation from the original variables via preprocessing from the recipe, or maybe the tidying doesn't work that well at all. We have a tidy()
method for glmnet in parsnip that may work better.
I suggest that you create a much smaller reprex (data with some categorical variables, like penguins
or similar, plus a glmnet model) and ask the gtsummary folks how they recommend handling this. They may want to use parsnip's tidy()
method for glmnet, maybe. Good luck! π
library(tidymodels)
data(penguins)
my_split <- penguins %>% na.omit() %>% initial_split()
rec <- recipe(sex ~ species + bill_length_mm + bill_depth_mm,
data = penguins) %>%
step_dummy(species)
glmnet_spec <- logistic_reg(penalty = 0.1, mixture = 1) %>%
set_engine("glmnet")
glmnet_fit <-
workflow(rec, glmnet_spec) %>%
last_fit(my_split)
extract_workflow(glmnet_fit) %>%
gtsummary::tbl_regression(exponentiate = TRUE) %>%
gtsummary::as_kable()
#> Extracting {workflows} model fit with `workflows::extract_fit_parsnip(x) %>% tbl_regression(...)`
#> Extracting {parsnip} model fit with `tbl_regression(x = x$fit, ...)`
#> β Unable to identify the list of variables.
#>
#> This is usually due to an error calling `stats::model.frame(x)`or `stats::model.matrix(x)`.
#> It could be the case if that type of model does not implement these methods.
#> Rarely, this error may occur if the model object was created within
#> a functional programming framework (e.g. using `lappy()`, `purrr::map()`, etc.).
Characteristic | exp(Beta) |
---|---|
(Intercept) | |
(Intercept) | -0.04 |
(Intercept) | -0.95 |
(Intercept) | -2.35 |
(Intercept) | -3.66 |
(Intercept) | -4.89 |
(Intercept) | -6.06 |
(Intercept) | -7.17 |
(Intercept) | -8.25 |
(Intercept) | -9.28 |
(Intercept) | -10.8 |
(Intercept) | -12.7 |
(Intercept) | -14.6 |
(Intercept) | -16.4 |
(Intercept) | -18.2 |
(Intercept) | -19.9 |
(Intercept) | -21.7 |
(Intercept) | -23.4 |
(Intercept) | -25.1 |
(Intercept) | -26.8 |
(Intercept) | -28.5 |
(Intercept) | -30.2 |
(Intercept) | -31.9 |
(Intercept) | -33.6 |
(Intercept) | -35.2 |
(Intercept) | -36.8 |
(Intercept) | -38.4 |
(Intercept) | -40.0 |
(Intercept) | -41.6 |
(Intercept) | -43.1 |
(Intercept) | -44.6 |
(Intercept) | -46.0 |
(Intercept) | -47.5 |
(Intercept) | -48.8 |
(Intercept) | -50.2 |
(Intercept) | -51.4 |
(Intercept) | -52.7 |
(Intercept) | -53.9 |
(Intercept) | -55.0 |
(Intercept) | -56.1 |
(Intercept) | -57.1 |
(Intercept) | -58.1 |
(Intercept) | -59.1 |
(Intercept) | -60.0 |
(Intercept) | -60.8 |
(Intercept) | -61.6 |
(Intercept) | -62.3 |
(Intercept) | -63.0 |
(Intercept) | -63.7 |
(Intercept) | -64.3 |
(Intercept) | -64.9 |
(Intercept) | -65.4 |
(Intercept) | -65.9 |
(Intercept) | -66.4 |
(Intercept) | -66.8 |
(Intercept) | -67.2 |
(Intercept) | -67.5 |
(Intercept) | -67.9 |
(Intercept) | -68.2 |
(Intercept) | -68.5 |
(Intercept) | -68.7 |
(Intercept) | -69.0 |
(Intercept) | -69.2 |
(Intercept) | -69.4 |
(Intercept) | -69.6 |
(Intercept) | -69.7 |
(Intercept) | -69.9 |
(Intercept) | -70.0 |
(Intercept) | -70.1 |
(Intercept) | -70.2 |
(Intercept) | -70.3 |
(Intercept) | -70.4 |
(Intercept) | -70.5 |
bill_length_mm | |
bill_length_mm | 0.01 |
bill_length_mm | 0.02 |
bill_length_mm | 0.03 |
bill_length_mm | 0.05 |
bill_length_mm | 0.06 |
bill_length_mm | 0.07 |
bill_length_mm | 0.08 |
bill_length_mm | 0.10 |
bill_length_mm | 0.11 |
bill_length_mm | 0.14 |
bill_length_mm | 0.16 |
bill_length_mm | 0.18 |
bill_length_mm | 0.20 |
bill_length_mm | 0.22 |
bill_length_mm | 0.24 |
bill_length_mm | 0.26 |
bill_length_mm | 0.28 |
bill_length_mm | 0.30 |
bill_length_mm | 0.32 |
bill_length_mm | 0.34 |
bill_length_mm | 0.36 |
bill_length_mm | 0.38 |
bill_length_mm | 0.40 |
bill_length_mm | 0.42 |
bill_length_mm | 0.44 |
bill_length_mm | 0.46 |
bill_length_mm | 0.48 |
bill_length_mm | 0.50 |
bill_length_mm | 0.51 |
bill_length_mm | 0.53 |
bill_length_mm | 0.55 |
bill_length_mm | 0.56 |
bill_length_mm | 0.58 |
bill_length_mm | 0.60 |
bill_length_mm | 0.61 |
bill_length_mm | 0.62 |
bill_length_mm | 0.64 |
bill_length_mm | 0.65 |
bill_length_mm | 0.66 |
bill_length_mm | 0.67 |
bill_length_mm | 0.69 |
bill_length_mm | 0.70 |
bill_length_mm | 0.71 |
bill_length_mm | 0.72 |
bill_length_mm | 0.72 |
bill_length_mm | 0.73 |
bill_length_mm | 0.74 |
bill_length_mm | 0.75 |
bill_length_mm | 0.75 |
bill_length_mm | 0.76 |
bill_length_mm | 0.77 |
bill_length_mm | 0.77 |
bill_length_mm | 0.78 |
bill_length_mm | 0.78 |
bill_length_mm | 0.79 |
bill_length_mm | 0.79 |
bill_length_mm | 0.79 |
bill_length_mm | 0.80 |
bill_length_mm | 0.80 |
bill_length_mm | 0.80 |
bill_length_mm | 0.81 |
bill_length_mm | 0.81 |
bill_length_mm | 0.81 |
bill_length_mm | 0.81 |
bill_length_mm | 0.82 |
bill_length_mm | 0.82 |
bill_length_mm | 0.82 |
bill_length_mm | 0.82 |
bill_length_mm | 0.83 |
bill_length_mm | 0.83 |
bill_length_mm | 0.83 |
bill_depth_mm | |
bill_depth_mm | 0.04 |
bill_depth_mm | 0.08 |
bill_depth_mm | 0.12 |
bill_depth_mm | 0.16 |
bill_depth_mm | 0.20 |
bill_depth_mm | 0.23 |
bill_depth_mm | 0.26 |
bill_depth_mm | 0.30 |
bill_depth_mm | 0.34 |
bill_depth_mm | 0.40 |
bill_depth_mm | 0.45 |
bill_depth_mm | 0.51 |
bill_depth_mm | 0.56 |
bill_depth_mm | 0.61 |
bill_depth_mm | 0.66 |
bill_depth_mm | 0.71 |
bill_depth_mm | 0.77 |
bill_depth_mm | 0.82 |
bill_depth_mm | 0.87 |
bill_depth_mm | 0.92 |
bill_depth_mm | 0.97 |
bill_depth_mm | 1.01 |
bill_depth_mm | 1.06 |
bill_depth_mm | 1.11 |
bill_depth_mm | 1.16 |
bill_depth_mm | 1.21 |
bill_depth_mm | 1.25 |
bill_depth_mm | 1.30 |
bill_depth_mm | 1.34 |
bill_depth_mm | 1.38 |
bill_depth_mm | 1.43 |
bill_depth_mm | 1.47 |
bill_depth_mm | 1.51 |
bill_depth_mm | 1.54 |
bill_depth_mm | 1.58 |
bill_depth_mm | 1.62 |
bill_depth_mm | 1.65 |
bill_depth_mm | 1.68 |
bill_depth_mm | 1.71 |
bill_depth_mm | 1.74 |
bill_depth_mm | 1.77 |
bill_depth_mm | 1.80 |
bill_depth_mm | 1.82 |
bill_depth_mm | 1.85 |
bill_depth_mm | 1.87 |
bill_depth_mm | 1.89 |
bill_depth_mm | 1.91 |
bill_depth_mm | 1.93 |
bill_depth_mm | 1.94 |
bill_depth_mm | 1.96 |
bill_depth_mm | 1.97 |
bill_depth_mm | 1.99 |
bill_depth_mm | 2.00 |
bill_depth_mm | 2.01 |
bill_depth_mm | 2.02 |
bill_depth_mm | 2.03 |
bill_depth_mm | 2.04 |
bill_depth_mm | 2.05 |
bill_depth_mm | 2.06 |
bill_depth_mm | 2.06 |
bill_depth_mm | 2.07 |
bill_depth_mm | 2.07 |
bill_depth_mm | 2.08 |
bill_depth_mm | 2.08 |
bill_depth_mm | 2.08 |
bill_depth_mm | 2.09 |
bill_depth_mm | 2.09 |
bill_depth_mm | 2.09 |
bill_depth_mm | 2.09 |
bill_depth_mm | 2.09 |
bill_depth_mm | 2.10 |
species_Chinstrap | |
species_Chinstrap | -0.16 |
species_Chinstrap | -0.44 |
species_Chinstrap | -0.71 |
species_Chinstrap | -0.97 |
species_Chinstrap | -1.22 |
species_Chinstrap | -1.47 |
species_Chinstrap | -1.71 |
species_Chinstrap | -1.94 |
species_Chinstrap | -2.18 |
species_Chinstrap | -2.41 |
species_Chinstrap | -2.64 |
species_Chinstrap | -2.87 |
species_Chinstrap | -3.10 |
species_Chinstrap | -3.32 |
species_Chinstrap | -3.54 |
species_Chinstrap | -3.76 |
species_Chinstrap | -3.98 |
species_Chinstrap | -4.19 |
species_Chinstrap | -4.40 |
species_Chinstrap | -4.61 |
species_Chinstrap | -4.81 |
species_Chinstrap | -5.00 |
species_Chinstrap | -5.19 |
species_Chinstrap | -5.38 |
species_Chinstrap | -5.56 |
species_Chinstrap | -5.73 |
species_Chinstrap | -5.90 |
species_Chinstrap | -6.06 |
species_Chinstrap | -6.21 |
species_Chinstrap | -6.36 |
species_Chinstrap | -6.50 |
species_Chinstrap | -6.64 |
species_Chinstrap | -6.76 |
species_Chinstrap | -6.88 |
species_Chinstrap | -7.00 |
species_Chinstrap | -7.11 |
species_Chinstrap | -7.21 |
species_Chinstrap | -7.30 |
species_Chinstrap | -7.39 |
species_Chinstrap | -7.47 |
species_Chinstrap | -7.55 |
species_Chinstrap | -7.62 |
species_Chinstrap | -7.69 |
species_Chinstrap | -7.75 |
species_Chinstrap | -7.80 |
species_Chinstrap | -7.86 |
species_Chinstrap | -7.91 |
species_Chinstrap | -7.95 |
species_Chinstrap | -7.99 |
species_Chinstrap | -8.03 |
species_Chinstrap | -8.07 |
species_Chinstrap | -8.10 |
species_Chinstrap | -8.13 |
species_Chinstrap | -8.17 |
species_Chinstrap | -8.20 |
species_Chinstrap | -8.23 |
species_Chinstrap | -8.26 |
species_Chinstrap | -8.29 |
species_Chinstrap | -8.32 |
species_Chinstrap | -8.34 |
species_Chinstrap | -8.36 |
species_Chinstrap | -8.38 |
species_Chinstrap | -8.39 |
species_Gentoo | |
species_Gentoo | 0.00 |
species_Gentoo | -0.02 |
species_Gentoo | -0.04 |
species_Gentoo | -0.05 |
species_Gentoo | -0.07 |
species_Gentoo | -0.08 |
species_Gentoo | -0.09 |
species_Gentoo | -0.11 |
species_Gentoo | -0.12 |
species_Gentoo | -0.13 |
species_Gentoo | -0.14 |
Created on 2022-06-17 by the reprex package (v2.0.1)
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.
The problem
I'm having trouble with feeding a last_fit model to a gtsummary
tbl_regression
so that odds ratios, confidence intervals and p-values can be reported. I'm following thetidymodels
case study walkthrough here: https://www.tidymodels.org/start/case-study/. The error is:When rerun with
extract_fit_parsnip()
error:Reproducible example
The Hotel Bookings Data
Let's read the hotel data into R and randomly select 30% of the rows in the data set to avoid long computation times later on.
Note that your results will differ from the original article, since you are only using 30% of the data.
Let's look at proportions of hotel stays that include children and/or babies:
A first model: penalized logistic regression
Do you recall Evaluate your model with resampling article for data splitting?
Let's reserve 25% of the
hotels
data for the test set:Now let's reserve another 20% of the
hotel_other
for our validation set.Build the model
Let's specify a penalized logistic regression model using the lasso method. Note that we define
penalty = tune()
so we can tune it in the next steps, and since we are using lasso method, we setmixture = 1
.For more details try typing
?logistic_reg
on the console.Create the recipe
Remember the second article Preprocess your data with recipes?
Let's preprocess the data by creating a recipe:
Create the workflow
Let's bundle the model and recipe into a single
workflow()
:Create the grid for tuning
We can now tune our model, similar to what is shown in the previous article Tune model parameters. Let's create a grid with 30 values for the hyperparameter we would like to tune:
Train and tune the model
Let's train all these logistic regression models with 30 different hyperparameter values. We provide the validation set
val_set
, so model diagnostics computed onval_set
will be available after the fit.Now visualize the validation set metrics by plotting the area under the ROC curve against the range of penalty values:
Get the best values for this hyperparameter:
Let's pick candidate model 12 with a penalty value of
0.00137
:Note that because you are using less data, your mean ROC AUC will be slightly lower than what's shown in the article.
And visualize the validation set ROC curve:
A second model: tree-based ensemble
Let's try to improve our prediction performance by using a random forest model (model type), which we also explored in the Evaluate your model with resampling article.
Check number of cores to work with:
Set model specification and provide number of cores for parallelization while tuning.
Create the recipe and workflow
Let's create the recipe for the model.
Then bundle it with the model specification:
Train and tune the model
When we set up our parsnip model, we chose two hyperparameters for tuning:
We will use a space-filling design to tune with 12 candidate models (instead of 25, to reduce computation time).
Be patient here! Computing these results will take several minutes to complete if you are using the default RStudio Cloud resources (1 GB memory, 1 CPU).
Here are our top 5 random forest models, out of the 12 candidates:
Note that your results will be different and your accuracy will take a small hit since you are using less data (only 25% of the whole data set) and setting up a smaller grid to tune model hyperparameters.
But we're already getting much better results than our penalized logistic regression!
Let's plot the results:
Let's select the best model according to the ROC AUC metric. Our final tuning parameter values are:
Collect predictions for the best model: Note that we simply provide our best model's parameter values
rf_best
to subset it from a whole list of tuned models.Now, we can compare the validation set ROC curves for our top penalized logistic regression model and random forest model:
The random forest is uniformly better across event probability thresholds.
The last fit
Let's evaluate the model performance one last time with the held-out test set. We'll start by building our parsnip model object again from scratch with our best hyperparameter values from our random forest model:
Note that we added a new argument
importance = "impurity"
toset_engine
to get variable importance scores. This is an optional, engine-specific argument. To see its documentation, you need to read the documentation for the underlyingranger()
function. To see it and other options, type?ranger
in console.Now let's collect the metrics:
Now let's
pluck
the workflow and pull out the fit and visualize the variable importance scores for the top 20 features:Let's generate our last ROC curve to visualize:
Not bad!
The error is