-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_data.coxph
returns data without labels
#790
Comments
labels are not removed in general inside library(easystats)
#> # Attaching packages: easystats 0.6.0.10
#> ✔ bayestestR 0.13.1.2 ✔ correlation 0.8.4
#> ✔ datawizard 0.8.0.3 ✔ effectsize 0.8.3.11
#> ✔ insight 0.19.3 ✔ modelbased 0.8.6.3
#> ✔ performance 0.10.4.1 ✔ parameters 0.21.1.2
#> ✔ report 0.5.7.9 ✔ see 0.8.0.2
data(efc)
m <- lm(neg_c_7 ~ e42dep, data = efc)
str(get_data(m))
#> 'data.frame': 94 obs. of 2 variables:
#> $ neg_c_7: num 12 20 11 12 19 15 11 15 10 28 ...
#> ..- attr(*, "label")= chr "Negative impact with 7 items"
#> $ e42dep : Factor w/ 4 levels "1","2","3","4": 3 3 3 4 4 4 4 4 4 4 ...
#> ..- attr(*, "label")= chr "elder's dependency"
#> ..- attr(*, "labels")= Named num [1:4] 1 2 3 4
#> .. ..- attr(*, "names")= chr [1:4] "independent" "slightly dependent" "moderately dependent" "severely dependent"
str(get_data(m, source = "mf"))
#> 'data.frame': 94 obs. of 2 variables:
#> $ neg_c_7: num 12 20 11 12 19 15 11 15 10 28 ...
#> ..- attr(*, "label")= chr "Negative impact with 7 items"
#> $ e42dep : Factor w/ 4 levels "1","2","3","4": 3 3 3 4 4 4 4 4 4 4 ...
#> ..- attr(*, "labels")= Named num [1:4] 1 2 3 4
#> .. ..- attr(*, "names")= chr [1:4] "independent" "slightly dependent" "moderately dependent" "severely dependent"
#> ..- attr(*, "label")= chr "elder's dependency"
#> - attr(*, "terms")=Classes 'terms', 'formula' language neg_c_7 ~ e42dep
#> .. ..- attr(*, "variables")= language list(neg_c_7, e42dep)
#> .. ..- attr(*, "factors")= int [1:2, 1] 0 1
#> .. .. ..- attr(*, "dimnames")=List of 2
#> .. .. .. ..$ : chr [1:2] "neg_c_7" "e42dep"
#> .. .. .. ..$ : chr "e42dep"
#> .. ..- attr(*, "term.labels")= chr "e42dep"
#> .. ..- attr(*, "order")= int 1
#> .. ..- attr(*, "intercept")= int 1
#> .. ..- attr(*, "response")= int 1
#> .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>
#> .. ..- attr(*, "predvars")= language list(neg_c_7, e42dep)
#> .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "factor"
#> .. .. ..- attr(*, "names")= chr [1:2] "neg_c_7" "e42dep"
#> - attr(*, "na.action")= 'omit' Named int [1:6] 4 27 33 46 58 97
#> ..- attr(*, "names")= chr [1:6] "4" "27" "33" "46" ...
#> - attr(*, "is_subset")= logi FALSE Created on 2023-07-09 with reprex v2.0.2 |
I should remark that (called by For a minimal example: library(survival)
dat_regression_test <- data.frame(
time = c(4, 3, 1, 1, 2, 2, 3),
status = c(1, 1, 1, 0, 1, 1, 0),
x = c(0, 2, 1, 1, 1, 0, 0),
sex = c(0, 0, 0, 0, 1, 1, 1)
)
attr(dat_regression_test$x, "label") <- "Pred"
mod <- survival::coxph(Surv(time, status) ~ x + strata(sex),
data = dat_regression_test,
ties = "breslow"
)
str(get_data(mod, source = "mf"))
'data.frame': 7 obs. of 4 variables:
$ time : num 4 3 1 1 2 2 3
$ status: num 1 1 1 0 1 1 0
$ x : num 0 2 1 1 1 0 0
$ sex : num 0 0 0 0 1 1 1
- attr(*, "is_subset")= logi FALSE
For your example - attr(*, "pretty_labels")= Named chr [1:4] "(Intercept)" "elder's dependency [slightly dependent]" "elder's dependency [moderately dependent]" "elder's dependency [severely dependent] However, for - attr(*, "pretty_labels")= Named chr "x"
..- attr(*, "names")= chr "x" |
Maybe the issue is that when calling |
So, @strengejacke why in some of the |
The original idea of |
Yes, but that data isn't labelled, so no surprise here? |
@strengejacke The issue is that
Wrong, it is labelled, since previously I had done
|
get_data.coxph
returns data without labels. As a consequence, when used forparameters::parameters
, the attributepretty_labels
is not useful at all.Indeed, in the function
insight/R/get_data.R
Lines 1827 to 1852 in a95325c
the issue happens with
.prepare_get_data
, where labels are removed from variables.The text was updated successfully, but these errors were encountered: