Solved – Multinomial logistic regression and marginal effects

logitrregression

I am trying to calculate the marginal effects of a multinomial logistic regression. To do this I use the mlogit package and the effects() function.

Here is how the procedure works (source : effects() function of mlogit package) :

data("Fishing", package = "mlogit")
Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice = "mode")
m <- mlogit(mode ~ price | income | catch, data = Fish)
# compute a data.frame containing the mean value of the covariates in the sample
z <- with(Fish, data.frame(price = tapply(price, index(m)$alt, mean), 
	catch = tapply(catch, index(m)$alt, mean), 
income = mean(income)))
# compute the marginal effects (the second one is an elasticity
effects(m, covariate = "income", data = z)
effects(m, covariate = "price", type = "rr", data = z)
effects(m, covariate = "catch", type = "ar", data = z)

I have no problem with first step (mlogit.data() function). I think my problem is in the specification of the multinomial regression.

My regression (for example with three variables) is on the form: Y ~ 0 | X1 + X2 + X3. When I try to estimate the marginal effects for a model with 2 variables, there is no problem, however for 3 variables R console returns me the following error: "Error in if (rhs% in% c (1, 3)) {: argument is of length zero " (translation from error in R console in french).

To understand what is my problem I tried to perform a multinomial regression of similar shape on the dataset "Fishing", i.e.,: mode ~ 0 | income + price + catch (even if this form has no "economic" sense.) Again the R console returns me the same error for 3 variables but manages to estimate these effects for a model with two variables.

This leads me to think that my problem really comes from the specification of my multinomial regression. Do you know how I could find a solution to my problem? Or could you suggest another logit multinomial regression form?

Best Answer

The | is used to separate individual variant and alternative variant regressors. In this example, price and catch rate vary through alternatives (fishing from a pier, beach,..) and income does not change depending on alternatives.

So, I'm inclined to advise you to write your mlogit regression like so:

 m<-mlogit(mode ~ price + catch| income , data = Fish, reflevel="beach")

Then you can call:

 effects(m,covariate="{insert whichever you want}",type="{whichever you select}")

I tried it on a subset of this data and it worked.

Related Question