wss | R Documentation |
This function calculates sums of squares of residuals with respect to mean for observations with weights.
wss(x,w = rep(1,nrow(x)))
x |
A data matrix (data frame, data table, matrix, etc.) containing only entries of class numeric. |
w |
Vector of length nrow(x) of weights for each observation in the dataset. Must be of class numeric or integer. If NULL, the default value is a vector of 1 with length nrow(x), i.e., weights equal 1 for all observations. |
In this function, for a dataset with observational weights, the weighted mean for the dataset is calculated first. Based on it, the weighted sum of squares of residuals with respect to the weighted mean is calculated with observational weights. This could be used to calculate weighted within-cluster sum of squares for one cluster of data with observational weights.
a length-one numeric vector.
Javier Cabrera, Yajie Duan, Ge Cheng
require(cluster)
# The Ruspini data set from the package "cluster""
x = as.matrix(ruspini)
# assign random weights to observations
w = sample(1:10,nrow(x),replace = TRUE)
wss(x,w)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.