r - stepAIC handling of multinom models -


i seeing weird behavior stepaic function in mass package when dealing multinomial logistic models. here sample code:

library(nnet) library(mass) example("birthwt") race.model <- multinom(race ~ smoke, bwt) race.model2 <- stepaic(race.model, k = 2) 

in case race.model , race.model2 have identical terms; stepaic did not prune anything. however, need query attributes of models, , error race.model2:

formula(race.model)[2] 

returns race() but

formula(race.model2)[2] 

gives error:

    error in terms.formula(newformula, specials = names(attr(termobj, "specials"))) :  invalid model formula in extractvars 

this behavior seems occur when stepaic not remove terms model. in following code, terms removed stepaic, , both models can queried:

race.big <- multinom(race ~ ., bwt) race.big2 <- stepaic(race.big, k = 2) formula(race.big)[2] formula(race.big2)[2] 

any ideas going wrong here?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -