2

I am trying to add1 all interaction terms on top of a multinomial baseline model using multinom() but it shows the error

trying + x1:x2 
Error in if (trace) { : argument is not interpretable as logical
Called from: nnet.default(X, Y, w, mask = mask, size = 0, skip = TRUE, softmax = TRUE, 
    censored = censored, rang = 0, ...)

What is the problem here? I appreciate any input. Here is a reproducible example:

require(nnet)
data <- data.frame(y=sample(1:3, 24, replace = TRUE), 
        x1 = c(rep(1,12), rep(2,12)),
        x2 = rep(c(rep(1,4), rep(2,4), rep(3,4)),2),
        x3=rnorm(24),
        z1 = sample(1:10, 24, replace = TRUE))

m0 <- multinom(y ~ x1 + x2 + x3 + z1, data = data)
m1 <- add1(m0, scope = .~. + .^2, test="Chisq")

My end goal is to see which terms are appropriate to drop by later adding the line m1[order(add1.m1$'Pr(>Chi)'),].

cliu
  • 933
  • 6
  • 13
  • 1
    try replacing add1 with update using the same arguments. – G. Grothendieck Mar 29 '21 at 15:15
  • Thank you for your comment @G.Grothendieck. Although it works and doesn't show the error message, I couldn't get the model fit information (test="Chisq") as I would normally get from the add1() function – cliu Mar 29 '21 at 15:34
  • Try `m1 <- update(m0, scope = .~. + .^2); anova(m0, m1, test = "Chisq")` – G. Grothendieck Mar 29 '21 at 15:46
  • Thanks again @G.Grothendieck. However, the `anova` approach is doing a sort of global comparison to see which *model* is better but I would like to do it in a stepwise fashion to see which *terms* to keep and which to drop. I know I can still use the `anova` approach by slowing building and comparing the models one at a time but it is time consuming and I have a lot of variables. – cliu Mar 29 '21 at 16:06

0 Answers0