我想将16个连续的(7点Likert Scale)变量分成三个单独的类别,然后使用一个因子对其进行方差分析。目前,我在将变量聚在一起以使其作为方差分析运行时遇到了问题。这就是我到目前为止所拥有的。
> class(test)
data.frame
> colnames(test)
[1] "S1" "S2" "S3" "S4" "S5" "S6" "S7" "S8"
[9] "S9" "S10" "S11" "S12" "S13" "S14" "S15" "S16"
[17] "Condition"
> lapply(test[,1:16], class)
numeric
> class(test$Condition)
factor
如何将变量组合在一起-例如,S1-5、S6-10、S11-16 -并使用因子test$Condition作为自变量?
发布于 2014-12-05 19:23:12
我身上没有代码,但我最初的目标是用一种复杂的方法将变量聚集在一起,并将错误降至最低。相反,在组合变量时,我选择了两种方法: 1)对组进行平均;2)对组进行汇总。然而,应该注意的是,所选方法对输出(即beta权重、边际均值等)有影响-p值保持不变。
发布于 2016-04-10 17:49:28
# this function give you the number of clusters as variable n in R # # programming test your datastes.
clusrer.data <- function(test,n) {
data <- t(test)
z <- rbind(data)
(cl <- kmeans(z, n))
cl
}
调用函数
clusrer.data(test, 3)# give you 3 clusters each cluster have 5 features.
然后我认为你可以使用带有3个聚类的单向方差分析,这是来自# k-means的结果。
https://stackoverflow.com/questions/27006027
复制相似问题