[R] resolving expand.grid & NA errors

Bob Green bgreen at dyson.brisnet.org.au
Sun Mar 25 22:29:43 CEST 2007


I am hoping for some advice regarding resolving error messages I have 
received when trying to use the expand.grid command.

library(nnet)
library(MASS)
library(car)
mod.multacute <-multinom(kc$group ~ kc$in.acute.danger * 
kc$violent.convictions, na.rm=T)
summary(mod.multacute, cor=F, Wald=T)
Anova (mod.multacute)
confint (mod.multacute)

 > predictors <- expand.grid(group=1:3, in.acute.danger = c("y","n"), 
violent.convictions = c("y","n"))
 > p.fit <- predict(mod.multacute, predictors, type='probs')
Error in predict.multinom(mod.multacute, predictors, type = "probs") :
         NAs are not allowed in subscripted assignments
In addition: Warning message:
'newdata' had 12 rows but variable(s) found have 160 rows

There are two errors - the NA error which I thought would have been 
removed in line 3 above. I also tried ra.omit.
I know there will be a difference between the raw data and the new 
data but do not know what I need to change to be able to successfully 
run the command.

What I want to do is obtain the fitted probabilities and plot them.

Any suggestions are appreciated,

Bob Green



More information about the R-help mailing list