nagelR2 | R Documentation |
Nagelkerge's / Craig & Uhler's R2
nagelR2(likeNull, likeFull, n)
likeNull |
Likelihood (not log-likelihood) of the null model or an object of class |
likeFull |
Likelihood (not log-likelihood) of the "full" model or an object of class |
n |
Sample size. |
Numeric.
# create data
x <- 1:100
y <- 2 + 1.7 * x + rnorm(100, 0, 30)
# models
nullModel <- lm(y ~ 1)
fullModel <- lm(y ~ x)
# plot
plot(x, y)
abline(nullModel, col='red')
abline(fullModel, col='blue')
legend('bottomright', legend=c('Null', 'Full'), lwd=1, col=c('red', 'blue'))
# R2
likeNull <- exp(as.numeric(logLik(nullModel)))
likeFull <- exp(as.numeric(logLik(fullModel)))
nagelR2(likeNull, likeFull, 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.