mkshaw / r2mlm

r2mlm: R Package for Calculating R-Squared in Multilevel Models
27 stars 1 forks source link

Error in variance == 0 when a group only has n of 1. #26

Closed mkshaw closed 3 years ago

mhimmelstein commented 3 years ago

I had come here to raise having run into this issue. It looks like the solution has been found, but not pushed out yet, is that correct (I checked the development version too)?

I was able to tweak the function code for r2mlm_lmer() as a hack to get it to work, but I'm using this to teach an HLM class and don't know if I can have my students do that independently.

Thanks for the awesome package!

mkshaw commented 3 years ago

Hello! That's correct: I think I've fixed it, but haven't uploaded the fixed version to CRAN (since I'm also trying to fix other bugs before I release a new version). I also haven't pushed to the main branch on github; it's on the refactoring branch. When you say you checked the development version, do you mean you tried with the devtools::install_github("mkshaw/r2mlm", ref = "refactoring") version of the package and you still ran into an issue?

Exciting to hear you're thinking about incorporating the package into your HLM class!

mhimmelstein commented 3 years ago

Ah, that makes sense. I just used the main development branch, not ref = "refactoring". I can try that too. Thank you!

And we already did incorporate it! I'm the lab instructor/TA and the primary instructor wanted to teach the Rights and Sterba papers for how to think about HLM effect sizes. We actually started using it a bit right before you pushed it to CRAN :). It's been super helpful for producing tangible examples.

mkshaw commented 3 years ago

Let me know how the ref = "refactoring" goes, and I'm really glad it's been helpful so far (bugs notwithstanding)!

mhimmelstein commented 3 years ago

I checked the refactoring branch, and the base r2mlm() function does indeed work, but the bug is still present in r2mlm_comp()

mkshaw commented 3 years ago

This is actually great news! I haven't fixed r2mlm_comp() yet, so I would expect it to not work.

mhimmelstein commented 3 years ago

Great! I'll keep an eye out for when the next update pushes out. Thanks again for all the hard work!

mkshaw commented 3 years ago

Fixed in 2bb041a8fcfea37576620f3d3d1492031d2818f6.