bcjaeger / r2glmm

An R package for computation of model R squared and semi-partial R squared (with confidence limits) in linear and generalized linear mixed models
16 stars 9 forks source link

error in r2beta function when using covariates with missing data using GLM #11

Closed ChanceyMac closed 3 years ago

ChanceyMac commented 3 years ago

Hi, Thanks for a great package, the 'sgv' method with partial R2 is a useful option. I noticed today, a similar issue to that raised by Gscorreia89 on 31 Jul 2018 (#6), but for GLM. r2glmm(partial = TRUE) does not work for GLMs fit in lme4 with incomplete cases, regardless of the R2 method (or model error family). At some point, the number of replacement rows does not match that in the data. I realize the main drive of the package is for GLMM and I am not sure if there are additional technical issues that make it inappropriate to use partial R2 for GLMs but thought I'd raise the issue. Thanks

bcjaeger commented 3 years ago

Thanks! glm() and other model functions will drop any row with missing values from the data before proceeding with whatever modelling procedures they do. Have you tried using na.omit() or drop_na() on the data you are modelling? That may fix the issue with r2beta()

ChanceyMac commented 3 years ago

Thanks, r2beta() works for glm() on data with missing values when drop_na(data) is used before modeling.

bcjaeger commented 3 years ago

Great! Thanks for letting me know and closing the issue.