distribution_metrics | R Documentation |
These are simple distribution metric functions.
se(x, na.rm = getOption("na.rm", FALSE))
ci(x, level = 0.95, na.rm = getOption("na.rm", FALSE))
sum_of_squares(x, correct_mean = TRUE, na.rm = getOption("na.rm", FALSE))
cv(x, na.rm = getOption("na.rm", FALSE))
cqv(x, na.rm = getOption("na.rm", FALSE))
mse(actual, predicted, na.rm = getOption("na.rm", FALSE))
mape(actual, predicted, na.rm = getOption("na.rm", FALSE))
rmse(actual, predicted, na.rm = getOption("na.rm", FALSE))
mae(actual, predicted, na.rm = getOption("na.rm", FALSE))
z_score(x, na.rm = getOption("na.rm", FALSE))
midhinge(x, na.rm = getOption("na.rm", FALSE))
ewma(x, lambda, na.rm = getOption("na.rm", FALSE))
rr_ewma(x, lambda, na.rm = getOption("na.rm", FALSE))
normalise(n, n_ref, per = 1000)
normalize(n, n_ref, per = 1000)
scale_sd(x)
centre_mean(x)
percentiles(x, na.rm = getOption("na.rm", FALSE))
deciles(x, na.rm = getOption("na.rm", FALSE))
x |
values |
na.rm |
a logical to indicate whether empty must be removed from |
level |
alpha level, defaults to 95% |
correct_mean |
with |
actual |
Vector of actual values |
predicted |
Vector of predicted values |
lambda |
smoothing parameter, a value between 0 and 1. A value of 0 is equal to |
n |
number to be normalised |
n_ref |
reference to use for normalisation |
per |
normalisation factor |
These are the explanations of the functions:
se()
calculates the standard error: sd / square root of length
ci()
calculates the confidence intervals for a mean (defaults at 95%), which returns length 2
sum_of_squares()
calculates the sum of (x - mean(x)) ^ 2
cv()
calculates the coefficient of variation: standard deviation / mean
cqv()
calculates the coefficient of quartile variation: (Q3 - Q1) / (Q3 + Q1)
mse()
calculates the mean squared error
mape()
calculates the mean absolute percentage error
rmse()
calculates the root mean squared error
mae()
calculates the mean absolute error
z_score()
calculates the number of standard deviations from the mean: (x - mean) / sd
midhinge()
calculates the mean of interquartile range: (Q1 + Q3) / 2
ewma()
calculates the EWMA (exponentially weighted moving average)
rr_ewma()
calculates the rrEWMA (reversed-recombined exponentially weighted moving average)
normalise()
normalises the data based on a reference: (n / reference) * unit
scale_sd()
normalises the data to have a standard deviation of 1, while retaining the mean
centre_mean()
normalises the data to have a mean of 0, while retaining the standard deviation
percentiles()
and deciles()
take a numeric vector as input, and return the lowest percentiles or deciles for each value
na.rm
This 'certestats' package supports a global default setting for na.rm
in many mathematical functions. This can be set with options(na.rm = TRUE)
or options(na.rm = FALSE)
.
For normality()
, quantile()
and IQR()
, this also applies to the type
argument. The default, type = 7
, is the default of base R. Use type = 6
to comply with SPSS.
For the sum of squares: https://www.thoughtco.com/sum-of-squares-formula-shortcut-3126266
x <- c(0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6)
percentiles(x)
deciles(x)
percentiles(rnorm(10))
library(dplyr, warn.conflicts = FALSE)
tib <- as_tibble(matrix(as.integer(runif(40, min = 1, max = 7)), ncol = 4),
.name_repair = function(...) LETTERS[1:4])
tib
# percentiles per column
tib |> mutate_all(percentiles)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.