Skip to content
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_ and get_ methods with models of multiple formula components like clm() & lme() #729

Merged
merged 6 commits into from
Mar 12, 2023

Conversation

strengejacke
Copy link
Member

Fixes #727

@strengejacke strengejacke merged commit 8b627fe into main Mar 12, 2023
@strengejacke strengejacke deleted the strengejacke/issue727 branch March 12, 2023 21:13
@vincentarelbundock
Copy link
Contributor

@strengejacke, nlme::lme() are kind of weird with the indexing, and I don’t know them well enough to say exactly what the best strategy is. But there are still some issues. For example, consider this model from the nlme docs:

library(nlme)
library(insight)
model <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)

dat <- get_data(model)

head(Orthodont)
# Grouped Data: distance ~ age | Subject
#   distance age Subject  Sex
# 1     26.0   8     M01 Male
# 2     25.0  10     M01 Male
# 3     29.0  12     M01 Male
# 4     31.0  14     M01 Male
# 5     21.5   8     M02 Male
# 6     22.5  10     M02 Male

head(dat)
#   distance age  Sex
# 1     26.0   8 Male
# 2     25.0  10 Male
# 3     29.0  12 Male
# 4     31.0  14 Male
# 5     21.5   8 Male
# 6     22.5  10 Male

predict(model, newdata = dat)
# Error in predict.lme(model, newdata = dat): cannot evaluate groups for desired levels on 'newdata'

Which fails because get_data does not retrieve the Subject column, which is required for the random effects, even though it is not explicitly given to random=~1

@strengejacke
Copy link
Member Author

ok, that issue should be fixed (wait for commit, I'm, fixing tests). Can you then please check this example?

  # from easystats/insight/482
  cr <- corAR1(form = ~ 1 | Mare)
  m4 <- lme(follicles ~ Time, Ovary, correlation = cr)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

find_ and get_ methods with models of multiple formula components like clm() & lme()
2 participants