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

时间:2017-08-19 08:18:43

标签: r r-daisy

我有一个包含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"

1 个答案:

答案 0 :(得分:2)

简短回答

如果您指定了序数比率&观察结果类型为“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>),&amp;您的数据集列是:

  • 因素:“N”

  • 下令:“O”

  • 数字/整数:“我”

(不知道为什么logratio没有自己的类型,但这可能会在这里讨论主题......)