Comments (19)
This package is not in active development, if you are interested in this feature, please implement it, then keep a fork or create a pull request to https://github.com/ShixiangWang/forestmodel
from forestmodel.
@ShixiangWang is it an official fork?
@NikNakk could you clarify if you still plan to maintain and develop forestmodel
?
from forestmodel.
@larmarange Nope, I don't say that. The author is nice, but he may be not active in GitHub, from my view.
from forestmodel.
Hi @larmarange, @ShixiangWang,
I've not been very active in maintaining this package for a while because of being busy with other things, but I'm still aiming to get to the outstanding queries that have been raised including yours. There's also now a more pressing reason to attend to the package because it's erroring on CRAN so will be delisted if I don't fix that. I'll at least fix the current issue that would lead to delisting in the next few days, but if I can I'll try to fix any other outstanding issues and improvements.
from forestmodel.
Thanks @NikNakk for your feedback.
Regarding the proposed improvement, it should not be very difficult to implement once identified where variable names are taken into account.
I didn't have time to get into your code in details so I do not know yet how your code was organized. But as you are familiar with your package, you should have an idea on where to look at.
Best regards
from forestmodel.
@larmarange I've made a new branch that has a simple implementation of this at https://github.com/NikNakk/forestmodel/tree/labels. You can test it using remotes::install_github("NikNakk/forestmodel@labels")
from forestmodel.
Thanks a lot
from forestmodel.
@larmarange please let me know when you've had a chance to test this out.
from forestmodel.
@NikNakk I have done some quick tests. It works well with simple models. Thanks.
When I add interaction terms, labels are not taken into account for interaction terms, but it was already the case before (it seems that forstmodel
was not treating them in a particular way).
library(questionr)
library(forestmodel)
library(labelled)
data(fertility)
women <- unlabelled(women)
mod <- glm(employed ~ age + residency * instruction, data = women, family = binomial())
forest_model(mod, exponentiate = TRUE)
Here a quick example with gtsummary
to show this package handle interaction terams.
library(gtsummary)
tbl_regression(mod)
Characteristic | log(OR) | 95% CI | p-value |
---|---|---|---|
Age at last anniversary (in years) | 0.06 | 0.05, 0.07 | <0.001 |
Urban / rural residency | |||
urban | |||
rural | 0.28 | 0.00, 0.55 | 0.052 |
Level of instruction | |||
none | |||
primary | 0.35 | -0.02, 0.74 | 0.067 |
secondary | -0.83 | -1.2, -0.50 | <0.001 |
higher | -0.71 | -1.3, -0.10 | 0.022 |
Urban / rural residency * Level of instruction | |||
rural * primary | -0.16 | -0.67, 0.35 | 0.5 |
rural * secondary | 0.19 | -0.41, 0.80 | 0.5 |
rural * higher | -1.5 | -4.5, 0.56 | 0.2 |
from forestmodel.
But I know that managing interaction terms could be tricky and beyond the current issue.
Otherwise, it's perfect. Thanks a lot
from forestmodel.
I’ll have a look at interaction terms when I get a chance. gtsummary
looks like a good starting point. For now I’ve merged the labels branch into master and need to get the latest version on CRAN because otherwise it will be delisted.
from forestmodel.
Thanks
from forestmodel.
FYI, this version is now on CRAN.
from forestmodel.
Variable labels still not showing up
from forestmodel.
Variable labels still not showing up
Same here, it works fine with gtsummary::tbl_regression
but not with forest_model
from the forestmodel
package that I just downloaded from Github.
from forestmodel.
Sorry for the delayed response, @proshano and @corneliushennch. Could you please give me some example code that doesn't work as expected? I'm still planning to work on interaction terms since they're not currently properly supported with or without labels.
from forestmodel.
In case it could be useful for you, gtsummary::tbl_regression()
now relies on broom.helpers
package: https://larmarange.github.io/broom.helpers/
from forestmodel.
EDIT:
The problem occurs with factor and character variables when using coxph()
. Only the label of the numeric variable gets printed as you can see in the reprex
. All variable types work fine if you use other models (just checked glm). So changing factors back to character – which would already be tedious as factors are pretty standard in this kind of data analysis – doesn't solve it, as I first thought. I'd very much appreciate if you could implement the proper use of labels also for the coxph objects, as there is so far no convenient function that can display Hazard ratios in clear forest plots with labels. I formerly used survminer::ggforest
, but switched to forestmodel
in order to be able to use labels...
library(survival)
library(dplyr)
library(forestmodel)
surv_data <- tibble(
time = abs(rnorm(300, 50, 30)),
event = sample(c(0,1), 300, prob = c(0.8, 0.2), replace = TRUE),
gender = sample(c(0,1), 300, prob = c(0.6, 0.4), replace = TRUE),
rx = sample(c("no","yes"), 300, prob = c(0.5, 0.5), replace = TRUE),
gene = sample(c(0,1), 300, prob = c(0.9, 0.1), replace = TRUE)
)
surv_data <- surv_data %>%
mutate(gender = factor(gender, levels = c(0,1), labels = c("female", "male")))
labelled::var_label(surv_data) <- list(
gender = "Gender (f/m)", #this variable is a factor -> doesn't work!
rx = "Irradiation", # character -> label doesn't work!
gene = "Gene of Interest" # numeric -> label works...
)
labelled::var_label(surv_data) # checking that labels are assigned
#> $time
#> NULL
#>
#> $event
#> NULL
#>
#> $gender
#> [1] "Gender (f/m)"
#>
#> $rx
#> [1] "Irradiation"
#>
#> $gene
#> [1] "Gene of Interest"
lapply(surv_data, class) # showing variable classes
#> $time
#> [1] "numeric"
#>
#> $event
#> [1] "numeric"
#>
#> $gender
#> [1] "factor"
#>
#> $rx
#> [1] "character"
#>
#> $gene
#> [1] "numeric"
# printing the coxph model -> only label of numeric variable works
print(forest_model(coxph(formula = Surv(time, event) ~ gender + rx +
gene, data = surv_data)))
# ok it seems to be a specific problem of the coxph object -> labels get printed correctly
# with glm...
mod <- glm(gender ~ gene + rx, data = surv_data, family = binomial())
forest_model(mod, exponentiate = TRUE)
Created on 2021-04-23 by the reprex package (v0.3.0)
from forestmodel.
I would also love to have the coxph factor label bug fixed as it would save a lot of time in my work.
from forestmodel.
Related Issues (20)
- Bug in forest_rma
- covariates option in forest_model do not work HOT 2
- How to plot subgroup data? HOT 3
- A warning message from changing the text_size HOT 5
- Tibble deprecation warning: data_frame() -> tibble() HOT 1
- Is it easy to support variable weight using point size? HOT 4
- forest_model doesn't show interactions in Cox PH models HOT 1
- Forest plot of multiple regression models
- Overall P-Value for Variables with More than Two Levels HOT 6
- How to set the range of the x axis on the forest plot HOT 1
- Forestmodel no longer showing interaction terms in multivariable model HOT 1
- Formatting p-value
- Error in plot when infinite value warning in model HOT 5
- Error with person-period data
- Changing Default Font Family HOT 2
- Font family supplied via theme(text = ...) is not honored in plot headings
- Excluding Plot of estimate, only including confidence interval
- Use colors in forestmodel::forest_model
- please provide an example of panel_forest_model
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forestmodel.