strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
606 stars 91 forks source link

tab_model(mod, show.re.var=TRUE) while not recomputing model #697

Open dylangomes opened 3 years ago

dylangomes commented 3 years ago

When using tab_model on a large model, it recomputes the model with stats::update().

Ben Bolker showed me that this can be turned off with tab_model(mod, show.r2=FALSE, show.icc=FALSE, show.re.var=FALSE) but suggests that theoretically show.re.var could be TRUE without recomputing the model (see: https://stackoverflow.com/a/64344513/9096420).

Is it possible to add re.var without recomputing the model?

strengejacke commented 3 years ago

No, currently not, any of show.re.var, show.icc or show.r2 will call insight::get_variance() (however, only once to save computation time). Calculation of ICC and R2 in mixed models in based on the random effects variances returned by insight::get_variance(), so you can't avoid that.

And according to Nakagawa et al., the log-approximation, which is needed for models with other families than Gaussian to approximate the residual variance, requires the mean value of the response of the null-model.

I could probably speed-up this a bit if I only rely on the information on random effects provided by summary().