如何将序数数据输入菊花函数

How to input ordinal data into daisy function

我有一个包含 12 个变量的数据集,每个变量的值都在 1 到 4 之间,并且将被视为序数。如果我不指定它们的类型,它们将被视为间隔类型

> attributes(gower_dist)
$class
[1] "dissimilarity" "dist"         

$Size
[1] 5845

$Metric
[1] "mixed"

$Types
 [1] "I" "I" "I" "I" "I" "I" "I" "I" "I" "I" "I" "I"

但如果我添加 'type=list(ordratio=1:12)',类型将变为 'T',我确定它代表什么。如果它不代表序数,那么我如何告诉菊花我输入的是序数数据?

> attributes(gower_dist)
$class
[1] "dissimilarity" "dist"         

$Size
[1] 5845

$Metric
[1] "mixed"

$Types
 [1] "T" "T" "T" "T" "T" "T" "T" "T" "T" "T" "T" "T"

简答

如果您指定了序数比并观察结果类型为 "T",这就是预期的行为。

长答案:

我看了一下 daisy 函数。 Types 属性有 6 个可能的值:

typeCodes <- c("A", "S", "N", "O", "I", "T")

我在调试模式下使用不同的参数循环了几次该函数。此属性的映射如下所示:

  • 如果指定type = list(asymm=<whichever columns in the dataset>):"A"

  • 如果指定type = list(symm=<whichever columns in the dataset>):"S"

  • 如果指定type = list(ordratio=<whichever columns in the dataset>):"T"

如果您指定类型,或者您指定type=list(logratio=<whichever columns in the dataset>),并且您的数据集的列是:

  • 因素:"N"

  • 已订购:"O"

  • 数字/整数:"I"

(不确定为什么 logratio 没有自己的类型,但这可能离题了...)