-
-
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
find_formula
fails when applied to lme
inside lapply
#658
Comments
Maybe solvable changing Lines 1198 to 1200 in 6fdc601
with formula(x$terms) ?
|
ok, but can we deal with random effects then? library(insight)
library(nlme)
models <-lapply(c("", " + Sex"), \(.x) lme(as.formula(paste0("distance ~ age", .x)), random = ~ 1, data = Orthodont))
lapply(models, function(i) formula(i$terms))
#> [[1]]
#> distance ~ age
#> <environment: 0x0000021eb3dc7010>
#>
#> [[2]]
#> distance ~ age + Sex
#> <environment: 0x0000021eb68257f0>
find_formula(models[[]])
#> $conditional
#> list()
#> <environment: 0x0000021eb70a1520>
#>
#> attr(,"class")
#> [1] "insight_formula" "list"
m2 <- lme(distance ~ age, random = ~ 1, data = Orthodont)
find_formula(m2)
#> $conditional
#> distance ~ age
#> <environment: 0x0000021eb745e998>
#>
#> $random
#> ~1
#> <environment: 0x0000021eb745e998>
#>
#> attr(,"class")
#> [1] "insight_formula" "list" Created on 2022-10-06 with reprex v2.0.2 |
@strengejacke I don't see your point. I only modify the fixed effects part of |
One question is: if the random part is something like |
Ah ok, didn't test with the PR. |
@vincentarelbundock library(insight)
library(nlme)
models <-lapply(c("", " + Sex"), \(.x) lme(as.formula(paste0("distance ~ age", .x)), random = ~ Sex, data = Orthodont))
find_formula(models[[1]])
$conditional
distance ~ age
<environment: 0x55a163099e58>
$random
~Sex
<environment: 0x55a163aea038>
attr(,"class")
[1] "insight_formula" "list" In this case, it seems to work. I may try some more complex example. |
Great! But I bet the code breaks if the lapply modifies the random component instead of the fixed. Is that a big deal? |
I am not sure what do you mean, but maybe you refer if I use the |
I close the issue, since th PR to solve the fixed effects part was merged and I do not see there is any chance to solve the random effects part as described in previous comments above. |
thanks, we can always open a new issue if needed. |
I come here from vincentarelbundock/modelsummary#559.
I adapt the reprex
I would say that this seems to be a duplicate of issue #309, but next line works
Thanks!
The text was updated successfully, but these errors were encountered: