# mlogit: restrict coefficient of alternative-invariant variable to be equal for alt

#### ga34gep

##### New Member
Hi. For evaluating a choice experiment I estimate a conditional logit model with mlogit in R .

The output looks like this:
HTML:
Call:
mlogit(RES ~ Money + X1a + X1b + X2a + X2b | Age,
data = CE,  reflevel = "C", shape = "long", alt.var = "ALT", method = "nr",
print.level = 0)

Frequencies of alternatives:
C       A       B
0.56206 0.22340 0.21454

nr method
5 iterations, 0h:0m:1s
g'(-H)^-1g = 1.09E-07

Coefficients :
Estimate Std. Error  t-value  Pr(>|t|)
A:(intercept)  0.9541021  0.3779952   2.5241 0.0115991 *
B:(intercept)  1.0174949  0.4033790   2.5224 0.0116547 *
X1a             -0.7386523  0.1960883  -3.7669 0.0001653 ***
X1b             -2.1118971  0.2563337  -8.2389 2.220e-16 ***
X1a             -1.0645459  0.2822902  -3.7711 0.0001625 ***
X2b             -3.3511706  0.3283743 -10.2053 < 2.2e-16 ***
Money           0.0102814  0.0028901   3.5574 0.0003745 ***
A:Age            0.8188962  0.1400442   5.8474 4.993e-09 ***
B:Age            0.5245825  0.1287723   4.0737 4.627e-05 ***
---
Problem: I want only one single intercept and only one single variable Age instead of one intercept and one Age variable for each alternative A and B.

The Method:
• In the experiment, persons of different age (=alternative-invariant variable) had to fill out two choice sets. In each choice set, the person had to choose between three alternatives: A, B, and C (=reference).
• Each alternative has three attributes (alternative-variant variables): X1, X2, and Money.
• Each of the attributes has two levels, denoted "a" and "b", or a number for the monetary attribute.

Question: How do I restrict the coefficient for my alternative invariant variable ("Age") to be equal for alternative A and B?

The long format of the data looks like this: Note: ALT = Alternative (A, B, or C); QES = number of choice set; RES = Choice of the person; X1a, X1b, X2a, X2b = Alternative-variant variables; Age = Alternative-invariant variable

A reviewer suggested this for my paper. Can someone help?

#### ga34gep

##### New Member
Re: mlogit: restrict coefficient of alternative-invariant variable to be equal for al

Okay, I need to be more specific:

Through specifying the reference level "C", I am normalizing the coefficient for option "C" to zero. Now I still have two options, "A" and "B". I want to normalize the difference of the error terms between "A" and "B" to one, basically equalizing the coefficient of "A" and "B". Does someone know how to do this normalization by scale?

#### JesperHP

##### TS Contributor
Re: mlogit: restrict coefficient of alternative-invariant variable to be equal for al

If you want to make the intercept the same for A and B alternatives you could try to remove the intercept using +0 in the formula, then you could add an alternative invariant variable coded 0 when alternative chosen is C and 1 when alternative chosen is A or B. Look at the buttom of page 9 of "Estimation of multinomial logit models in R : The mlogit Packages" to see an example of the model matrix where train, bus car each has an intercept and air is reference level. Instead of a model matrix with three columns in this example you need one column equal to the sum of the three, hence one for alternatives train bus car and zero for reference air.

#### ga34gep

##### New Member
Re: mlogit: restrict coefficient of alternative-invariant variable to be equal for al

I could still not get it to work. See the simple code below for how I tried to implement your suggestions. I have the options "charter", "boat", "beach", and "pier". However, I estimate it only for the subset of alternatives "charter", "boat", and "beach". Then I want to constrain the coefficient for "boat" and "beach" to yield a single estimate.

library("mlogit")
data("Fishing", package = "mlogit")
Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice = "mode")

## charter as the reference level
m1 <- mlogit(mode ~ price+ catch | income, data = Fish, reflevel = "charter",alt.subset = c("charter","beach","boat"))
summary(m1)

