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

Fix calculations in D3() for calculating likelihood ratio tests #228

Merged
merged 1 commit into from
Apr 13, 2020

Conversation

raselbw
Copy link
Contributor

@raselbw raselbw commented Apr 9, 2020

Simply, first, calculate the value of the log-likelihood functions for the full model and for the restricted model. Then, determine the average of the likelihood ratio tests. Please note that the existing D3() function gives incorrect results.

Simply, first, calculate the value of the log-likelihood functions for the full model and for the restricted model. Then, determine the average of the likelihood ratio tests. Please note that, the existing D3() function gives incorrect results.
@stefvanbuuren stefvanbuuren changed the title A major change in calculating likelihood ratio tests Fix calculations in D3() for calculating likelihood ratio tests Apr 13, 2020
@stefvanbuuren
Copy link
Member

Dear Rasel, thanks for your contribution.

It seems that there is an error in D3(), which indeed needs to be fixed. The problem and your solution is related to #226. I will study your fix, and get back to you.

Best, Stef.

@stefvanbuuren
Copy link
Member

We need some additional testing to see whether D3 is now correct.

Commit 15f3dd1 adds lines from #226 to tests/testthat/test-D3.R. For complete lrlmtest::lrtest, mitml::testModels and mice::D3 now produce the same value for the test statistic, which is good progress.

I am still uncertain about the discrepancies between mitml::testModels and mice::D3 for multiply imputated data. File tests/testthat/test-D3.R contains four (outcommented) tests that fail. It would be reassuring to know where the differences stem from, and which version should be preferred.

@raselbw
Copy link
Contributor Author

raselbw commented Apr 13, 2020

In mice::D3, from the m repetitions of the full (or null) models, it calculates the mean of the estimates of the (fixed) parameter coefficients, B-HAT, and then for each imputed dataset, it calculates the likelihood for the model with the parameters constrained to B-HAT.

In mitml::testModels, from the m repetitions of the full (or null) models, it calculates the mean of the estimates of both the (fixed) coefficients, B-HAT, and the variance component, SIGMA^2, and then for each imputed dataset, it calculates the likelihood for the model with the parameters constrained to (B-HAT, SIGMA^2).

Though the results are not very different for non-mixed models, I wonder which one is more appropriate.

@stefvanbuuren
Copy link
Member

Rasel,

I contacted Simon Grund, the author of mitml, on his thoughts about calculating the LR test, especially for multilevel data.

He prefers to be able to fix the variance components in multilevel models. The mitml package contains dedicated methods for doing this for selected multilevel models.

The mice::D3() function relies on the standard update for statistical models in R, and thus should work for a wider range of models. A post of Ben Bolker shows how to fix variances in lmer, but it's too complex and too specific to incorporate this into the generic mice::fix.coef() workhorse.

I therefore leave mice::fix.coef() as it currently is. The documentation of D3() explains why the LR results differ between mitml and mice. In the future, it may become easier to constrain variance component, so perhaps then we might use it. Users interested in the technical details, consults Bolker's FAQ.

Thanks for your contribution.

@stefvanbuuren stefvanbuuren merged commit d94769a into amices:master Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants