Last chance! 50% off unlimited learning
Sale ends in
R-squared ‘modified’ for nonlinear (mixed) models
R2M(x, ...)# S3 method for nls
R2M(x, ...)
# S3 method for lm
R2M(x, ...)
# S3 method for gls
R2M(x, ...)
# S3 method for gnls
R2M(x, ...)
# S3 method for lme
R2M(x, ...)
# S3 method for nlme
R2M(x, ...)
it returns a list with the following structure:
for an object of class ‘lm’, ‘nls’, ‘gls’ or ‘gnls’,
R2: R-squared
var.comp: variance components with var.fixed and var.resid
var.perc: variance components percents (should add up to 100)
for an object of class ‘lme’ or ‘nlme’ in addition it also returns:
R2.marginal: marginal R2 which only includes the fixed effects
R2.conditional: conditional R2 which includes both the fixed and random effects
var.random: the variance contribution of the random effects
object of class ‘lm’, ‘nls’, ‘gls’, ‘gnls’, ‘lme’ or ‘nlme’ .
additional arguments (none use at the moment).
I have read some papers about computing an R-squared for (non)linear (mixed) models
and I am not sure that it makes sense at all. However, here they are and
the method is general enough that it extends to nonlinear mixed models. What do
these numbers mean and why would you want to compute them are good questions to
ponder...
Recommended reading:
Nakagawa and Schielzeth Methods in Ecology and Evolution tools:::Rd_expr_doi("10.1111/j.2041-210x.2012.00261.x")
https://stats.oarc.ucla.edu/other/mult-pkg/faq/general/faq-what-are-pseudo-r-squareds/
Spiess, AN., Neumeyer, N. An evaluation of R2 as an inadequate measure for nonlinear models in
pharmacological and biochemical research: a Monte Carlo approach. BMC Pharmacol 10, 6 (2010).
tools:::Rd_expr_doi("10.1186/1471-2210-10-6")
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2010q1/003363.html
Other R pacakges which calculate some version of an R-squared: performance, rcompanion, MuMIn
IA_tab
# \donttest{
require(nlme)
data(barley, package = "nlraa")
fit2 <- lme(yield ~ NF + I(NF^2), random = ~ 1 | year, data = barley)
R2M(fit2)
## Nonlinear Mixed Model
barleyG <- groupedData(yield ~ NF | year, data = barley)
fit3L <- nlsLMList(yield ~ SSquadp3(NF, a, b, c), data = barleyG)
fit3 <- nlme(fit3L, random = pdDiag(a + b ~ 1))
R2M(fit3)
# }
Run the code above in your browser using DataLab