Ryan Murray
Ryan Murray

Reputation: 23

Error of ' "MaxNWts" matched by multiple actual arguments'

I'm receiving a matched arguments error when attempting to run MICE. I've tried increasing the maxits and maxnwts, but I'm still getting errors.

mice(df, m = 7, printFlag = FALSE, maxit = 350, seed = 123, MaxNWts = 50000)

Error in nnet.default(X, Y, w, mask = mask, size = 0, skip = TRUE, softmax = TRUE, : formal argument "MaxNWts" matched by multiple actual arguments Calls: mice ... sampler.univ -> do.call -> mice.impute.polyreg -> multinom

Upvotes: 2

Views: 812

Answers (1)

Leonardo Fontenelle
Leonardo Fontenelle

Reputation: 118

Now that you added the maxit and MaxNWts arguments to mice(), you are getting a different error, aren't you?

As stated in its documentation, mice() actually calls other functions when imputing the variables. mice.impute.polyreg(), which is part of the error message, is the default imputation function for categorical variables. If you read the documentation for mice.impute.polyreg(), you will see that its argument is called nnet.MaxNWts, not MaxNWts. mice.impute.polyreg() passes the value of nnet.MaxNWts to the MaxNWts argument of nnet::multinom().

If you provide an MaxNWts argument for mice.impute.polyreg(), it will pass two MaxNWts to nnet::multinom(): one with the default value of nnet.MaxNWts, and another (via the ...) with the value you supplied. The error message itself seems to originate from match.call(), inside nnet::multinom().

You could (re)produce this error by simply typing mean(x = 1, x = 2).

If you replace MaxNWts with nnet.MaxNWts in your call, you should stop receiving this error message.

Please notice that you didn't actually ask your question, just communicated you are (still) getting an error message. Let me know if my answer is not what you needed.

Due credit: This answer is an expanded version of another one, by Gordon Li. I myself found that answer when I got the same error message as you!

Upvotes: 2

Related Questions