Segments - Save Variable(s) - Cluster Membership
Jump to navigation
Jump to search
Creates a new variable that allocates cases to the most similar cluster (e.g., people to segments) in an output generated by using the function Create > Segments > K-Means Cluster Analysis. Observations with missing values in the predictors are not predicted.
To run this script, the setting Inputs > Output should be set to Means.
Example
The script produces a SUMMARY table with the new variable (each category corresponds to a cluster):
Code
var __webpack_modules__ = ({});
// The module cache
var __webpack_module_cache__ = {};
// The require function
function __webpack_require__(moduleId) {
// Check if module is in cache
var cachedModule = __webpack_module_cache__[moduleId];
if (cachedModule !== undefined) {
return cachedModule.exports;
}
// Create a new module (and put it into the cache)
var module = (__webpack_module_cache__[moduleId] = {
exports: {}
});
// Execute the module function
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
// Return the exports of the module
return module.exports;
}
// webpack/runtime/rspack_version
(() => {
__webpack_require__.rv = () => ("1.7.2")
})();
// webpack/runtime/rspack_unique_id
(() => {
__webpack_require__.ruid = "bundler=rspack@1.7.2";
})();
includeWeb('QScript R Output Functions');
saveVariables('Segment/Cluster memberships', 'K-means Cluster Analysis', 'predict(', ', use.names = TRUE)', 'Pick One', null, 'memb', 'KMeans');
See Also
Further reading: Market Segmentation Software