normalisr {piecenorms} | R Documentation |
Creates a recommended classInt based on the type of distribution.
Creates a recommended classInt based on the type of distribution.
Creates a normalisr R6 class for recommending a classInt based on the shape of the distribution of the observed data
data
(numeric()
)
Original observations
outliers
(logical()
)
Logical vector indicating is observations are
outliers
quantiles
(numeric()
)
Vector of quantiles
fitted_distribution
(character()
)
Suggested distribution
normalisation
(character()
)
Recommended class interval style based on
distribution
breaks
(numeric()
)
Recommended breaks for classes
number_of_classes
(numeric()
)
Number of classes identified
normalised_data
(numeric()
)
Normalised values based on recommendations
polarity
(numeric(1)
)
Which direction should the normalisation occur
percentiles
(numeric()
)
Observation percentiles
fittedmodel
(character()
)
Fitted univariate model
model
(univariateML()
)
Fitted univariate model parameters
new()
Creates a new instance of this R6 class.
Create a new normalisr object.
normalisr$new( x, polarity = 1, classint_preference = "jenks", num_classes = NULL, potential_distrs = c("unif", "power", "norm", "lnorm", "weibull", "pareto", "exp") )
x
A numeric vector of observations
polarity
Which direction should the normalisation occur, defaults to 1 but can either be:
1:: Lowest value is normalised to 0, highest value is normalised to 1
-1: Highest value is normalised to 0, lowest value is normalised to 1
classint_preference
Preference for classInt breaks
(see ?classInt::classIntervals
)
num_classes
Preference for number of classInt breaks,
defaults to Sturges number (see
?grDevices::nclass.Sturges
)
potential_distrs
The types of distributions to fit,
defaults to c("unif", "power", "norm", "lnorm", "weibull", "pareto", "exp")
A new normalisr
object.
print()
Prints the normalisr
normalisr$print()
plot()
Plots the normalised values against the original
normalisr$plot()
hist()
Histogram of normalised values against the original
normalisr$hist()
setManualBreaks()
Allows user to set manual breaks
normalisr$setManualBreaks(brks)
brks
User Defined Breaks
applyto()
Applies the normalisation model to new data
normalisr$applyto(x)
x
A numeric vector of observations
as.data.frame()
Returns a data frame of the normalisation
normalisr$as.data.frame()
clone()
The objects of this class are cloneable with this method.
normalisr$clone(deep = FALSE)
deep
Whether to make a deep clone.
set.seed(12345)
# Binary distribution test
x <- sample(c(0,1), 100, replace = TRUE)
y <- sample(c(0,1), 100, replace = TRUE)
mdl <- normalisr$new(x)
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)
# Uniform distribution test
x <- runif(100)
y <- runif(100)
mdl <- normalisr$new(x)
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)
# Normal distribution tests
x <- rnorm(100)
y <- rnorm(100)
mdl <- normalisr$new(x)
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)
# Lognormal distribution tests
x <- rlnorm(100)
y <- rlnorm(100)
mdl <- normalisr$new(x)
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)
# Lognormal distribution tests with 5 classes
x <- rlnorm(100)
y <- rlnorm(100)
mdl <- normalisr$new(x, num_classes = 5)
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)
# Exponential distribution test
x <- exp(1:100)
y <- exp(1:100)
mdl <- normalisr$new(x)
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)
# Poisson distribution test
x <- rpois(100, lambda = 0.5)
y <- rpois(100, lambda = 0.5)
mdl <- normalisr$new(x)
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)
# Weibull distribution test
x <- rweibull(100, shape = 0.5)
y <- rweibull(100, shape = 0.5)
mdl <- normalisr$new(x)
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)
# Set user defined breaks
mdl$setManualBreaks(c(5,10))
print(mdl)
mdl$plot()
mdl$hist()
head(mdl$as.data.frame())
mdl$applyto(y)