| rel_diff | R Documentation |
Calculates the relative difference, defined as
\frac{\vert x - y \vert}{x}
between two arrays or data frames, where x are considered reference values.
rel_diff(x, y, pct = TRUE, epsilon = 10 * .Machine$double.eps)
x |
An array or data frame, considered the reference values |
y |
Comparison array or data frame |
pct |
Logical; if |
epsilon |
Threshold for values near zero |
Beyond the obvious, a natural use case is to compare coefficients for alternative models for the same data, e.g., a classical and a robust model.
An array or data frame the same size as x and y containing the relative differences
link{robmlm}
# simple example
m1 <- cbind(c(0,1), c(1,1))
m2 <- cbind(c(0,1), c(1.01,1.11))
rel_diff(m1, m2, pct = FALSE)
rel_diff(m1, m2)
# compare coefficients
data(Skulls)
# fit manova model, classically and robustly
sk.mlm <- lm(cbind(mb, bh, bl, nh) ~ epoch, data=Skulls)
sk.rlm <- robmlm(cbind(mb, bh, bl, nh) ~ epoch, data=Skulls)
rel_diff(coef(sk.mlm),
coef(sk.rlm))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.