0

The achievement variable has three different values. All N/A and null values have already been removed from the dataset. When I try to run the confusion matrix code I receive the error "all arguments must have the same length."

    glm.fit=multinom(Achievement~Time.Played, data=thesis2)
    summary(glm.fit)
    predict(glm.fit, thesis2, "probs")
    dim(thesis2)
    set.seed(101)  
    train= thesis2[1:225928,] 
    test= thesis2[225929:451856,] 
    glm.fit=multinom(Achievement~Time.Played, data=train)
    glm.predict=predict(glm.fit, test, "probs",na.action=na.omit)
    dim(test)
    dim(glm.predict)
    length(glm.predict)
    length(Achievement.test)
    table(glm.predict,test$Achievement)
    mean(glm.predict==Achievement.test)
----------

Error in table(glm.predict, test$Achievement) : all arguments must have the >same length 2. stop("all arguments must have the same length") 1.table(glm.predict, test$Achievement)

However the glm.predict has the dimensions 225928 6 and the test$Achievement has the dimensions 225928 3. I have looked at the other posts about the arguments not having the same length, and I can not figure out what is wrong with my code. Please help.

  • Please share your code ! All you have shared is a stacktrace :/ – Cukic0d Jul 11 '18 at 16:07
  • Above the stacktrace is the code, but here is it again. glm.fit=multinom(Achievement~Time.Played, data=thesis2) summary(glm.fit) predict(glm.fit, thesis2, "probs") dim(thesis2) set.seed(101) train= thesis2[1:225928,] test= thesis2[225929:451856,] glm.fit=multinom(Achievement~Time.Played, data=train) glm.predict=predict(glm.fit, test, "probs",na.action=na.omit) dim(test) dim(glm.predict) length(glm.predict) length(Achievement.test) table(glm.predict,test$Achievement) mean(glm.predict==Achievement.test) – Kristi Titler Jul 12 '18 at 16:34

0 Answers0