Learn R Programming

nlraa (version 1.2)

R2M: R-squared for nonlinear mixed models

Description

R-squared ‘modified’ for nonlinear (mixed) models

Usage

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, ...)

Value

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

Arguments

x

object of class ‘lm’, ‘nls’, ‘gls’, ‘gnls’, ‘lme’ or ‘nlme’ .

...

additional arguments (none use at the moment).

Details

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

https://blog.minitab.com/en/adventures-in-statistics-2/why-is-there-no-r-squared-for-nonlinear-regression

https://stats.stackexchange.com/questions/111150/calculating-r2-in-mixed-models-using-nakagawa-schielzeths-2013-r2glmm-me/225334#225334

See Also

IA_tab

Examples

Run this code
# \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