I'm trying to double check that the Linear Discriminant Analysis function is doing what I think it is, and that the associated model lines up.
I create my data frame, run it through lda() and predict() and it changes the order in some way I don't understand, so I can't manually check that things work using the generated coefficients
My_Data <-as.data.frame( cbind(
c("CBT","CBT","CBT","CBT","CBT","CBT","CBT","CBT","CBT","CBT","BT","BT","BT","BT","BT","BT","BT","BT","BT","BT","No_Treatment_Control","No_Treatment_Control","No_Treatment_Control","No_Treatment_Control","No_Treatment_Control","No_Treatment_Control","No_Treatment_Control","No_Treatment_Control","No_Treatment_Control","No_Treatment_Control"),
as.numeric(c(5,5,4,4,5,3,7,6,6,4,4,4,1,1,4,6,5,5,2,5,4,5,5,4,6,4,7,4,6,5)),
as.numeric(c(14,11,16,13,12,14,12,15,16,11,14,15,13,14,15,19,13,18,14,17,13,15,14,14,13,20,13,16,14,18))))
colnames(My_Data) <- c("Group","Thoughts","Actions")
ocdDFA<-lda(Group ~ Actions + Thoughts, data = My_Data)
predict(ocdDFA)
plot(ocdDFA, fill = "Group")
This produces: LDA_Output
I should be able to get the predict(ocdDFA)$x values by taking each row of my data and going...
LD1 = Coefficient_ActionAction_Value + Coefficient_ThoughtsAction_Thoughts.
But the output from predict() changes the order of my data points, so I can't actually test this. ( I can tell because the order of Group changed from my original My_Data ) Predict_LDA_Output
So I'm wondering.
- What is actually happening to the order
- Why isn't the sum of coefficient*values lining up with the output from predict()?