| Title: | Histogram-Valued Data Analysis |
|---|---|
| Description: | In the framework of Symbolic Data Analysis, a relatively new approach to the statistical analysis of multi-valued data, we consider histogram-valued data, i.e., data described by univariate histograms. The methods and the basic statistics for histogram-valued data are mainly based on the L2 Wasserstein metric between distributions, i.e., the Euclidean metric between quantile functions. The package contains unsupervised classification techniques, least square regression and tools for histogram-valued data and for histogram time series. An introducing paper is Irpino A. Verde R. (2015) <doi: 10.1007/s11634-014-0176-4>. |
| Authors: | Antonio Irpino [aut, cre] (ORCID: <https://orcid.org/0000-0001-9293-7180>) |
| Maintainer: | Antonio Irpino <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0.10 |
| Built: | 2026-10-29 17:12:18 UTC |
| Source: | https://github.com/cran/HistDAWass |
Methods for the analysis of histogram-valued data, i.e. data described by univariate histograms, in the framework of Symbolic Data Analysis. The basic statistics and the methods are based on the L2 Wasserstein metric between distributions, i.e. the Euclidean metric between quantile functions.
distributionH: a histogram; data2hist builds
one from raw data.
MatH: a matrix of histograms (individuals by
histogram-valued variables).
HTS-class: a histogram time series.
Moments of a histogram (meanH, stdH,
skewH, kurtH), quantiles and cdf
(compQ, compP), the L2 Wasserstein distance
(WassSqDistH, WH_MAT_DIST), the mean histogram
(WH.vec.mean), variance-covariance and correlation matrices
(WH.var.covar).
Clustering: WH_kmeans, WH_adaptive.kmeans,
WH_fcmeans, WH_adaptive_fcmeans,
WH_hclust, Kohonen maps (WH_2d_Kohonen_maps,
WH_2d_Adaptive_Kohonen_maps).
Principal component analysis: WH.1d.PCA,
WH.MultiplePCA.
Regression: WH.regression.two.components.
Histogram time series: HTS.moving.averages,
HTS.exponential.smoothing, HTS.predict.knn.
Maintainer: Antonio Irpino [email protected] (ORCID)
Authors:
Antonio Irpino [email protected] (ORCID)
Irpino, A., Verde, R. (2015) Basic statistics for distributional symbolic variables: a new metric-based approach, Advances in Data Analysis and Classification, 9(2), 143-175. doi:10.1007/s11634-014-0176-4
Useful links:
# a matrix of four histograms (2 individuals x 2 variables) a <- list( distributionH(x = c(80, 100, 120, 135, 150, 165, 180, 200, 240), p = c(0, 0.025, 0.1, 0.275, 0.525, 0.725, 0.887, 0.975, 1)), distributionH(x = c(80, 100, 120, 135, 150, 165, 180, 195, 210, 240), p = c(0, 0.013, 0.101, 0.255, 0.508, 0.718, 0.895, 0.961, 0.987, 1)), distributionH(x = c(95, 110, 125, 140, 155, 170, 185, 200, 215, 230, 245), p = c(0, 0.012, 0.041, 0.154, 0.36, 0.595, 0.781, 0.929, 0.972, 0.992, 1)), distributionH(x = c(105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 260), p = c(0, 0.009, 0.035, 0.081, 0.186, 0.385, 0.633, 0.832, 0.932, 0.977, 1)) ) M <- MatH(x = a, nrows = 2, ncols = 2, rownames = c("u1", "u2"), varnames = c("Var_1", "Var_2")) M WH.vec.mean(M)# a matrix of four histograms (2 individuals x 2 variables) a <- list( distributionH(x = c(80, 100, 120, 135, 150, 165, 180, 200, 240), p = c(0, 0.025, 0.1, 0.275, 0.525, 0.725, 0.887, 0.975, 1)), distributionH(x = c(80, 100, 120, 135, 150, 165, 180, 195, 210, 240), p = c(0, 0.013, 0.101, 0.255, 0.508, 0.718, 0.895, 0.961, 0.987, 1)), distributionH(x = c(95, 110, 125, 140, 155, 170, 185, 200, 215, 230, 245), p = c(0, 0.012, 0.041, 0.154, 0.36, 0.595, 0.781, 0.929, 0.972, 0.992, 1)), distributionH(x = c(105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 260), p = c(0, 0.009, 0.035, 0.081, 0.186, 0.385, 0.633, 0.832, 0.932, 0.977, 1)) ) M <- MatH(x = a, nrows = 2, ncols = 2, rownames = c("u1", "u2"), varnames = c("Var_1", "Var_2")) M WH.vec.mean(M)
Distributions of the population by 5-year age classes (relative frequencies) for 228 countries and the World (first row): whole population, male and female population.
A MatH object with 229 rows (the World and 228 countries) and 3 columns:
Both.Sexes.Population, Male.Population, Female.Population.
United States Census Bureau, https://www.census.gov/data.html
get.MatH.main.info(Age_Pyramids_2014)get.MatH.main.info(Age_Pyramids_2014)
Distributions of the marginal costs of farms in 22 French regions.
A MatH object with 22 rows (regions) and 4 columns: Y_TSC (total costs of a
farm), X_Wheat (costs for wheat), X_Pig (costs for pigs),
X_Cmilk (costs for cow milk).
Verde, R., Irpino, A., Desbois, D. (2014). How to cope with modelling and privacy concerns? A regression model and a visualization tool for aggregated data, Conference of European Statistics Stakeholders, Rome.
AgronomiqueAgronomique
Sum, difference and product of distributionH objects and numbers,
consistent with the L2 Wasserstein metric: the operations are applied to the
quantile functions of the distributions.
e1 + e2: the sum of the quantile functions. A number is treated as
an impulse distribution, so x + a shifts x by a.
e1 - e2: the difference of the quantile functions. The difference
of two distributions is a distribution only if e1 is more variable
than e2 (the result must be a non-decreasing quantile function);
otherwise it may not be valid. x - a shifts x by -a.
a * x or x * a: the product of a distribution and a number,
i.e. the distribution of a times the random variable (for a < 0
the distribution is reflected). Similarly, a - x is the distribution
of a minus the random variable.
## S4 method for signature 'distributionH,distributionH' e1 + e2 ## S4 method for signature 'distributionH,distributionH' e1 - e2 ## S4 method for signature 'distributionH,distributionH' e1 * e2## S4 method for signature 'distributionH,distributionH' e1 + e2 ## S4 method for signature 'distributionH,distributionH' e1 - e2 ## S4 method for signature 'distributionH,distributionH' e1 * e2
e1, e2
|
Two |
A distributionH object.
d1 <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1)) d2 <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) d1 + d2 d2 + 10 2 * d1 d2 - d1d1 <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1)) d2 <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) d1 + d2 d2 + 10 2 * d1 d2 - d1
Histograms of cholesterol, hemoglobin and hematocrit for 14 groups of patients (by sex and age).
A MatH object with 14 rows (groups of patients) and 3 columns (variables).
Billard L. and Diday E. (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining, Wiley.
BLOOD plot(BLOOD)BLOOD plot(BLOOD)
Histograms of hematocrit and hemoglobin for 10 patients.
A MatH object with 10 rows (patients) and 2 columns (variables).
Dias, S. and Brito P. (2013). Distribution and Symmetric Distribution Regression Model for Histogram-Valued Variables, arXiv:1303.6199.
BloodBRITOBloodBRITO
Shifts each histogram of a MatH object so that its mean is zero.
Center.cell.MatH(object)Center.cell.MatH(object)
object |
A |
A MatH object whose histograms have zero mean.
CEN_BLOOD <- Center.cell.MatH(BLOOD) get.MatH.stats(CEN_BLOOD, stat = "mean")CEN_BLOOD <- Center.cell.MatH(BLOOD) get.MatH.stats(CEN_BLOOD, stat = "mean")
Checks for empty bins, i.e. bins with zero weight (two consecutive equal values
of the cdf). Each empty bin gets a weight of 1e-8 and the cdf is
renormalised. Since version 1.0.9 empty bins are fixed when a
distributionH object is created (see distributionH), so
this method is useful for objects created with previous versions of the
package or modified by assigning their slots directly. The MatH method
applies the check to all the cells of the matrix.
checkEmptyBins(object)checkEmptyBins(object)
object |
A |
An object of the same class of object, without empty bins.
## an empty bin in an object modified by slot assignment mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.5, 0.6, 1)) mydist@p <- c(0, 0.5, 0.5, 1) diff(checkEmptyBins(mydist)@p) ## all the distributions of a MatH newMat <- checkEmptyBins(China_Seas[1:5, 1:3])## an empty bin in an object modified by slot assignment mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.5, 0.6, 1)) mydist@p <- c(0, 0.5, 0.5, 1) diff(checkEmptyBins(mydist)@p) ## all the distributions of a MatH newMat <- checkEmptyBins(China_Seas[1:5, 1:3])
Distributions of 14 climatic variables observed in 60 stations of China in each month (168 histogram-valued variables).
A MatH object with 60 rows (stations) and 168 columns (14 variables x 12 months).
The 14 variables are: mean station pressure (mb), mean temperature, mean
maximum temperature, mean minimum temperature, total precipitation (mm),
sunshine duration (h), mean cloud amount (percentage of sky cover), mean
relative humidity (%), snow days (days with snow cover), dominant wind
direction (degrees), mean wind speed (m/s), dominant wind frequency (%),
extreme maximum temperature (C), extreme minimum temperature (C). The
coordinates of the stations are in stations_coordinates.
Climate Data Bases of the People's Republic of China 1841-1988 (TR055), doi:10.3334/CDIAC/cli.tr055
get.MatH.main.info(China_Month)$ncolsget.MatH.main.info(China_Month)$ncols
Distributions of 14 climatic variables observed in 60 stations of China in each season (56 histogram-valued variables).
A MatH object with 60 rows (stations) and 56 columns (14 variables x 4 seasons).
The 14 variables are: mean station pressure (mb), mean temperature, mean
maximum temperature, mean minimum temperature, total precipitation (mm),
sunshine duration (h), mean cloud amount (percentage of sky cover), mean
relative humidity (%), snow days (days with snow cover), dominant wind
direction (degrees), mean wind speed (m/s), dominant wind frequency (%),
extreme maximum temperature (C), extreme minimum temperature (C). The
coordinates of the stations are in stations_coordinates.
Climate Data Bases of the People's Republic of China 1841-1988 (TR055), doi:10.3334/CDIAC/cli.tr055
get.MatH.main.info(China_Seas)$ncolsget.MatH.main.info(China_Seas)$ncols
Computes the value of the cumulative distribution function of a
distributionH object.
compP(object, q)compP(object, q)
object |
A |
q |
A number. |
A number between 0 and 1.
mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) compP(mydist, 5)mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) compP(mydist, 5)
Computes the quantile of a distributionH object at a given level,
i.e. the value of its quantile function.
compQ(object, p)compQ(object, p)
object |
A |
p |
A number between 0 and 1. |
A number, the quantile of order p.
mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) compQ(mydist, 0.5) # the median compQ(mydist, 0) # the minimum compQ(mydist, 1) # the maximum compQ(mydist, 0.25) # the first quartilemydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) compQ(mydist, 0.5) # the median compQ(mydist, 0) # the minimum compQ(mydist, 1) # the maximum compQ(mydist, 0.25) # the first quartile
Computes the centre (midpoint), the radius (half-width) and the weight
(probability) of each bin of a distributionH object. This
representation allows a fast computation of the statistics based on the L2
Wasserstein distance.
crwtransform(object)crwtransform(object)
object |
A |
A list with three numeric vectors: Centers, the midpoints of
the bins; Radii, the half-widths of the bins; Weights, the
probabilities of the bins (summing to one).
Irpino, A., Verde, R., Lechevallier, Y. (2006) Dynamic clustering of histograms using Wasserstein metric, In: Proceedings of COMPSTAT 2006, Physica-Verlag, 869-876.
mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) crwtransform(mydist)mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) crwtransform(mydist)
Builds a distributionH object from a vector of numeric values, using
one of several algorithms for choosing the bins.
data2hist( data, algo = "histogram", type = "combined", qua = 10, breaks = numeric(0), epsilon = 0.01 )data2hist( data, algo = "histogram", type = "combined", qua = 10, breaks = numeric(0), epsilon = 0.01 )
data |
A numeric vector. |
algo |
The algorithm: |
type |
For |
qua |
For |
breaks |
For |
epsilon |
For |
A distributionH object. Empty bins (without observations) get a
weight of 1e-8.
data <- rnorm(n = 1000, mean = 2, sd = 3) mydist <- data2hist(data) plot(mydist) data2hist(data, algo = "FixedQuantiles", qua = 20)data <- rnorm(n = 1000, mean = 2, sd = 3) mydist <- data2hist(data) plot(mydist) data2hist(data, algo = "FixedQuantiles", qua = 20)
The distributionH class describes a histogram (a distribution) by means
of its cumulative distribution function (cdf): the bounds of the bins and the
values of the cdf at the bounds. All the methods of the package are based on
the L2 Wasserstein distance between distributions.
distributionH(x = numeric(0), p = numeric(0))distributionH(x = numeric(0), p = numeric(0))
x |
A numeric vector, the bounds of the bins, in non-decreasing order. A single value defines an impulse distribution. |
p |
A numeric vector of the same length of |
distributionH() returns a distributionH object.
xA non-decreasing numeric vector: the bounds of the bins (the domain of the distribution).
pA non-decreasing numeric vector of the same length of x, from 0
to 1: the cdf at the values in x.
mThe mean of the distribution.
sThe standard deviation of the distribution.
Objects are created with distributionH(x, p) or, equivalently, with
new("distributionH", x, p, m, s), where the optional m and
s (mean and standard deviation) are computed when not given.
Empty bins, i.e. bins with zero weight (two consecutive equal values in
p), may produce numerical problems. Since version 1.0.9 each empty bin
gets a weight of 1e-8 and the cdf is renormalised when the object is
created (see also checkEmptyBins).
Irpino, A., Verde, R. (2015) Basic statistics for distributional symbolic variables: a new metric-based approach, Advances in Data Analysis and Classification, 9(2), 143-175. doi:10.1007/s11634-014-0176-4
data2hist to build a histogram from raw data;
meanH, stdH, plot,distributionH-method.
# the histogram # | Bins | Prob | cdf | # | [1,2) | 0.4 | 0.4 | # | [2,3] | 0.6 | 1.0 | mydist <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1)) mydist str(mydist)# the histogram # | Bins | Prob | cdf | # | [1,2) | 0.4 | 0.4 | # | [2,3] | 0.6 | 1.0 | mydist <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1)) mydist str(mydist)
Computes the dot product, inducing the L2 Wasserstein metric, between two
distributionH objects, or between a distributionH and a number
(considered as an impulse distribution).
dotpW(e1, e2)dotpW(e1, e2)
e1, e2
|
Two |
A number.
Irpino, A., Verde, R. (2015) Basic statistics for distributional symbolic variables: a new metric-based approach, Advances in Data Analysis and Classification, 9(2), 143-175. doi:10.1007/s11634-014-0176-4
mydist1 <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) mydist2 <- distributionH(x = c(5, 7, 15), p = c(0, 0.7, 1)) dotpW(mydist1, mydist2) # 39.51429 dotpW(mydist1, 3) # 13.2 dotpW(3, mydist1) # 13.2mydist1 <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) mydist2 <- distributionH(x = c(5, 7, 15), p = c(0, 0.7, 1)) dotpW(mydist1, mydist2) # 39.51429 dotpW(mydist1, 3) # 13.2 dotpW(3, mydist1) # 13.2
Approximates a curve, given by a sequence of 2d points, with a polyline
(Ramer-Douglas-Peucker algorithm). It is used by data2hist with
algo = "PolyLine".
DouglasPeucker(points, epsilon)DouglasPeucker(points, epsilon)
points |
A two-column matrix with the coordinates of the points. |
epsilon |
A positive number, the tolerance of the approximation (recommended 0.01). |
A two-column matrix with the vertices of the polyline.
x <- seq(0, 1, length.out = 50) DouglasPeucker(cbind(x, x^2), epsilon = 0.01)x <- seq(0, 1, length.out = 50) DouglasPeucker(cbind(x, x^2), epsilon = 0.01)
Extracts rows and/or columns of a MatH object, as for an ordinary
matrix.
## S4 method for signature 'MatH,ANY,ANY,ANY' x[i, j, ..., drop = TRUE]## S4 method for signature 'MatH,ANY,ANY,ANY' x[i, j, ..., drop = TRUE]
x |
A |
i, j
|
Row and column indices (integers, names or logical vectors). |
... |
Not used. |
drop |
Not used (the result is always a |
A MatH object.
SUB_D <- BLOOD[c(1, 2, 5), c(1, 2)] SUB_DSUB_D <- BLOOD[c(1, 2, 5), c(1, 2)] SUB_D
get.cell.MatH returns the histogram in a cell of a MatH object;
set.cell.MatH assigns a histogram to a cell.
get.cell.MatH(object, r, c) set.cell.MatH(object, mat, r, c)get.cell.MatH(object, r, c) set.cell.MatH(object, mat, r, c)
object |
For |
r, c
|
Integers, the row and the column of the cell. |
mat |
A |
get.cell.MatH returns a distributionH object,
set.cell.MatH the modified MatH object.
get.cell.MatH(BLOOD, r = 1, c = 1) mydist <- distributionH(x = c(0, 1, 2, 3, 4), p = c(0, 0.1, 0.6, 0.9, 1)) MAT <- set.cell.MatH(mydist, BLOOD, r = 1, c = 1)get.cell.MatH(BLOOD, r = 1, c = 1) mydist <- distributionH(x = c(0, 1, 2, 3, 4), p = c(0, 0.1, 0.6, 0.9, 1)) MAT <- set.cell.MatH(mydist, BLOOD, r = 1, c = 1)
Returns the points of the cumulative distribution function (cdf) of a
distributionH object.
get.distr(object)get.distr(object)
object |
A |
A data.frame with two columns: x, the bounds of the
bins, and p, the values of the cdf at x.
D <- distributionH(x = c(1, 2, 3, 4), p = c(0, 0.2, 0.6, 1)) get.distr(D)D <- distributionH(x = c(1, 2, 3, 4), p = c(0, 0.2, 0.6, 1)) get.distr(D)
Returns the bins of a distributionH object and their probabilities.
get.histo(object)get.histo(object)
object |
A |
A data.frame with one row for each bin and three columns:
min.x and max.x, the bounds of the bin, and p, its
probability (relative frequency).
D <- distributionH(x = c(1, 2, 3, 4), p = c(0, 0.2, 0.6, 1)) get.histo(D)D <- distributionH(x = c(1, 2, 3, 4), p = c(0, 0.2, 0.6, 1)) get.histo(D)
Returns the mean stored in the m slot of a distributionH object.
To compute it from the distribution use meanH.
get.m(object)get.m(object)
object |
A |
A number, the mean of the distribution.
D <- distributionH(x = c(1, 2, 3, 4), p = c(0, 0.2, 0.6, 1)) get.m(D)D <- distributionH(x = c(1, 2, 3, 4), p = c(0, 0.2, 0.6, 1)) get.m(D)
Functions returning the number of rows and of columns, the names of the rows
(individuals) and of the columns (variables) of a MatH object.
get.MatH.nrows(object) get.MatH.ncols(object) get.MatH.rownames(object) get.MatH.varnames(object) get.MatH.main.info(object)get.MatH.nrows(object) get.MatH.ncols(object) get.MatH.rownames(object) get.MatH.varnames(object) get.MatH.main.info(object)
object |
A |
get.MatH.nrows and get.MatH.ncols return an integer;
get.MatH.rownames and get.MatH.varnames return a character
vector; get.MatH.main.info returns a list with all of them
(nrows, ncols, rownames, varnames).
get.MatH.nrows(BLOOD) get.MatH.ncols(BLOOD) get.MatH.rownames(BLOOD) get.MatH.varnames(BLOOD) get.MatH.main.info(BLOOD)get.MatH.nrows(BLOOD) get.MatH.ncols(BLOOD) get.MatH.rownames(BLOOD) get.MatH.varnames(BLOOD) get.MatH.main.info(BLOOD)
Computes a statistic (mean, median, standard deviation, ...) for each
histogram of a MatH object.
## S4 method for signature 'MatH' get.MatH.stats(object, stat = "mean", prob = 0.5)## S4 method for signature 'MatH' get.MatH.stats(object, stat = "mean", prob = 0.5)
object |
A |
stat |
The statistic: |
prob |
A number between 0 and 1, the level of the quantile when
|
A list with the name of the statistic (stat), the level
prob (only when stat = "quantile") and the matrix of values
(mat).
get.MatH.stats(BLOOD) # means get.MatH.stats(BLOOD, stat = "median") get.MatH.stats(BLOOD, stat = "quantile", prob = 0.05) # 5th percentiles get.MatH.stats(BLOOD, stat = "std")get.MatH.stats(BLOOD) # means get.MatH.stats(BLOOD, stat = "median") get.MatH.stats(BLOOD, stat = "quantile", prob = 0.05) # 5th percentiles get.MatH.stats(BLOOD, stat = "std")
Returns the standard deviation stored in the s slot of a
distributionH object. To compute it from the distribution use
stdH.
get.s(object)get.s(object)
object |
A |
A non-negative number, the standard deviation of the distribution.
D <- distributionH(x = c(1, 2, 3, 4), p = c(0, 0.2, 0.6, 1)) get.s(D)D <- distributionH(x = c(1, 2, 3, 4), p = c(0, 0.2, 0.6, 1)) get.s(D)
The HTS class describes a histogram time series, i.e. a sequence of
histograms (TdistributionH objects) observed along time.
dataA list of TdistributionH objects.
Objects are created with new("HTS", epocs, ListOfTimedElements), where
epocs is the number of time points and ListOfTimedElements a
list of TdistributionH objects.
RetHTS for an example dataset;
subsetHTS, plot,HTS-method,
HTS.moving.averages, HTS.exponential.smoothing,
HTS.predict.knn.
RetHTS subsetHTS(RetHTS, from = 1, to = 5)RetHTS subsetHTS(RetHTS, from = 1, to = 5)
(Beta version) Exponential smoothing of a histogram time series, based on the L2 Wasserstein distance.
HTS.exponential.smoothing(HTS, alpha = 0.9)HTS.exponential.smoothing(HTS, alpha = 0.9)
HTS |
A |
alpha |
A number between 0 and 1, the smoothing parameter (default 0.9). |
A list with smoothing.alpha, the smoothing parameter, and
SmoothedHTS, the smoothed HTS object.
mov.expo.smooth <- HTS.exponential.smoothing(HTS = RetHTS, alpha = 0.8) mov.expo.smooth$SmoothedHTSmov.expo.smooth <- HTS.exponential.smoothing(HTS = RetHTS, alpha = 0.8) mov.expo.smooth$SmoothedHTS
(Beta version) Smoothing of a histogram time series by (weighted) moving averages, based on the L2 Wasserstein distance.
HTS.moving.averages(HTS, k = 3, weights = rep(1, k))HTS.moving.averages(HTS, k = 3, weights = rep(1, k))
HTS |
A |
k |
An odd integer, the number of elements of each average (default 3). |
weights |
A vector of |
A list with k, the (normalised) weights and
AveragedHTS, the smoothed HTS object.
mov.av.smoothed <- HTS.moving.averages(HTS = RetHTS, k = 5) mov.av.smoothed$AveragedHTSmov.av.smoothed <- HTS.moving.averages(HTS = RetHTS, k = 5) mov.av.smoothed$AveragedHTS
(Beta version) Forecasts a histogram of a time series with the k-nearest
neighbours method, based on the L2 Wasserstein distance: the forecast is the
mean of the histograms following the k histograms most similar to the
one at position.
HTS.predict.knn(HTS, position = length(HTS@data), k = 3)HTS.predict.knn(HTS, position = length(HTS@data), k = 3)
HTS |
A |
position |
An integer, the position of the last observed histogram (default: the last one). |
k |
The number of neighbours (default 3). |
A distributionH object, the forecast.
Arroyo, J., Mate, C. (2009). Forecasting histogram time series with k-nearest neighbours methods. International Journal of Forecasting, 25(1), 192-207. doi:10.1016/j.ijforecast.2008.07.003
prediction <- HTS.predict.knn(HTS = RetHTS, position = 108, k = 3)prediction <- HTS.predict.knn(HTS = RetHTS, position = 108, k = 3)
Computes the kurtosis (fourth standardised moment) of a distributionH
object.
kurtH(object)kurtH(object)
object |
A |
A number, the kurtosis index (3 for a Gaussian distribution).
mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) kurtH(mydist) # 2.133533mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) kurtH(mydist) # 2.133533
The MatH class describes a matrix of histograms: each cell contains a
distributionH object, rows are the individuals and columns the
(histogram-valued) variables.
MatH( x = NULL, nrows = 1, ncols = 1, rownames = NULL, varnames = NULL, by.row = FALSE )MatH( x = NULL, nrows = 1, ncols = 1, rownames = NULL, varnames = NULL, by.row = FALSE )
nrows, ncols
|
Integers, the number of rows (individuals) and of columns (variables). Default 1. |
by.row |
A logical value (default |
x |
A list of |
rownames, varnames
|
Character vectors (or lists of strings), the names
of the rows and of the columns (variables). Default |
MatH() returns a MatH object.
MA matrix of mode list, each cell containing a distributionH
object.
Objects are created with MatH() or with
new("MatH", nrows, ncols, ListOfDist, names.rows, names.cols, by.row),
where ListOfDist is a list of distributionH objects and
names.rows, names.cols are the names of rows and columns.
Irpino, A., Verde, R. (2015) Basic statistics for distributional symbolic variables: a new metric-based approach, Advances in Data Analysis and Classification, 9(2), 143-175. doi:10.1007/s11634-014-0176-4
get.MatH.main.info, plot,MatH-method,
WH.vec.mean, WH.var.covar.
## a list of six distributionH objects ListOfDist <- vector("list", 6) ListOfDist[[1]] <- distributionH(c(1, 2, 3), c(0, 0.4, 1)) ListOfDist[[2]] <- distributionH(c(7, 8, 10, 15), c(0, 0.2, 0.7, 1)) ListOfDist[[3]] <- distributionH(c(9, 11, 20), c(0, 0.5, 1)) ListOfDist[[4]] <- distributionH(c(2, 5, 8), c(0, 0.3, 1)) ListOfDist[[5]] <- distributionH(c(8, 10, 15), c(0, 0.75, 1)) ListOfDist[[6]] <- distributionH(c(20, 22, 24), c(0, 0.12, 1)) ## a 3 x 2 MatH filled by columns MyMAT <- MatH( x = ListOfDist, nrows = 3, ncols = 2, rownames = c("I1", "I2", "I3"), varnames = c("Var1", "Var2") ) MyMAT ## an empty 10 x 4 matrix of histograms MAT <- MatH(nrows = 10, ncols = 4)## a list of six distributionH objects ListOfDist <- vector("list", 6) ListOfDist[[1]] <- distributionH(c(1, 2, 3), c(0, 0.4, 1)) ListOfDist[[2]] <- distributionH(c(7, 8, 10, 15), c(0, 0.2, 0.7, 1)) ListOfDist[[3]] <- distributionH(c(9, 11, 20), c(0, 0.5, 1)) ListOfDist[[4]] <- distributionH(c(2, 5, 8), c(0, 0.3, 1)) ListOfDist[[5]] <- distributionH(c(8, 10, 15), c(0, 0.75, 1)) ListOfDist[[6]] <- distributionH(c(20, 22, 24), c(0, 0.12, 1)) ## a 3 x 2 MatH filled by columns MyMAT <- MatH( x = ListOfDist, nrows = 3, ncols = 2, rownames = c("I1", "I2", "I3"), varnames = c("Var1", "Var2") ) MyMAT ## an empty 10 x 4 matrix of histograms MAT <- MatH(nrows = 10, ncols = 4)
Computes the mean (first moment) of a distributionH object.
meanH(object)meanH(object)
object |
A |
A number, the mean of the distribution.
mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) meanH(mydist) # 4.4mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) meanH(mydist) # 4.4
Histograms of four variables recorded by 78 stations in the USA, without missing data: ozone concentration (ppb), temperature (C), solar radiation (W/m2) and wind speed (m/s).
A MatH object with 78 rows (stations) and 4 columns (variables).
US EPA, CASTNET (Clean Air Status and Trends Network), meteorological data.
get.MatH.main.info(OzoneFull)get.MatH.main.info(OzoneFull)
Histograms of four variables recorded by 84 stations in the USA: ozone concentration (ppb), temperature (C), solar radiation (W/m2) and wind speed (m/s). Some stations have missing data.
A MatH object with 84 rows (stations) and 4 columns (variables).
US EPA, CASTNET (Clean Air Status and Trends Network), meteorological data.
get.MatH.main.info(OzoneH)get.MatH.main.info(OzoneH)
Plots the differences between observed and predicted histograms (e.g. from
WH.regression.two.components.predict) and prints the root mean
squared error based on the L2 Wasserstein distance.
plot_errors(PRED, OBS, type = "HISTO_QUA", np = 200)plot_errors(PRED, OBS, type = "HISTO_QUA", np = 200)
PRED |
A |
OBS |
A |
type |
The type of plot: |
np |
The number of points used to compute the differences (default 200). |
The root mean squared error, invisibly. The plot is drawn on the current device.
plotPredVsObs, WH.regression.GOF
pars <- WH.regression.two.components(BLOOD, Yvar = 1, Xvars = c(2:3)) PRED <- WH.regression.two.components.predict(data = BLOOD[, 2:3], parameters = pars) OBS <- BLOOD[, 1] plot_errors(PRED, OBS, "HISTO_QUA") plot_errors(PRED, OBS, "HISTO_DEN") plot_errors(PRED, OBS, "DENS_KDE")pars <- WH.regression.two.components(BLOOD, Yvar = 1, Xvars = c(2:3)) PRED <- WH.regression.two.components.predict(data = BLOOD[, 2:3], parameters = pars) OBS <- BLOOD[, 1] plot_errors(PRED, OBS, "HISTO_QUA") plot_errors(PRED, OBS, "HISTO_DEN") plot_errors(PRED, OBS, "DENS_KDE")
Plots a distributionH object as a histogram, a cumulative distribution
function, a quantile function, a density or a boxplot.
## S4 method for signature 'distributionH' plot(x, type = "HISTO", col = "green", border = "black")## S4 method for signature 'distributionH' plot(x, type = "HISTO", col = "green", border = "black")
x |
A |
type |
The type of plot: |
col |
The fill colour (default |
border |
The colour of the borders (default |
The plot is drawn on the current device and the ggplot object is
returned invisibly, so that it can be further modified, e.g.
p <- plot(mydist); p + ggplot2::theme_bw().
mydist <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) plot(mydist) plot(mydist, type = "HISTO", col = "red", border = "blue") plot(mydist, type = "DENS", col = "red", border = "blue") plot(mydist, type = "HBOXPLOT") plot(mydist, type = "VBOXPLOT") plot(mydist, type = "CDF") plot(mydist, type = "QF")mydist <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) plot(mydist) plot(mydist, type = "HISTO", col = "red", border = "blue") plot(mydist, type = "DENS", col = "red", border = "blue") plot(mydist, type = "HBOXPLOT") plot(mydist, type = "VBOXPLOT") plot(mydist, type = "CDF") plot(mydist, type = "QF")
Plots a HTS object as a sequence of violin plots or boxplots, one for
each timestamp.
## S4 method for signature 'HTS' plot(x, y = "missing", type = "VIOLIN", border = "black", maxno.perplot = 30)## S4 method for signature 'HTS' plot(x, y = "missing", type = "VIOLIN", border = "black", maxno.perplot = 30)
x |
A |
y |
Not used. |
type |
The type of plot: |
border |
The colour of the borders (default |
maxno.perplot |
The maximum number of timestamps in each row of the plot (default 30): longer series are split into several rows. |
The plot is drawn on the current device and the ggplot object is
returned invisibly, so that it can be further modified.
plot(subsetHTS(RetHTS, from = 1, to = 10)) plot(RetHTS, type = "BOXPLOT", border = "blue", maxno.perplot = 20) plot(RetHTS, type = "VIOLIN", maxno.perplot = 20)plot(subsetHTS(RetHTS, from = 1, to = 10)) plot(RetHTS, type = "BOXPLOT", border = "blue", maxno.perplot = 20) plot(RetHTS, type = "VIOLIN", maxno.perplot = 20)
Plots all the histograms of a MatH object: one panel for each variable,
one row for each individual.
## S4 method for signature 'MatH' plot(x, y = "missing", type = "HISTO", border = "black", angL = 330)## S4 method for signature 'MatH' plot(x, y = "missing", type = "HISTO", border = "black", angL = 330)
x |
A |
y |
Not used. |
type |
The type of plot: |
border |
The colour of the borders (default |
angL |
Not used (kept for compatibility). |
The plot is drawn on the current device and the ggplot object is
returned invisibly, so that it can be further modified.
plot(BLOOD) plot(BLOOD, type = "DENS", border = "blue") plot(BLOOD, type = "BOXPLOT")plot(BLOOD) plot(BLOOD, type = "DENS", border = "blue") plot(BLOOD, type = "BOXPLOT")
Plots a TdistributionH object: see plot,distributionH-method
for the types of plot.
## S4 method for signature 'TdistributionH' plot(x, type = "HISTO", col = "green", border = "black")## S4 method for signature 'TdistributionH' plot(x, type = "HISTO", col = "green", border = "black")
x |
A |
type |
The type of plot: |
col |
The fill colour (default |
border |
The colour of the borders (default |
The plot is drawn on the current device and the ggplot object is
returned invisibly.
td <- new("TdistributionH", tstamp = 1, x = c(1, 2, 3), p = c(0, 0.4, 1)) plot(td)td <- new("TdistributionH", tstamp = 1, x = c(1, 2, 3), p = c(0, 0.4, 1)) plot(td)
Compares observed and predicted histograms (e.g. from
WH.regression.two.components.predict), one panel for each
individual.
plotPredVsObs(PRED, OBS, type = "HISTO", ncolu = 2)plotPredVsObs(PRED, OBS, type = "HISTO", ncolu = 2)
PRED |
A |
OBS |
A |
type |
The type of plot: |
ncolu |
The number of columns of panels (default 2). |
The plot is drawn on the current device and the ggplot object
is returned invisibly.
pars <- WH.regression.two.components(BLOOD, Yvar = 1, Xvars = c(2:3)) PRED <- WH.regression.two.components.predict(data = BLOOD[, 2:3], parameters = pars) OBS <- BLOOD[, 1] plotPredVsObs(PRED, OBS, "HISTO") plotPredVsObs(PRED, OBS, "CDF") plotPredVsObs(PRED, OBS, "DENS")pars <- WH.regression.two.components(BLOOD, Yvar = 1, Xvars = c(2:3)) PRED <- WH.regression.two.components.predict(data = BLOOD[, 2:3], parameters = pars) OBS <- BLOOD[, 1] plotPredVsObs(PRED, OBS, "HISTO") plotPredVsObs(PRED, OBS, "CDF") plotPredVsObs(PRED, OBS, "DENS")
Given two distributionH objects, returns two equivalent
distributions sharing the same cdf values (the union of the two p
vectors). This is the basis for computing the statistics based on the L2
Wasserstein distance.
register(object1, object2)register(object1, object2)
object1, object2
|
Two |
A list: the two distributionH objects, with the same p
slot, and a matrix with their quantiles and the common cdf.
Irpino, A., Lechevallier, Y. and Verde, R. (2006): Dynamic clustering of histograms using Wasserstein metric In: Rizzi, A., Vichi, M. (eds.) COMPSTAT 2006. Physica-Verlag, Berlin, 869-876.
mydist1 <- distributionH(c(1, 2, 3), c(0, 0.4, 1)) mydist2 <- distributionH(c(7, 8, 10, 15), c(0, 0.2, 0.7, 1)) regDist <- register(mydist1, mydist2) regDist[[1]]@p regDist[[1]]@x regDist[[2]]@xmydist1 <- distributionH(c(1, 2, 3), c(0, 0.4, 1)) mydist2 <- distributionH(c(7, 8, 10, 15), c(0, 0.2, 0.7, 1)) regDist <- register(mydist1, mydist2) regDist[[1]]@p regDist[[1]]@x regDist[[2]]@x
registerMH recomputes all the histograms of a MatH object so that
they share the same cdf values (the same p slot), without changing the
distributions. This allows a fast computation of all the methods based on the
L2 Wasserstein metric. is.registeredMH checks whether the histograms
already share the same cdf.
is.registeredMH(object) registerMH(object)is.registeredMH(object) registerMH(object)
object |
A |
registerMH returns a MatH object whose histograms share
the same cdf; is.registeredMH returns TRUE or FALSE.
Irpino, A., Lechevallier, Y. and Verde, R. (2006): Dynamic clustering of histograms using Wasserstein metric In: Rizzi, A., Vichi, M. (eds.) COMPSTAT 2006. Physica-Verlag, Berlin, 869-876.
mydist1 <- distributionH(c(1, 2, 3), c(0, 0.4, 1)) mydist2 <- distributionH(c(7, 8, 10, 15), c(0, 0.2, 0.7, 1)) mydist3 <- distributionH(c(9, 11, 20), c(0, 0.8, 1)) MyMAT <- MatH(x = list(mydist1, mydist2, mydist3), nrows = 1, ncols = 3) is.registeredMH(MyMAT) # FALSE MATregistered <- registerMH(MyMAT) is.registeredMH(MATregistered) # TRUE MATregistered@M[[1, 1]]@pmydist1 <- distributionH(c(1, 2, 3), c(0, 0.4, 1)) mydist2 <- distributionH(c(7, 8, 10, 15), c(0, 0.2, 0.7, 1)) mydist3 <- distributionH(c(9, 11, 20), c(0, 0.8, 1)) MyMAT <- MatH(x = list(mydist1, mydist2, mydist3), nrows = 1, ncols = 3) is.registeredMH(MyMAT) # FALSE MATregistered <- registerMH(MyMAT) is.registeredMH(MATregistered) # TRUE MATregistered@M[[1, 1]]@p
Daily histograms of the returns of the US dollar / Japanese yen exchange rate.
A HTS-class object with 108 histograms.
summaryHTS(subsetHTS(RetHTS, from = 1, to = 5)) plot(subsetHTS(RetHTS, from = 1, to = 20))summaryHTS(subsetHTS(RetHTS, from = 1, to = 5)) plot(subsetHTS(RetHTS, from = 1, to = 20))
Computes the correlation between the quantile functions of two
distributionH objects.
rQQ(e1, e2)rQQ(e1, e2)
e1, e2
|
Two |
A number, the correlation between the quantile functions.
Irpino, A., Verde, R. (2015) Basic statistics for distributional symbolic variables: a new metric-based approach, Advances in Data Analysis and Classification, 9(2), 143-175. doi:10.1007/s11634-014-0176-4
mydist1 <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1)) mydist2 <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) rQQ(mydist1, mydist2) # 0.916894mydist1 <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1)) mydist2 <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) rQQ(mydist1, mydist2) # 0.916894
Computes the Euclidean distance between a point and the line through two
points (used by DouglasPeucker).
ShortestDistance(p, line)ShortestDistance(p, line)
p |
A vector with the coordinates of the point. |
line |
A 2 x 2 matrix with the coordinates of two points of the line. |
A number, the distance of p from line.
ShortestDistance(c(0, 1), rbind(c(0, 0), c(1, 0)))ShortestDistance(c(0, 1), rbind(c(0, 0), c(1, 0)))
Prints a distributionH object as a table of bins and probabilities.
If the histogram has many bins, only the first and the last five are shown.
## S4 method for signature 'distributionH' show(object)## S4 method for signature 'distributionH' show(object)
object |
A |
Invisibly NULL; called for its side effect.
mydist <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) mydistmydist <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) mydist
Prints a MatH object showing, for each histogram, its mean and its
standard deviation.
## S4 method for signature 'MatH' show(object)## S4 method for signature 'MatH' show(object)
object |
A |
Invisibly NULL; called for its side effect.
BLOODBLOOD
Computes the skewness (third standardised moment) of a distributionH
object.
skewH(object)skewH(object)
object |
A |
A number, the skewness index.
mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) skewH(mydist) # 0.7148855mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) skewH(mydist) # 0.7148855
Geographical coordinates of the 60 stations of China_Month and
China_Seas.
A data frame with 60 rows and 9 columns: ID, Name_ST
(name of the station), Code_ST (code of the station), LAT.deg,
LAT.min, LON.deg, LON.min (latitude and longitude, degrees
and minutes), Elevation, Beginning (first year of observation).
Climate Data Bases of the People's Republic of China 1841-1988 (TR055), doi:10.3334/CDIAC/cli.tr055
head(stations_coordinates)head(stations_coordinates)
Computes the standard deviation (square root of the second centred moment)
of a distributionH object.
stdH(object)stdH(object)
object |
A |
A non-negative number, the standard deviation of the distribution.
mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) stdH(mydist) # 2.563851mydist <- distributionH(x = c(1, 2, 3, 10), p = c(0, 0.1, 0.5, 1)) stdH(mydist) # 2.563851
Extracts the elements of a histogram time series between two positions.
subsetHTS(object, from, to)subsetHTS(object, from, to)
object |
A |
from, to
|
Integers, the positions of the first and of the last element. |
A HTS object.
SUB_RetHTS <- subsetHTS(RetHTS, from = 1, to = 20) # the first 20 elementsSUB_RetHTS <- subsetHTS(RetHTS, from = 1, to = 20) # the first 20 elements
Computes basic statistics for each histogram of a HTS object.
summaryHTS(x)summaryHTS(x)
x |
A |
A data frame with one row for each histogram: timestamp and period, mean, standard deviation, skewness, kurtosis, minimum, quartiles and maximum.
summaryHTS(subsetHTS(RetHTS, from = 1, to = 10))summaryHTS(subsetHTS(RetHTS, from = 1, to = 10))
The TdistributionH class extends distributionH with a time
reference: a timestamp or a time period. It is the element of a histogram time
series (HTS-class).
tstampA number, the timestamp.
periodA list with two elements, start and end, the bounds
of the time period (alternative to tstamp).
xThe bounds of the bins (see distributionH-class).
pThe cdf at x.
mThe mean.
sThe standard deviation.
Objects are created with
new("TdistributionH", tstamp, period, x, p, m, s), where x,
p, m and s are as in distributionH.
HTS-class, plot,TdistributionH-method
td <- new("TdistributionH", tstamp = 1, x = c(1, 2, 3), p = c(0, 0.4, 1)) td@tstamptd <- new("TdistributionH", tstamp = 1, x = c(1, 2, 3), p = c(0, 0.4, 1)) td@tstamp
The TMatH class extends MatH with a time reference (timestamps or
time periods).
tstampA numeric vector of timestamps.
periodA list of time periods (alternative to tstamp).
MThe matrix of histograms, as in MatH-class.
Objects are created with new("TMatH", mat, tstamp, period), where
mat is a MatH object.
Computes the squared L2 Wasserstein distance between two distributionH
objects, i.e. the integral of the squared difference of their quantile
functions. Optionally it returns its decomposition into a position, a size and
a shape component.
## S4 method for signature 'distributionH,distributionH' WassSqDistH(object1 = object1, object2 = object2, details = FALSE)## S4 method for signature 'distributionH,distributionH' WassSqDistH(object1 = object1, object2 = object2, details = FALSE)
object1, object2
|
Two |
details |
A logical value (default |
If details = FALSE, a number, the squared distance. If
details = TRUE, a named vector with the squared distance
(SQ_W_dist), its position (POSITION), size (SIZE) and
shape (SHAPE) components, and the correlation between the quantile
functions (rQQ).
Irpino, A. and Romano, E. (2007): Optimal histogram representation of large data sets: Fisher vs piecewise linear approximations. RNTI E-9, 99-110.
Irpino, A., Verde, R. (2015) Basic statistics for distributional symbolic variables: a new metric-based approach, Advances in Data Analysis and Classification, 9(2), 143-175. doi:10.1007/s11634-014-0176-4
WH_MAT_DIST for the distance matrix of a MatH.
mydist1 <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1)) mydist2 <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) WassSqDistH(mydist1, mydist2) WassSqDistH(mydist1, mydist2, details = TRUE)mydist1 <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1)) mydist2 <- distributionH(x = c(7, 8, 10, 15), p = c(0, 0.2, 0.7, 1)) WassSqDistH(mydist1, mydist2) WassSqDistH(mydist1, mydist2, details = TRUE)
Batch Kohonen self-organising 2d map of the individuals of a MatH
object, based on adaptive L2 Wasserstein distances.
WH_2d_Adaptive_Kohonen_maps( x, net = list(xdim = 4, ydim = 3, topo = c("rectangular")), kern.param = 2, TMAX = -9999, Tmin = -9999, niter = 30, repetitions, simplify = FALSE, qua = 10, standardize = FALSE, schema = 6, init.weights = "EQUAL", weight.sys = "PROD", theta = 2, Wfix = FALSE, verbose = FALSE, atleast = 2 )WH_2d_Adaptive_Kohonen_maps( x, net = list(xdim = 4, ydim = 3, topo = c("rectangular")), kern.param = 2, TMAX = -9999, Tmin = -9999, niter = 30, repetitions, simplify = FALSE, qua = 10, standardize = FALSE, schema = 6, init.weights = "EQUAL", weight.sys = "PROD", theta = 2, Wfix = FALSE, verbose = FALSE, atleast = 2 )
x |
A |
net |
A list describing the topology of the map:
|
kern.param |
The parameter of the RBF kernel (default 2). |
TMAX, Tmin
|
The initial and final values of the neighbourhood radius. When negative (default), they are computed from the size of the map. |
niter |
The maximum number of iterations (default 30). |
repetitions |
The number of repetitions of the algorithm (default 5); the best solution is returned. |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles used when |
standardize |
A logical value (default |
schema |
An integer, the system of weights: 1 = a weight for each variable; 2 = a weight for the position and one for the variability component of each variable; 3 and 4 = as 1 and 2, with a different set of weights for each neuron (product of the weights of each variable equal to one); 5 and 6 = as 1 and 2, with a different set of weights for each neuron (product of all the weights equal to one, default 6). |
init.weights |
The initial weights: |
weight.sys |
The constraint on the weights: |
theta |
A number, the exponent of the weights when
|
Wfix |
A logical value (default |
verbose |
A logical value (default |
atleast |
An integer (default 2): solutions where fewer than
|
Batch Self-Organising Maps (BSOM) for histogram data, with a cost function based on the L2 Wasserstein distance, i.e. the Euclidean distance between quantile functions. The adaptive version introduces an automatic system of weights in the cost function, to take into account the different effect of the variables on the map.
A list with:
solution |
The best solution among the repetitions: a list with
|
quality |
The proportion of the total sum of squares explained by the map (the higher the better). |
and further details on the parameters of the algorithm. The final map is plotted on the current graphic device.
Irpino A., Verde R., De Carvalho F.A.T. (2012). Batch self organizing maps for interval and histogram data. In: Proceedings of COMPSTAT 2012, ISI/IASC, 143-154.
results <- WH_2d_Adaptive_Kohonen_maps( x = BLOOD, net = list(xdim = 2, ydim = 3, topo = c("rectangular")), repetitions = 2, simplify = TRUE, qua = 10, standardize = TRUE )results <- WH_2d_Adaptive_Kohonen_maps( x = BLOOD, net = list(xdim = 2, ydim = 3, topo = c("rectangular")), repetitions = 2, simplify = TRUE, qua = 10, standardize = TRUE )
Batch Kohonen self-organising 2d map of the individuals of a MatH
object, based on the L2 Wasserstein distance.
WH_2d_Kohonen_maps( x, net = list(xdim = 4, ydim = 3, topo = c("rectangular")), kern.param = 2, TMAX = 2, Tmin = 0.2, niter = 30, repetitions = 5, simplify = FALSE, qua = 10, standardize = FALSE, verbose = FALSE )WH_2d_Kohonen_maps( x, net = list(xdim = 4, ydim = 3, topo = c("rectangular")), kern.param = 2, TMAX = 2, Tmin = 0.2, niter = 30, repetitions = 5, simplify = FALSE, qua = 10, standardize = FALSE, verbose = FALSE )
x |
A |
net |
A list describing the topology of the map:
|
kern.param |
The parameter of the RBF kernel (default 2). |
TMAX, Tmin
|
The initial and final values of the neighbourhood radius (defaults 2 and 0.2). |
niter |
The maximum number of iterations (default 30). |
repetitions |
The number of repetitions of the algorithm (default 5); the best solution is returned. |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles used when |
standardize |
A logical value (default |
verbose |
A logical value (default |
Batch Self-Organising Maps (BSOM) for histogram data, with a cost function based on the L2 Wasserstein distance, i.e. the Euclidean distance between quantile functions. The adaptive version introduces an automatic system of weights in the cost function, to take into account the different effect of the variables on the map.
A list with:
solution |
The best solution among the repetitions: a list with
|
quality |
The proportion of the total sum of squares explained by the map (the higher the better). |
and further details on the parameters of the algorithm. The final map is plotted on the current graphic device.
Irpino A., Verde R., De Carvalho F.A.T. (2012). Batch self organizing maps for interval and histogram data. In: Proceedings of COMPSTAT 2012, ISI/IASC, 143-154.
results <- WH_2d_Kohonen_maps( x = BLOOD, net = list(xdim = 2, ydim = 3, topo = c("rectangular")), repetitions = 2, simplify = TRUE, qua = 10, standardize = TRUE )results <- WH_2d_Kohonen_maps( x = BLOOD, net = list(xdim = 2, ydim = 3, topo = c("rectangular")), repetitions = 2, simplify = TRUE, qua = 10, standardize = TRUE )
Fuzzy c-means of the individuals of a MatH object based on adaptive L2
Wasserstein distances: the algorithm also estimates a weight for each variable
(or for each component of the variables, and/or for each cluster).
WH_adaptive_fcmeans( x, k = 5, schema, m = 1.6, rep, simplify = FALSE, qua = 10, standardize = FALSE, init.weights = "EQUAL", weight.sys = "PROD", theta = 2, verbose = FALSE )WH_adaptive_fcmeans( x, k = 5, schema, m = 1.6, rep, simplify = FALSE, qua = 10, standardize = FALSE, init.weights = "EQUAL", weight.sys = "PROD", theta = 2, verbose = FALSE )
x |
A |
k |
An integer, the number of clusters. |
schema |
An integer, the system of weights: 1 = a weight for each variable; 2 = a weight for the position and one for the variability component of each variable; 3 = as 1, with a different set of weights for each cluster; 4 = as 2, with a different set of weights for each cluster. |
m |
A number greater than 1, the fuzziness coefficient (default 1.6). |
rep |
An integer, the number of repetitions of the algorithm (with random starting partitions); the best solution is returned. Default 5. |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles used when |
standardize |
A logical value (default |
init.weights |
The initial weights: |
weight.sys |
The constraint on the weights: |
theta |
A number, the exponent of the weights when
|
verbose |
A logical value (default |
A list with:
solution |
The best solution among the repetitions: a list with
|
quality |
The proportion of the total sum of squares explained by the partition (the higher the better). |
and further details on the decomposition of the sum of squares.
WH_fcmeans, WH_adaptive.kmeans
results <- WH_adaptive_fcmeans( x = BLOOD, k = 2, schema = 4, m = 1.5, rep = 3, simplify = TRUE, qua = 10, standardize = TRUE, init.weights = "EQUAL", weight.sys = "PROD" ) results$solution$var.weightsresults <- WH_adaptive_fcmeans( x = BLOOD, k = 2, schema = 4, m = 1.5, rep = 3, simplify = TRUE, qua = 10, standardize = TRUE, init.weights = "EQUAL", weight.sys = "PROD" ) results$solution$var.weights
K-means of the individuals of a MatH object based on adaptive L2
Wasserstein distances: the algorithm also estimates a weight for each variable
(or for each component of the variables, and/or for each cluster).
WH_adaptive.kmeans( x, k, schema = 1, init, rep, simplify = FALSE, qua = 10, standardize = FALSE, weight.sys = "PROD", theta = 2, init.weights = "EQUAL", verbose = FALSE )WH_adaptive.kmeans( x, k, schema = 1, init, rep, simplify = FALSE, qua = 10, standardize = FALSE, weight.sys = "PROD", theta = 2, init.weights = "EQUAL", verbose = FALSE )
x |
A |
k |
An integer, the number of clusters. |
schema |
An integer, the system of weights: 1 = a weight for each variable (default); 2 = a weight for the position and one for the variability component of each variable; 3 = as 1, with a different set of weights for each cluster; 4 = as 2, with a different set of weights for each cluster. |
init |
Not used. |
rep |
An integer, the number of repetitions of the algorithm (with random starting partitions); the best solution is returned. Default 5. |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles used when |
standardize |
A logical value (default |
weight.sys |
The constraint on the weights: |
theta |
A number, the exponent of the weights when
|
init.weights |
The initial weights: |
verbose |
A logical value (default |
A list with IDX (the cluster of each individual),
cardinality (the size of each cluster), proto (a MatH
object with the prototypes), weights (the weights of the variables or
components), Crit (the criterion), TOTSSQ, BSQ,
WSQ (total, between and within sums of squares) and quality (the
proportion of the total sum of squares explained by the partition).
Irpino A., Verde R., De Carvalho F.A.T. (2014). Dynamic clustering of histogram data based on adaptive squared Wasserstein distances. Expert Systems with Applications, 41, 3351-3366. doi:10.1016/j.eswa.2013.12.001
WH_kmeans, WH_adaptive_fcmeans
results <- WH_adaptive.kmeans(x = BLOOD, k = 2, rep = 10, simplify = TRUE, qua = 10, standardize = TRUE) results$weightsresults <- WH_adaptive.kmeans(x = BLOOD, k = 2, rep = 10, simplify = TRUE, qua = 10, standardize = TRUE) results$weights
Fuzzy c-means of the individuals of a MatH object, based on the L2
Wasserstein distance between histograms.
WH_fcmeans(x, k, m = 1.6, rep, simplify = FALSE, qua = 10, standardize = FALSE)WH_fcmeans(x, k, m = 1.6, rep, simplify = FALSE, qua = 10, standardize = FALSE)
x |
A |
k |
An integer, the number of clusters. |
m |
A number greater than 1, the fuzziness coefficient (default 1.6). |
rep |
An integer, the number of repetitions of the algorithm (with random starting partitions); the best solution is returned. Default 5. |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles used when |
standardize |
A logical value (default |
A list with:
solution |
The best solution among the repetitions: a list with
|
quality |
The proportion of the total sum of squares explained by the partition (the higher the better). |
and further details on the decomposition of the sum of squares.
WH_adaptive_fcmeans, WH_kmeans
results <- WH_fcmeans(x = BLOOD, k = 2, m = 1.5, rep = 10, simplify = TRUE, qua = 10, standardize = TRUE) results$solution$membershipresults <- WH_fcmeans(x = BLOOD, k = 2, m = 1.5, rep = 10, simplify = TRUE, qua = 10, standardize = TRUE) results$solution$membership
Hierarchical clustering of the individuals of a MatH object, based on
the L2 Wasserstein distance. It is a wrapper of hclust.
WH_hclust( x, simplify = FALSE, qua = 10, standardize = FALSE, distance = "WDIST", method = "complete" )WH_hclust( x, simplify = FALSE, qua = 10, standardize = FALSE, distance = "WDIST", method = "complete" )
x |
A |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles used when |
standardize |
A logical value (default |
distance |
The distance: only |
method |
The agglomeration method, as in |
An object of class hclust.
Irpino A., Verde R. (2006). A new Wasserstein based distance for the hierarchical clustering of histogram symbolic data. In: Batanjeli et al. (eds.) Data Science and Classification, IFCS 2006, Springer, 185-192.
results <- WH_hclust(x = BLOOD, simplify = TRUE, method = "complete") plot(results) cutree(results, k = 5)results <- WH_hclust(x = BLOOD, simplify = TRUE, method = "complete") plot(results) cutree(results, k = 5)
K-means (dynamic clustering) of the individuals of a MatH object, based
on the L2 Wasserstein distance between histograms.
WH_kmeans( x, k, rep = 5, simplify = FALSE, qua = 10, standardize = FALSE, verbose = FALSE )WH_kmeans( x, k, rep = 5, simplify = FALSE, qua = 10, standardize = FALSE, verbose = FALSE )
x |
A |
k |
An integer, the number of clusters. |
rep |
An integer, the number of repetitions of the algorithm (with random starting partitions); the best solution is returned. Default 5. |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles used when |
standardize |
A logical value (default |
verbose |
A logical value (default |
A list with:
solution |
The best solution among the repetitions (minimum criterion): a
list with |
quality |
The proportion of the total sum of squares explained by the partition (the higher the better). |
Irpino A., Verde R., Lechevallier Y. (2006). Dynamic clustering of histograms using Wasserstein metric. In: Rizzi A., Vichi M. (eds.) COMPSTAT 2006 - Advances in computational statistics, Physica-Verlag, 869-876.
WH_adaptive.kmeans, WH_fcmeans,
WH_hclust
results <- WH_kmeans( x = BLOOD, k = 2, rep = 10, simplify = TRUE, qua = 10, standardize = TRUE ) results$solution$IDX results$qualityresults <- WH_kmeans( x = BLOOD, k = 2, rep = 10, simplify = TRUE, qua = 10, standardize = TRUE ) results$solution$IDX results$quality
Computes the matrix of the L2 Wasserstein distances between the individuals
(rows) of a MatH object, summing the squared distances over the
variables.
WH_MAT_DIST(x, simplify = FALSE, qua = 10, standardize = FALSE)WH_MAT_DIST(x, simplify = FALSE, qua = 10, standardize = FALSE)
x |
A |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles used when |
standardize |
A logical value (default |
A symmetric matrix of L2 Wasserstein distances.
Irpino A., Verde R. (2006). A new Wasserstein based distance for the hierarchical clustering of histogram symbolic data. In: Batanjeli et al. (eds.) Data Science and Classification, IFCS 2006, Springer, 185-192.
DMAT <- WH_MAT_DIST(x = BLOOD, simplify = TRUE)DMAT <- WH_MAT_DIST(x = BLOOD, simplify = TRUE)
Principal component analysis (PCA) of one histogram variable based on the L2 Wasserstein distance: a centred (not standardised) PCA of the quantiles of the histograms. It provides a dimensional reduction and a visualization of the distributions.
WH.1d.PCA( data, var, quantiles = 10, plots = TRUE, listaxes = c(1:4), axisequal = FALSE, qcut = 1, outl = 0 )WH.1d.PCA( data, var, quantiles = 10, plots = TRUE, listaxes = c(1:4), axisequal = FALSE, qcut = 1, outl = 0 )
data |
A |
var |
An integer, the column of the variable to analyse. |
quantiles |
An integer, the number of quantiles used in the analysis (default 10). |
plots |
A logical value (default |
listaxes |
A vector of integers, the axes of the factorial planes to
plot (default |
axisequal |
A logical value (default |
qcut |
A number between 0.5 and 1 (default 1): densities higher than
their |
outl |
A number between 0 (default) and 0.5, the probability mass removed from each tail of the distributions (e.g. 0.1 removes 10% from each tail). |
A list with PCAout, the results of
PCA, WASSVARIANCE (not computed, always 0)
and INERTIA, the total inertia.
Verde, R., Irpino, A., Balzanella, A. (2016). Dimension reduction techniques for distributional symbolic data. IEEE Transactions on Cybernetics, 46(2), 344-355. doi:10.1109/TCYB.2015.2389653
WH.MultiplePCA, WH.plot_multiple_Spanish.funs
results <- WH.1d.PCA(data = BLOOD, var = 1, listaxes = c(1:2))results <- WH.1d.PCA(data = BLOOD, var = 1, listaxes = c(1:2))
WH.bind.row binds by rows two MatH objects with the same number
of columns, WH.bind.col binds by columns two MatH objects with
the same number of rows. WH.bind does one of the two according to
byrow.
WH.bind.row(object1, object2) WH.bind.col(object1, object2) WH.bind(object1, object2, byrow)WH.bind.row(object1, object2) WH.bind.col(object1, object2) WH.bind(object1, object2, byrow)
object1, object2
|
Two |
byrow |
A logical value: if |
A MatH object.
WH.bind.row(BLOOD[1:3, ], BLOOD[5:8, ]) WH.bind.col(BLOOD[1:10, 1], BLOOD[1:10, 3]) WH.bind(BLOOD[1:10, 1], BLOOD[1:10, 3], byrow = FALSE)WH.bind.row(BLOOD[1:3, ], BLOOD[5:8, ]) WH.bind.col(BLOOD[1:10, 1], BLOOD[1:10, 3]) WH.bind(BLOOD[1:10, 1], BLOOD[1:10, 3], byrow = FALSE)
Matrix product of two MatH objects, where the product of two cells is
the dot product of the histograms inducing the L2 Wasserstein metric (see
dotpW).
## S4 method for signature 'MatH,MatH' WH.mat.prod(object1, object2, traspose1 = FALSE, traspose2 = FALSE)## S4 method for signature 'MatH,MatH' WH.mat.prod(object1, object2, traspose1 = FALSE, traspose2 = FALSE)
object1, object2
|
Two |
traspose1, traspose2
|
Logical values (default |
A numeric matrix.
MAT <- WH.mat.prod(BLOOD[1:5, ], BLOOD[6:10, ], traspose1 = TRUE)MAT <- WH.mat.prod(BLOOD[1:5, ], BLOOD[6:10, ], traspose1 = TRUE)
Sums two MatH objects of the same dimensions, cell by cell, by summing
the quantile functions of the histograms (a sum consistent with the L2
Wasserstein metric).
WH.mat.sum(object1, object2)WH.mat.sum(object1, object2)
object1, object2
|
Two |
A MatH object.
MAT <- WH.mat.sum(BLOOD[1:5, ], BLOOD[6:10, ])MAT <- WH.mat.sum(BLOOD[1:5, ], BLOOD[6:10, ])
(Beta version) Principal component analysis of several histogram variables
based on the L2 Wasserstein distance: a multiple factor analysis
(MFA) of the quantiles of the histograms, where each
variable is a group of quantiles. It extends WH.1d.PCA.
WH.MultiplePCA(data, list.of.vars, quantiles = 10, outl = 0, graph = TRUE)WH.MultiplePCA(data, list.of.vars, quantiles = 10, outl = 0, graph = TRUE)
data |
A |
list.of.vars |
A vector of integers, the columns of the variables to analyse. |
quantiles |
An integer, the number of quantiles used in the analysis (default 10). |
outl |
A number between 0 (default) and 0.5, the probability mass removed from each tail of the distributions (e.g. 0.1 removes 10% from each tail). |
graph |
A logical value (default |
The results of MFA.
WH.plot_multiple_Spanish.funs,
WH.plot_multiple_indivs
res <- WH.MultiplePCA(BLOOD, list.of.vars = c(1:3), graph = FALSE)res <- WH.MultiplePCA(BLOOD, list.of.vars = c(1:3), graph = FALSE)
(Beta version) Plots the histograms (or densities) of one variable for each
individual, placed at the coordinates of the individuals on a factorial plane
of WH.MultiplePCA.
WH.plot_multiple_indivs( data, res, axes = c(1, 2), indiv = 0, var = 1, strx = 0.1, stry = 1/8, HISTO = TRUE, coor = 0, stat = "mean" )WH.plot_multiple_indivs( data, res, axes = c(1, 2), indiv = 0, var = 1, strx = 0.1, stry = 1/8, HISTO = TRUE, coor = 0, stat = "mean" )
data |
A |
res |
The results of |
axes |
A vector of two integers, the factorial axes (default
|
indiv |
A vector of integers, the individuals (rows) to plot. Default 0: all the individuals. |
var |
An integer, the variable to plot. |
strx |
A number, the average width of the drawn distributions as a fraction of the range of the coordinates of the individuals on the x axis (default 0.1: on average, the domain of a distribution takes one tenth of the x axis). All the distributions share the same scale, so their spreads remain comparable. |
stry |
A number, the height of the highest density as a fraction of the range of the coordinates of the individuals on the y axis (default 1/8). All the densities share the same scale; spikes (bins of almost zero width) are avoided by drawing histograms with very narrow bins on 30 equal-width bins. |
HISTO |
A logical value: if |
coor |
A matrix of coordinates of the individuals. Default 0: the
coordinates in |
stat |
The statistic used to label and colour the histograms in the
second plot: |
The distributions are measured on the scale of the original
variable, while the factorial plane has the scale of the principal
components: strx and stry set the size of the drawn
distributions automatically, as fractions of the ranges of the coordinates
of the individuals. Each distribution is drawn with its mean at the
coordinates of the individual.
The two plots are drawn on the current device and a list with the two
ggplot objects is returned invisibly.
results <- WH.MultiplePCA(BLOOD, list.of.vars = c(1:3), graph = FALSE) WH.plot_multiple_indivs(BLOOD, results, axes = c(1, 2), var = 1, HISTO = TRUE) WH.plot_multiple_indivs(BLOOD, results, axes = c(1, 2), var = 1, HISTO = FALSE)results <- WH.MultiplePCA(BLOOD, list.of.vars = c(1:3), graph = FALSE) WH.plot_multiple_indivs(BLOOD, results, axes = c(1, 2), var = 1, HISTO = TRUE) WH.plot_multiple_indivs(BLOOD, results, axes = c(1, 2), var = 1, HISTO = FALSE)
Plots the quantiles of the histogram variables on a factorial plane after
WH.MultiplePCA (or WH.1d.PCA): the quantiles of
each variable form a fan.
WH.plot_multiple_Spanish.funs( res, axes = c(1, 2), var = 1, LABS = TRUE, multi = TRUE, corplot = TRUE )WH.plot_multiple_Spanish.funs( res, axes = c(1, 2), var = 1, LABS = TRUE, multi = TRUE, corplot = TRUE )
res |
The results of |
axes |
A vector of two integers, the factorial axes (default
|
var |
A vector of integers, the variables to plot. |
LABS |
A logical value (default |
multi |
A logical value: |
corplot |
A logical value: if |
The plot is drawn on the current device and the ggplot object
is returned invisibly.
res <- WH.MultiplePCA(BLOOD, list.of.vars = c(1:3), graph = FALSE) WH.plot_multiple_Spanish.funs(res, axes = c(1, 2), var = c(1:3))res <- WH.MultiplePCA(BLOOD, list.of.vars = c(1:3), graph = FALSE) WH.plot_multiple_Spanish.funs(res, axes = c(1, 2), var = c(1:3))
Computes goodness of fit indices of the predictions of a
WH.regression.two.components model.
WH.regression.GOF(observed, predicted)WH.regression.GOF(observed, predicted)
observed |
A |
predicted |
A |
A list with the root mean squared error based on the L2 Wasserstein
distance (RMSE_W), the OMEGA index and the pseudo-R2 index
(PSEUDOR2, with the details of the decomposition of the sum of
squares).
Irpino, A., Verde, R. (2015). Linear regression for numeric symbolic variables: a least squares approach based on Wasserstein Distance. Advances in Data Analysis and Classification, 9, 81-106. doi:10.1007/s11634-015-0197-7
model.parameters <- WH.regression.two.components(data = BLOOD, Yvar = 1, Xvars = c(2:3)) Predicted.BLOOD <- WH.regression.two.components.predict( data = BLOOD[, 2:3], parameters = model.parameters ) WH.regression.GOF(observed = BLOOD[, 1], predicted = Predicted.BLOOD)model.parameters <- WH.regression.two.components(data = BLOOD, Yvar = 1, Xvars = c(2:3)) Predicted.BLOOD <- WH.regression.two.components.predict( data = BLOOD[, 2:3], parameters = model.parameters ) WH.regression.GOF(observed = BLOOD[, 1], predicted = Predicted.BLOOD)
Linear regression of a histogram variable on a set of histogram variables, based on the decomposition of the L2 Wasserstein distance into a component for the means and a component for the centred distributions. The parameters are estimated by least squares (non-negative least squares for the centred component).
WH.regression.two.components(data, Yvar, Xvars, simplify = FALSE, qua = 20)WH.regression.two.components(data, Yvar, Xvars, simplify = FALSE, qua = 20)
data |
A |
Yvar |
An integer, the column of the dependent variable. |
Xvars |
A vector of integers, the columns of the explanatory variables. |
simplify |
A logical value (default |
qua |
An integer, the number of quantiles when |
A named vector with the estimated parameters: the intercept and the
coefficients of the means (prefix AV_) and the coefficients of the
centred distributions (prefix CEN_).
Irpino, A., Verde, R. (2015). Linear regression for numeric symbolic variables: a least squares approach based on Wasserstein Distance. Advances in Data Analysis and Classification, 9, 81-106. doi:10.1007/s11634-015-0197-7
WH.regression.two.components.predict,
WH.regression.GOF
model.parameters <- WH.regression.two.components(data = BLOOD, Yvar = 1, Xvars = c(2:3)) model.parametersmodel.parameters <- WH.regression.two.components(data = BLOOD, Yvar = 1, Xvars = c(2:3)) model.parameters
Predicts the histograms of the dependent variable using the parameters
estimated by WH.regression.two.components.
WH.regression.two.components.predict(data, parameters)WH.regression.two.components.predict(data, parameters)
data |
A |
parameters |
The named vector of parameters returned by
|
A MatH object with one column, the predicted histograms.
model.parameters <- WH.regression.two.components(data = BLOOD, Yvar = 1, Xvars = c(2:3)) Predicted.BLOOD <- WH.regression.two.components.predict( data = BLOOD[, 2:3], parameters = model.parameters )model.parameters <- WH.regression.two.components(data = BLOOD, Yvar = 1, Xvars = c(2:3)) Predicted.BLOOD <- WH.regression.two.components.predict( data = BLOOD[, 2:3], parameters = model.parameters )
Compute the matrix of the sums of squared deviations from the mean
(WH.SSQ), the variance-covariance matrix (WH.var.covar) and the
correlation matrix (WH.correlation) of the variables of a MatH
object, according to the L2 Wasserstein metric. The functions with suffix 2
compute the same (rectangular) matrices between the variables of two
MatH objects with the same number of rows.
## S4 method for signature 'MatH' WH.SSQ(object, w = numeric(0)) ## S4 method for signature 'MatH' WH.var.covar(object, w = numeric(0)) ## S4 method for signature 'MatH' WH.correlation(object, w = numeric(0)) ## S4 method for signature 'MatH,MatH' WH.SSQ2(object1, object2, w = numeric(0)) ## S4 method for signature 'MatH,MatH' WH.var.covar2(object1, object2, w = numeric(0)) ## S4 method for signature 'MatH,MatH' WH.correlation2(object1, object2, w = numeric(0))## S4 method for signature 'MatH' WH.SSQ(object, w = numeric(0)) ## S4 method for signature 'MatH' WH.var.covar(object, w = numeric(0)) ## S4 method for signature 'MatH' WH.correlation(object, w = numeric(0)) ## S4 method for signature 'MatH,MatH' WH.SSQ2(object1, object2, w = numeric(0)) ## S4 method for signature 'MatH,MatH' WH.var.covar2(object1, object2, w = numeric(0)) ## S4 method for signature 'MatH,MatH' WH.correlation2(object1, object2, w = numeric(0))
object |
A |
object1, object2
|
Two |
w |
A vector of non-negative weights, one for each row (individual). Default: equal weights. |
A numeric matrix.
Irpino, A., Verde, R. (2015) Basic statistics for distributional symbolic variables: a new metric-based approach, Advances in Data Analysis and Classification, 9(2), 143-175. doi:10.1007/s11634-014-0176-4
WH.SSQ(BLOOD) WH.var.covar(BLOOD) WH.correlation(BLOOD) # weighted, with random weights RN <- runif(get.MatH.nrows(BLOOD)) WH.var.covar(BLOOD, w = RN) # between two sets of variables WH.correlation2(BLOOD[, 1], BLOOD[, 2:3])WH.SSQ(BLOOD) WH.var.covar(BLOOD) WH.correlation(BLOOD) # weighted, with random weights RN <- runif(get.MatH.nrows(BLOOD)) WH.var.covar(BLOOD, w = RN) # between two sets of variables WH.correlation2(BLOOD[, 1], BLOOD[, 2:3])
WH.vec.sum and WH.vec.mean compute the (weighted) sum and the
(weighted) mean of all the histograms of a MatH object, consistently
with the L2 Wasserstein metric: the result is the histogram whose quantile
function is the (weighted) sum or mean of the quantile functions. The mean is
the Wasserstein barycenter of the histograms.
## S4 method for signature 'MatH' WH.vec.sum(object, w = numeric(0)) ## S4 method for signature 'MatH' WH.vec.mean(object, w = numeric(0))## S4 method for signature 'MatH' WH.vec.sum(object, w = numeric(0)) ## S4 method for signature 'MatH' WH.vec.mean(object, w = numeric(0))
object |
A |
w |
A vector of non-negative weights, one for each cell of the matrix. Default: equal weights. |
A distributionH object.
WH.vec.mean(BLOOD) WH.vec.sum(BLOOD) # weighted mean with random weights RN <- runif(get.MatH.nrows(BLOOD) * get.MatH.ncols(BLOOD)) WH.vec.mean(BLOOD, w = RN)WH.vec.mean(BLOOD) WH.vec.sum(BLOOD) # weighted mean with random weights RN <- runif(get.MatH.nrows(BLOOD) * get.MatH.ncols(BLOOD)) WH.vec.mean(BLOOD, w = RN)