Error in Unused Arguments

Hi all,

I have been using the example from this website without any issue at all:

https://www.r-bloggers.com/2020/05/multinomial-logistic-regression-with-r/

However there is now an error.

Here is a code snippet of the problem, once the BreastTissue data is loaded.

require(nnet)
# Training the multinomial model
multinom_model <- multinom(Class ~ ., data = tissue)

# Predicting the values for train dataset
train$ClassPredicted <- predict(multinom_model, newdata = train, "class")

Error Message below:

Error in predict(multinom_model, newdata = train, "class") : 
  unused arguments (newdata = train, "class")

It is no longer working and I have tried to delete the current version and go back a couple of versions with R studio to see if that would fix the problem, but still no luck. Very strange. Any guidance on how to solve an issue like this?

Thank you.

Let's confirm that objects are what you expect. What is the result of

class(multinom_model)

I think the result should include nnet.formula.

What is the result of

train$ClassPredicted <- predict.nnet(multinom_model, newdata = train, type = "class")

I ran the following.

Result of

class(multinom_model)

is

[1] "multinom" "nnet"    

and the result of

train$ClassPredicted <- predict.nnet(multinom_model, newdata = train, type = "class")

is

Error in predict.nnet(multinom_model, newdata = train, type = "class") : 
  could not find function "predict.nnet"

If you run

search()

is package::nnet in the returned values?

yes "package:nnet" is returned in the list

Does

methods(predict)

show anything related to nnet?

It does. Thank you FJCC.
Endless hours later... after clearing the workspace it is now working.
Still strange as I would have expected that to work after deleting R and reinstalling etc.
I do appreciate your input.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.