longer object length is not a multiple of shorter object length

I am computing a test error using this code

test_error = mean((train_set$dis - yhat_test)^2)
test_error

R is given me a warning which say "longer object length is not a multiple of shorter object length"
I kind of know the issue. I think the train_set is a list and yhat_test is a double, which is why i am getting the warning.

I think it is more likely to be a result of the difference in lengths of train_set$dis and yhat_test.

While you're finding test error, shouldn't you compare the predictions for test dataset with the expected results of test dataset? Why are you comparing with expectations of the training dataset? My point is, don't you want this?

mean((test_set$dis - yhat_test)^2)

If this is not the case, can you please provide a REPRoducible EXample of your problem? It provides more specifics of your problem, and it helps others to understand what problem you are facing.

If you don't know how to do it, take a look at this thread:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Many Thanks for pointing this out.