Cluster variables together and run ANOVA

1.6k Views Asked by At

I want to cluster 16 continuous (7-point Likert Scale) variables into three separate categories, and then use a factor to run an ANOVA against it. Currently, I'm having problems with clustering the variables together so it can be run as an ANOVA. This is what I have so far.

> 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

How do I cluster variables together - say, S1-5, S6-10, S11-16 - and use the factor test$Condition as the independent variable?

2

There are 2 best solutions below

0
On

I don't have the code on me, but originally I was aiming for a sophisticated method to cluster variables together with minimal errors. Instead, I opted for two methods when combining the variables: 1) averaging the groups; 2) summing up the groups. One should note, however, that the selected method has an impact on the output (i.e., beta weights, marginal means, etc.) - p-values remain the same.

0
On
# 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

 }

recall function

 clusrer.data(test, 3)# give you 3 clusters each cluster have 5 features.

then i think you can use one way ANOVA with 3 clusters, as a result from the # k-means.