Hi Louis,
It seems to me that the easiest way to accomplish what you want is to
just define an extractAIC method for objects of class "mlogit". I am
not familiar with multinomial logistic models, so this may not be
correct (I am especially uncertain about the degrees of freedom I
used), but it should get you close. You just need to edit the formula
to be correct and then step(), etc. should all work.
extractAIC.mlogit <- function (fit, scale = 0, k = 2, ...) {
n <- length(fit$residuals)
edf <- length(fit$coefficients)
aic <- (-2 * fit$logLik) + k + edf
c(edf, aic + (k - 2) * edf)
}
You can also look at:
require(MASS)
?stepAIC
Hope this helps,
Josh
On Mon, Jun 20, 2011 at 12:36 PM, Merlin, Louis <lmerlin at email.unc.edu>
wrote:> I am trying to perform a backwards stepwise variable selection with an
mlogit model. ?The usual functions, step(), drop1(), and dropterm() do not work
for mlogit models.
>
>
>
> Update() works but I am only able to use it manually, i.e. I have to type
in each variable I wish to remove by hand on a separate line.
>
>
>
> My goal is to write some code that will systematically remove a certain set
of variables one at a time and compare the AIC of each alternative model.
>
>
>
> i.e.:
>
>
>
> famodel1.mn <- mlogit(Chosen ~ 0 + q23_wt + park_avg + walk_avg +
aesth_avg + Length + ln_ps, data = data.mn)
>
> I wish to remove each of "q23_wt", "park_avg",
"walk_avg" and "aesth_avg" one at a time from the above
model, without having to type each version manually.
>
>
>
> Louis Merlin
>
>
>
>
>
>
>
> ________________________________
>
> Mr. Louis Merlin, AICP
>
> Doctoral Student
>
> UNC CH Department of City and Regional Planning
>
> ? ? ? ?[[alternative HTML version deleted]]
Per the posting guide, please post in plain text, not HTML.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/