Accuracy Function - R Documentation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

accuracy function | R Documentation https://www.rdocumentation.org/packages/rcompanion/versions/2.3.25/t...

accuracy(fits, plotit = TRUE, digits = 3, ...)

TRUE

plot

MAE = mean(abs(predy - actual))

1 of 3 4/12/2020, 4:45 AM
accuracy function | R Documentation https://www.rdocumentation.org/packages/rcompanion/versions/2.3.25/t...

lm

compareLM compareGLM nagelkerke

# NOT RUN {
data(BrendonSmall)
BrendonSmall$Calories = as.numeric(BrendonSmall$Calories)
BrendonSmall$Calories2 = BrendonSmall$Calories ^ 2
model.1 = lm(Sodium ~ Calories, data = BrendonSmall)
model.2 = lm(Sodium ~ Calories + Calories2, data = BrendonSmall)
model.3 = glm(Sodium ~ Calories, data = BrendonSmall, family="Gamma")
quadplat = function(x, a, b, clx) {
ifelse(x < clx, a + b * x + (-0.5*b/clx) * x * x,
a + b * clx + (-0.5*b/clx) * clx * clx)}
model.4 = nls(Sodium ~ quadplat(Calories, a, b, clx),
data = BrendonSmall,
start = list(a=519, b=0.359, clx = 2300))
accuracy(list(model.1, model.2, model.3, model.4), plotit=FALSE)

### Perfect and poor model fits


X = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
Y = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)

2 of 3 4/12/2020, 4:45 AM
accuracy function | R Documentation https://www.rdocumentation.org/packages/rcompanion/versions/2.3.25/t...

Z = c(1, 12, 13, 6, 10, 13, 4, 3, 5, 6, 10, 14)


perfect = lm(Y ~ X)
poor = lm(Z ~ X)
accuracy(list(perfect, poor), plotit=FALSE)

# }

3 of 3 4/12/2020, 4:45 AM

You might also like