Fish$alt2 <- Fish$alt
Fish$alt2[Fish$alt2 == "boat"] <- 1; Fish$alt2[Fish$alt2 == "beach"] <- 1; Fish$alt2[Fish$alt2 == "charter"] <- 0

m2 <- mlogit(mode ~ price+ catch | income+0+alt2, data = Fish, reflevel = "charter",alt.subset = c("charter","beach","boat"))
summary(m2)
I do not only want a single intercept but also a single coefficient for the alternative-invariant variables. For the "Fishing" example it means that instead of getting this outcome:
Code:
                     Estimate  Std. Error  t-value  Pr(>|t|)
beach:(intercept) -1.5508e+00  2.3679e-01  -6.5495 5.775e-11 ***
boat:(intercept)  -1.1157e+00  1.6187e-01  -6.8925 5.484e-12 ***
price             -2.1168e-02  1.8320e-03 -11.5550 < 2.2e-16 ***
catch              2.5066e-01  1.1321e-01   2.2141   0.02682 *
beach:income       1.9751e-05  5.4197e-05   0.3644   0.71554
boat:income        1.2558e-04  2.8889e-05   4.3471 1.380e-05 ***
I would like to get something like this:
Code:
                     Estimate  Std. Error  t-value  Pr(>|t|)
(intercept)  -1.1157e+00  1.6187e-01  -6.8925 5.484e-12 ***
price             -2.1168e-02  1.8320e-03 -11.5550 < 2.2e-16 ***
catch              2.5066e-01  1.1321e-01   2.2141   0.02682 *
income        1.2558e-04  2.8889e-05   4.3471 1.380e-05 ***

#### JesperHP

##### TS Contributor
Re: mlogit: restrict coefficient of alternative-invariant variable to be equal for al

I do not only want a single intercept but also a single coefficient for the alternative-invariant variables.
I do not think that is possible due to identification issues, they become uindentifiable compared to the constant because the variable itself do not vary over alternatives (but I'm not completely sure about this). Read Kenneth Train book on discrete choice http://eml.berkeley.edu/books/choice2.html. If I remember correctly it is explained in chapter 1 and 2.

As for the constant you almost had it (I told you to add as alternative invariant but I found out it should be as alternative specific).
Don't do : price+ catch | income+0+alt2
Do : price+ catch +alt2| income+0

Code:
library("mlogit")
data("Fishing", package = "mlogit")
Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice = "mode")

## charter as the reference level
m1 <- mlogit(mode ~ price+ catch | income, data = Fish, reflevel = "charter",alt.subset = c("charter","beach","boat"))
summary(m1)

Fish$beachdummy <- Fish$alt
Fish$beachdummy[Fish$beachdummy == "beach"] <- 1;
Fish$beachdummy[Fish$beachdummy == "charter"] <- 0;
Fish$beachdummy[Fish$beachdummy == "boat"] <- 0;
Fish$boatdummy <- Fish$alt
Fish$boatdummy[Fish$boatdummy == "boat"] <- 1;
Fish$boatdummy[Fish$boatdummy == "charter"] <- 0;
Fish$boatdummy[Fish$boatdummy == "beach"] <- 0;

## EXACTLY THE SAME CONSTANT TERMS AS MODEL m1 OK SO THE METHOD WORKS
m2 <- mlogit(mode ~ price+ catch+beachdummy+boatdummy | income+0, data = Fish, reflevel = "charter",alt.subset = c("charter","beach","boat"))
summary(m2)

## NOW FOR THE RESTRICTION (as you did)
Fish$alt2 <- Fish$alt
Fish$alt2[Fish$alt2 == "boat"] <- 1; Fish$alt2[Fish$alt2 == "beach"] <- 1; Fish$alt2[Fish$alt2 == "charter"] <- 0

# changing the place for alt2
m3 <- mlogit(mode ~ price+ catch+alt2 | income+0, data = Fish, reflevel = "charter",alt.subset = c("charter","beach","boat"))
summary(m3)