Comments (9)
I have done a quick diagnosis using the CRAN version of cosphf
and I have identified two issues that should be reported to the coxphf
team and handled directly in their package.
- It seems that
coxphf()
fail in case of missing values (wich is the case for the age variable). The function works if missing values are removed before callingcoxphf()
. To be consistent with other package, missing values should be managed directly by the package. - The package includes a tidier but it seems that the method is not properly declared. If you call
broom::tidy()
, the coxphf tidier is not used and the function failed. You need to use specifically thecoxphf::tidy.coxphf()
tidier and to pass it explicitly tobroom.helpers
orgtsummary
If you remove missing values and if you indicate the proper tidier, everything seems to work correctly.
library(coxphf)
library(broom.helpers)
library(survival)
library(gtsummary)
#> #Uighur
#>
#> Attachement du package : 'gtsummary'
#> L'objet suivant est masqué depuis 'package:broom.helpers':
#>
#> all_continuous
library(tidyverse)
df <- gtsummary::trial
mod <- coxphf(
Surv(ttdeath, death) ~ age + grade,
data = df
)
#> Error in cbind(obj$mm1, obj$timedata): le nombre de lignes des matrices doit correspondre (voir argument 2)
df <- df |> tidyr::drop_na(age, grade)
mod <- coxphf(
Surv(ttdeath, death) ~ age + grade,
data = df
)
broom::tidy(mod)
#> coxphf(formula = Surv(ttdeath, death) ~ age + grade, data = df)
#>
#> Model fitted by Penalized ML
#> Confidence intervals and p-values by Profile Likelihood
#>
#> coef se(coef) exp(coef) lower 0.95 upper 0.95 Chisq
#> age 0.006553054 0.007024429 1.006575 0.9928443 1.020559 0.8727594
#> gradeII 0.179710038 0.253931543 1.196870 0.7284027 1.966637 0.5074864
#> gradeIII 0.582291957 0.238403535 1.790137 1.1288125 2.866911 6.1274020
#> p
#> age 0.35019253
#> gradeII 0.47622901
#> gradeIII 0.01331023
#>
#> Likelihood ratio test=7.323796 on 3 df, p=0.06226301, n=189
#> Wald test = 7.377032 on 3 df, p = 0.06080364
#>
#> Covariance-Matrix:
#> age gradeII gradeIII
#> age 4.934260e-05 -4.848146e-05 -2.820656e-05
#> gradeII -4.848146e-05 6.448123e-02 3.224237e-02
#> gradeIII -2.820656e-05 3.224237e-02 5.683625e-02
#> Error in co[, -2, drop = FALSE]: nombre de dimensions incorrect
tidy.coxphf(mod)
#> # A tibble: 3 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 age 0.00655 0.00702 0.873 0.350
#> 2 gradeII 0.180 0.254 0.507 0.476
#> 3 gradeIII 0.582 0.238 6.13 0.0133
tidy_plus_plus(mod, tidy_fun = tidy.coxphf)
#> # A tibble: 4 × 19
#> term variable var_label var_class var_type var_nlevels contrasts
#> <chr> <chr> <chr> <chr> <chr> <int> <chr>
#> 1 age age Age numeric continuous NA <NA>
#> 2 gradeI grade Grade factor categorical 3 contr.treatment
#> 3 gradeII grade Grade factor categorical 3 contr.treatment
#> 4 gradeIII grade Grade factor categorical 3 contr.treatment
#> # ℹ 12 more variables: contrasts_type <chr>, reference_row <lgl>, label <chr>,
#> # n_obs <dbl>, n_event <dbl>, exposure <dbl>, estimate <dbl>,
#> # std.error <dbl>, statistic <dbl>, p.value <dbl>, conf.low <dbl>,
#> # conf.high <dbl>
tbl_regression(mod, tidy_fun = coxphf::tidy.coxphf, exponentiate = TRUE) |>
as_kable()
Characteristic | HR | 95% CI | p-value |
---|---|---|---|
Age | 1.01 | 0.99, 1.02 | 0.4 |
Grade | |||
I | — | — | |
II | 1.20 | 0.73, 1.97 | 0.5 |
III | 1.79 | 1.12, 2.86 | 0.013 |
df |>
select(death, ttdeath, age, grade) |>
tbl_uvregression(
method = coxphf,
y = Surv(ttdeath, death),
exponentiate = TRUE,
tidy_fun = coxphf::tidy.coxphf
) |>
add_nevent() |>
as_kable()
Characteristic | N | Event N | HR | 95% CI | p-value |
---|---|---|---|---|---|
Age | 189 | 103 | 1.01 | 0.99, 1.02 | 0.3 |
Grade | 189 | 103 | |||
I | — | — | |||
II | 1.21 | 0.73, 1.98 | 0.5 | ||
III | 1.80 | 1.13, 2.87 | 0.013 |
Created on 2023-10-08 with reprex v2.0.2
from broom.helpers.
Thank you very much for your help!
When I run this code:
gtsummary::trial %>%
select(ttdeath, death, age, grade) %>%
drop_na(age, grade) %>%
tbl_uvregression(
method = coxphf,
y = Surv(ttdeath, death),
exponentiate = TRUE,
tidy_fun = coxphf::tidy.coxphf
) %>%
add_nevent()
I get the following error:
Error: 'tidy.coxphf' is not an exported object from 'namespace:coxphf'
Would you be able to help me with this?
from broom.helpers.
Are you using cran version or dev version of coxphf?
from broom.helpers.
I believe I am using the CRAN version, installed with install.packages ('coxphf').
from broom.helpers.
Regarding CRAN version, tidy.coxphf()
is an exported object. cf. https://cran.r-project.org/web/packages/coxphf/coxphf.pdf
It seems to be still the case with the dev version, cf. https://github.com/georgheinze/coxphf/blob/master/R/coxphf-tidiers.R
Could you try to reinstall the package?
from broom.helpers.
Hello,
I re-installed the package as follows:
> install.packages("coxphf")
Warning in install.packages :
lzma decoder corrupt data
There is a binary version available but the source version is later:
binary source needs_compilation
coxphf 1.13.1 1.13.4 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘coxphf’
trying URL 'https://cran.rstudio.com/src/contrib/coxphf_1.13.4.tar.gz'
Content type 'application/x-gzip' length 30421 bytes (29 KB)
==================================================
downloaded 29 KB
* installing *source* package ‘coxphf’ ...
** package ‘coxphf’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -mmacosx-version-min=10.13 -fno-optimize-sibling-calls -fPIC -Wall -g -O2 -c coxphf.f90 -o coxphf.o
make: gfortran: No such file or directory
make: *** [coxphf.o] Error 1
ERROR: compilation failed for package ‘coxphf’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/coxphf’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/coxphf’
Warning in install.packages :
installation of package ‘coxphf’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/6h/lb103m897q14p9dv7t7__9qh0000gn/T/RtmpXyzlTO/downloaded_packages’
And still get the same error. When I do ?tidy.coxphf() I also get the response:
No documentation for ‘tidy.coxphf’ in specified packages and libraries:
you could try ‘??tidy.coxphf’
When I try to use your example and call:
tidy.coxphf(mod)
I get the error:
Error in tidy.coxphf(mod) : could not find function "tidy.coxphf"
Do you know what else I could try? Thank you!
from broom.helpers.
The installation failed. See the error message.
Restart R and re install the package before charging anything in memory
from broom.helpers.
You could also try to update R to version 4.2
from broom.helpers.
Got it, it works now! Thank you very much for all your help!
from broom.helpers.
Related Issues (20)
- Bug fixes and improvements for mixed models HOT 1
- tbl_regression (package gtsummary) and ggcoef_model (package ggstats) not working on the output of a replicate svyglm model HOT 2
- fantastic support of multivariate quantile regression for any quantile HOT 1
- Support for survival::cch model? HOT 5
- Avg_comparisons and nlme::lme() models HOT 1
- order of variable levels with marginal tidiers HOT 8
- Release broom.helpers 1.15.0
- Take into account (id) when computing model_get_n() for coxph models
- `marginaleffects::datagridcf()` is deprecated
- Do you know the status of the {margins} pkg? HOT 3
- Explore better support of VGAM::vglm() models HOT 1
- Execution time HOT 4
- marginaleffects::datagridcf() is deprecated
- pkgdown site has no search facility HOT 1
- Speed improvement when _parameters_ package is used HOT 2
- `tidy_multgee` Incorrectly Defines Values in `y.levels` for Nominal Logistic Regression HOT 1
- Using native pipe for speed improvement? HOT 1
- Check if variable labels are passed for a polynomial continuous terms HOT 1
- Release broom.helpers 1.16.0
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 broom.helpers.