Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
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

Fix bootstrap and simulation variance estimation for merMod models #117

Merged
merged 4 commits into from Dec 22, 2019

Conversation

@jacob-long
Copy link
Contributor

jacob-long commented Feb 18, 2019

Please ensure the following before submitting a PR:

  • if suggesting code changes or improvements, open an issue first

This would close #105.

  • for all but trivial changes (e.g., typo fixes), add your name to DESCRIPTION
  • for all but trivial changes (e.g., typo fixes), documentation your change in NEWS.md with a parenthetical reference to the issue number being addressed
  • if changing documentation, edit files in /R not /man and run devtools::document() to update documentation
  • add code or new test files to /tests for any new functionality or bug fix
  • make sure R CMD check runs without error before submitting the PR

For reference, here was the basic problem: The object manipulation done by get_effect_variances() doesn't work on S4 objects like merMod models. They aren't subset using [[, which is the most proximal cause of the error. These particular objects also have different names for the items the function is looking for. S4 objects also can impose object class restrictions for the internal list items, so things like setting the model frame to NULL can't work because lme4 insists that it be a data frame.

For the bootstrapping code, I was able to use a generalizable fix by just using the call extractor function and manipulating the call rather than the model itself, then evaluating the call and saving that as a temporary model. For the simulation, I had to do some merMod-specific control flow (i.e., doing some if (inherits(model, "merMod")) which is inelegant but I think better than trying to create an internal S3 method or something like that.

I should also draw your attention to the fact that for vce = "simulation", we're only simulating the fixed effects and not the random effects. I think this may be okay, and is certainly simpler, but I haven't thought deeply about the statistical theory behind leaving the random effects fixed and simulating only the fixed part of the model.

@leeper leeper added the enhancement label Dec 22, 2019
@leeper leeper merged commit b9ad25f into leeper:master Dec 22, 2019
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@leeper

This comment has been minimized.

Copy link
Owner

leeper commented Dec 22, 2019

Hey, this is cool. Thanks! Sorry for the delayed accept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.