Hi R-users
I try to calculate marginal effects of a multinomial logistic regression. To do this i use mlogit package and effects() function.
Here is how the procedure works (source : effects() function of mlogit package) :
I have no problem with first step (mlogit.data() function). I think my problem is on the specification of the multinomial regression.
My regression (for example with three variables) is on the form:
. When I try to estimate the marginal effects for model with 2 variables 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", that is to say :
(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?
Thank you for your help
I try to calculate marginal effects of a multinomial logistic regression. To do this i use mlogit package and effects() function.
Here is how the procedure works (source : effects() function of mlogit package) :
Code:
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)
My regression (for example with three variables) is on the form:
Code:
Y ~ 0 | X1 + X2 + X3
To understand what is my problem I tried to perform a multinomial regression of similar shape on the dataset "Fishing", that is to say :
Code:
mode ~ 0 | income + price + catch
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?
Thank you for your help