r.squaredLR | R Documentation |

Calculate a coefficient of determination based on the likelihood-ratio test
(`R_{LR}^{2}`

).

```
r.squaredLR(object, null = NULL, null.RE = FALSE, ...)
null.fit(object, evaluate = FALSE, RE.keep = FALSE, envir = NULL, ...)
```

`object` |
a fitted model object. |

`null` |
a fitted |

`null.RE` |
logical, should the null model contain random factors? Only
used if no |

`evaluate` |
if |

`RE.keep` |
if |

`envir` |
the environment in which the |

`...` |
further arguments, of which only |

This statistic is is one of the several proposed pseudo-`R^{2}`

's for
nonlinear regression models. It is based on an improvement from *null*
(intercept only) model to the fitted model, and calculated as

```
R_{LR}^{2}=1-\exp(-\frac{2}{n}(\log\mathcal{L}(x)-\log\mathcal{L}(0)))
```

where `\log\mathcal{L}(x)`

and `\log\mathcal{L}(0)`

are the log-likelihoods of the
fitted and the *null* model respectively.
ML estimates are used if models have been
fitted by REstricted ML (by calling `logLik`

with argument
`REML = FALSE`

). Note that the *null* model can include the random
factors of the original model, in which case the statistic represents the
‘variance explained’ by fixed effects.

For OLS models the value is consistent with classical `R^{2}`

. In some
cases (e.g. in logistic regression), the maximum `R_{LR}^{2}`

is less than one.
The modification proposed by Nagelkerke (1991) adjusts the `R_{LR}^{2}`

to achieve
1 at its maximum:
```
\bar{R}^{2} = R_{LR}^{2} / \max(R_{LR}^{2})
```

where
```
\max(R_{LR}^{2}) = 1 - \exp(\frac{2}{n}\log\mathcal{L}(\textrm{0}))
```

.

`null.fit`

tries to guess the *null* model call, given the provided
fitted model object. This would be usually a `glm`

. The function will give
an error for an unrecognised class.

`r.squaredLR`

returns a value of `R_{LR}^{2}`

, and the
attribute `"adj.r.squared"`

gives the Nagelkerke's modified statistic.
Note that this is not the same as nor equivalent to the classical
‘adjusted R squared’.

`null.fit`

returns the fitted *null* model object (if
`evaluate = TRUE`

) or an unevaluated call to fit a *null* model.

`R^{2}`

is a useful goodness-of-fit measure as it has the interpretation
of the proportion of the variance ‘explained’, but it performs poorly in
model selection, and is not suitable for use in the same way as the information
criteria.

Cox, D. R. and Snell, E. J. 1989 *The analysis of binary data*, 2nd ed.
London, Chapman and Hall.

Magee, L. 1990 `R^{2}`

measures based on Wald and likelihood ratio joint
significance tests. *Amer. Stat.* **44**, 250–253.

Nagelkerke, N. J. D. 1991 A note on a general definition of the coefficient of
determination. *Biometrika* **78**, 691–692.

`summary.lm`

, `r.squaredGLMM`

`r2`

from package performance calculates
many different types of `R^{2}`

.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.