| Title: | Fuzzy C-Means for Fuzzy Data |
|---|---|
| Description: | Implements a fuzzy clustering approach for ordinal Likert-type data using triangular fuzzy numbers (TFNs). The package extends the classical fuzzy C-means algorithm to better handle uncertainty in ordinal scales and includes automatic selection of the number of clusters using the Xie-Beni validity index. References: Coppi, R., D'Urso, P., and Giordani, P. (2012), "Fuzzy and possibilistic clustering for fuzzy data", <doi:10.1016/j.csda.2010.09.013>. Xie, X. L. and Beni, G. (1991), "A validity measure for fuzzy clustering", <doi:10.1109/34.85677>. |
| Authors: | José Ortigas [aut, cre] |
| Maintainer: | José Ortigas <jose.ortigas@unmsm.edu.pe> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-10-10 16:19:34 UTC |
| Source: | https://github.com/cran/fcmfd |
Assigns each observation to the cluster with the highest membership value.
cluster_assignment(object)cluster_assignment(object)
object |
An object of class "fcmTFN". |
A factor indicating cluster labels.
Computes the size of each cluster using both hard assignments and fuzzy memberships.
cluster_size(object)cluster_size(object)
object |
An object of class "fcmTFN". |
Hard size is obtained by assigning each observation to the cluster with the highest membership degree.
Fuzzy size is computed as the sum of membership degrees for each cluster.
A data.frame containing:
Cluster label.
Number of observations assigned to the cluster.
Sum of membership degrees.
Performs fuzzy clustering on ordinal Likert-type data represented as triangular fuzzy numbers (TFNs).
fcmTFN( data, type = "symmetric", option = "B", dictionary = NULL, k_values = 2:6, m = 2, epsilon = 1e-06, max_iter = 1000, verbose = TRUE )fcmTFN( data, type = "symmetric", option = "B", dictionary = NULL, k_values = 2:6, m = 2, epsilon = 1e-06, max_iter = 1000, verbose = TRUE )
data |
A data.frame or matrix containing ordinal Likert-type responses. Rows represent observations (respondents) and columns represent variables (items or dimensions). All values must be integers within the range defined by the selected scale option. |
type |
A character string specifying the type of fuzzy dictionary to use. Must be one of "symmetric" for predefined symmetric triangular fuzzy numbers, or "asymmetric" for a user-defined custom dictionary. Defaults to "symmetric". |
option |
A character string indicating the Likert scale option. Must be one of "A" (5-point scale, 1–5), "B" (7-point scale, 1–7), "C" (10-point scale, 1–10), or "D" (11-point scale, 0–10). Defaults to "B". |
dictionary |
An optional numeric matrix with 3 columns (l, c, r) representing the lower bound, modal value, and upper bound of each triangular fuzzy number. Required when type = "asymmetric"; ignored when type = "symmetric". Defaults to NULL. |
k_values |
A numeric vector specifying the candidate numbers of clusters to evaluate. The algorithm runs independently for each value of k. Defaults to 2:6. |
m |
Fuzzifier parameter (m > 1) specifying the fuzzifier parameter, which controls the degree of membership overlap between clusters. Higher values produce softer partitions. Defaults to 2. |
epsilon |
A positive numeric value specifying the convergence tolerance. The algorithm stops when the change in the objective function between iterations falls below this threshold. Defaults to 1e-06. |
max_iter |
A positive integer specifying the maximum number of iterations allowed per run. If convergence is not reached within this limit, a warning is issued. Defaults to 1000. |
verbose |
A logical value. If TRUE, progress messages are printed to the console during execution, including iteration count and convergence status for each value of k. Defaults to TRUE. |
The function automatically determines the optimal number of clusters based on the Xie-Beni validity index.
An object of class '"fcmTFN"' and '"fcm"'.
Coppi, R., D'Urso, P., & Giordani, P. (2012). Fuzzy and possibilistic clustering for fuzzy data. <doi:10.1016/j.csda.2010.09.013>
Xie, X. L., & Beni, G. (1991). A validity measure for fuzzy clustering. <doi:10.1109/34.85677>
Returns the fuzzy membership matrix obtained from the Fuzzy C-Means clustering process.
membership(object)membership(object)
object |
An object of class "fcmTFN". |
A matrix where rows represent observations and columns represent clusters.
Evaluates the quality of fuzzy assignments for each cluster using membership-based measures.
membership_quality(object)membership_quality(object)
object |
An object of class "fcmTFN". |
This function computes both cluster-specific metrics based on hardened assignments (maximum membership rule) and global partition criteria to evaluate how well-defined the fuzzy boundaries are.
A list containing:
Data frame with one row per cluster containing:
Hard_Size: number of observations primarily assigned to the cluster.
Avg_Membership: average membership of those observations.
Avg_Margin: average difference between the largest and second-largest memberships, indicating the clarity of assignment.
Global partition coefficient (PC).
Global partition entropy (PE).
Plots the triangular fuzzy numbers defining the Likert-scale dictionary.
plot_dictionary(object, show_title = TRUE, ...)plot_dictionary(object, show_title = TRUE, ...)
object |
An object of class "fcmTFN". |
show_title |
Logical. If TRUE (default), displays the plot title. |
... |
Additional graphical parameters. |
Invisibly returns NULL.
Visualizes cluster prototypes as interval plots using triangular fuzzy numbers (l, c, r).
plot_prototypes( object, cluster = 1, view = c("single", "global"), use_var_names = FALSE, var_names = NULL, show_title = TRUE, ... )plot_prototypes( object, cluster = 1, view = c("single", "global"), use_var_names = FALSE, var_names = NULL, show_title = TRUE, ... )
object |
An object of class "fcmTFN". |
cluster |
Integer cluster to plot when view = "single". |
view |
Character string indicating the visualization mode. Either "single" or "global". |
use_var_names |
Logical. |
var_names |
Optional character vector of variable names. |
show_title |
Logical. If TRUE (default), displays the plot title. |
... |
Additional graphical parameters. |
Invisibly returns NULL.
Plots the Xie-Beni validity index across candidate numbers of clusters.
plot_xb(object, mark_optimal = TRUE, type = "b", show_title = TRUE, ...)plot_xb(object, mark_optimal = TRUE, type = "b", show_title = TRUE, ...)
object |
An object of class "fcmTFN". |
mark_optimal |
Logical. Whether to highlight the optimal k. |
type |
Character string indicating the plotting style (default = "b"). |
show_title |
Logical. If TRUE (default), displays the plot title. |
... |
Additional graphical parameters. |
Invisibly returns NULL.
Displays a concise summary of a fitted fuzzy C-means model using triangular fuzzy numbers.
print_fcmTFN(x, ...)print_fcmTFN(x, ...)
x |
An object of class "fcmTFN". |
... |
Additional arguments (not used). |
The input object (invisibly).
Returns cluster prototypes either as a flat matrix or as a list of tables containing l, c, r values for each variable.
prototype_results( object, use_var_names = FALSE, var_names = NULL, format = c("flat", "table") )prototype_results( object, use_var_names = FALSE, var_names = NULL, format = c("flat", "table") )
object |
An object of class "fcmTFN". |
use_var_names |
Logical. |
var_names |
Optional variable names. |
format |
Character string indicating the output format: "flat" (default) returns the original matrix representation, while "table" returns one table per cluster. |
If format = "flat", a data.frame containing prototype values.
If format = "table", a named list of data.frames, one for each cluster.
A simulated Likert-type dataset with three well-separated clusters, specifically designed for testing fuzzy clustering of ordinal data.
sim_likert7sim_likert7
A data frame with 300 rows and 12 variables:
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
Simulated survey response measured on a 1–7 Likert scale.
The dataset contains 300 observations divided into three distinct clusters of 100 observations each. Data generation was based on three latent profiles centered approximately at:
Low agreement: 2
Moderate agreement: 4
High agreement: 6
Simulated data generated for package examples.
Survey data on subjective well-being, optimism, gratitude, emotional closeness, worry, and depression, collected from university students.
students_wellbeingstudents_wellbeing
A data frame with 651 rows and 9 variables:
| Q13.1 | Satisfaction with life overall. |
| Q13.2 | Satisfaction with life at the present moment. |
| Q13.3 | Satisfaction with oneself. |
| Q13.4 | Satisfaction with physical appearance. |
| Q13.5 | Satisfaction with ability to communicate with others. |
| Q13.6 | Satisfaction with overall health. |
| Q13.7 | Satisfaction with achievements in life so far. |
| Q13.8 | Satisfaction with the college. |
| Q13.9 | Satisfaction with college classmates. |
All variables are measured on an 11-point ordinal scale ranging from 0 to 10, where higher values indicate greater satisfaction.
Martinez, L., Valencia, I., Trofimoff, V., & Valenzuela, L. S. (2020). Students wellbeing during COVID-19. <doi:10.17632/w9brygpwg7.2>
Displays a summary of the Fuzzy C-Means clustering results for triangular fuzzy numbers.
## S3 method for class 'fcmTFN' summary(object, ...)## S3 method for class 'fcmTFN' summary(object, ...)
object |
An object of class "fcmTFN". |
... |
Additional arguments (not used). |
Prints a formatted summary of the clustering result.