Skip to content

reduced set of alternatives in package mlogit

4 messages · Jose Marcos Ferraro, Christopher David Desjardins, John Kane

#
-----Original Message-----
From: Bert Gunter [mailto:bgunter.4567 at gmail.com] 
Sent: quinta-feira, 31 de mar?o de 2016 20:22
To: Jose Marcos Ferraro <jose.ferraro at LOGITeng.com>
Cc: r-help at r-project.org
Subject: Re: [R] reduced set of alternatives in package mlogit

code? example data?  We can only guess based on your vague post.

"PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code."

Moreover, this sounds like a statistical question, not a question about R programming, and so might be more appropriate for a statistical list like stats.stackexchange.com  .

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Mar 31, 2016 at 2:51 PM, Jose Marcos Ferraro <jose.ferraro at logiteng.com> wrote:
Sorry if I was not clear enough, but  there is hardly any code to show. 
The problem is that a parameter or function is lacking (or , mostly likely, I can't find it), so in some sense the problem itself is that  there is no code to show.

In what follows choice situations , alternatives, wide, and variables have the same meaning that they have on the mlogit documentation. All variables are alternative specific.

1)I want to estimate a multinomial Logit  using the mlogit package

2)I have a dataset, made of choice situations

3)There is a set of alternatives

4)in some choice situations, not all alternatives were available, but only a subset of them. So there are no variables for the unavailable alternatives and the chosen alternative evidently  belongs to the set of available ones.

5)I use mlogit.data to prepare the dataset from a "wide" dataframe . There is no option to have only a subset of alternatives and the resulting object will have them all , that is, there will be a line for every alternative and every choice situation, even if in reality some of them were not available. The variables of these alternatives did not exist, so must be filled with 0s or any other made up value

6) If ones estimate a model from this data it will be wrong

7) It is possible to get an "almost right" model by using a dummy variable marking which alternatives are unavailable, for as it is only used in alternatives that are never chosen, its coefficient will get negative with big absolute value, in practice giving almost 0% probability for them

8)this is a workaround because it obligates the model to estimate a number that should be -infinity and this is known in advance, so it's ugly and difficult to know what the numeric consequences are as the coefficient can never converge. In fact, I don't use it the way I described for these reasons, preferring a more complex but almost equivalent formulation. The important point is that I want a clean solution, not a workaround

9)I demand simply if mlogit package has such functionality
#
Hi Jose,

You're referring to your response variable when you're saying it's missing
some of the choices, right? Are your response choices ever known or do they
just occur with extremely low frequency? Either way, I think the mlogit
package would be inappropriate for you. I imagine you would have much
better luck using MCMCpack or writing a model with rstan or something
Bayesian. Unless I'm missing something.

Chris



On Fri, Apr 1, 2016 at 8:40 AM, Jose Marcos Ferraro <
jose.ferraro at logiteng.com> wrote:

            

  
  
12 days later
#
code? example data?  We can only guess based on your vague post.

"PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code."

Moreover, this sounds like a statistical question, not a question about R programming, and so might be more appropriate for a statistical list like stats.stackexchange.com<http://stats.stackexchange.com>  .

Cheers,
Bert


Bert Gunter



Sorry if I was not clear enough, but  there is hardly any code to show.
The problem is that a parameter or function is lacking (or , mostly likely, I can't find it), so in some sense the problem itself is that  there is no code to show.

In what follows choice situations , alternatives, wide, and variables have the same meaning that they have on the mlogit documentation. All variables are alternative specific.

1)I want to estimate a multinomial Logit  using the mlogit package

2)I have a dataset, made of choice situations

3)There is a set of alternatives

4)in some choice situations, not all alternatives were available, but only a subset of them. So there are no variables for the unavailable alternatives and the chosen alternative evidently  belongs to the set of available ones.

5)I use mlogit.data to prepare the dataset from a "wide" dataframe . There is no option to have only a subset of alternatives and the resulting object will have them all , that is, there will be a line for every alternative and every choice situation, even if in reality some of them were not available. The variables of these alternatives did not exist, so must be filled with 0s or any other made up value

6) If ones estimate a model from this data it will be wrong

7) It is possible to get an "almost right" model by using a dummy variable marking which alternatives are unavailable, for as it is only used in alternatives that are never chosen, its coefficient will get negative with big absolute value, in practice giving almost 0% probability for them

8)this is a workaround because it obligates the model to estimate a number that should be -infinity and this is known in advance, so it's ugly and difficult to know what the numeric consequences are as the coefficient can never converge. In fact, I don't use it the way I described for these reasons, preferring a more complex but almost equivalent formulation. The important point is that I want a clean solution, not a workaround

9)I demand simply if mlogit package has such functionality





Hi,
I meant that in some choice situations there are some alternatives missing, but the available alternatives are known to everybody(both the one that made the choice as well as to who collected the data).
For future reference, I would like to post here that I found the answer.
Apparently it is not possible if one uses mlogit.data  with shape = ?wide?, but it is if one uses it with shape = ?long? .
So basically one can create an alternative specific variable with availability (let?s call it is_avaliable) and use mlogit.data  normally that is :
all_avaliable <- mlogit.data(df , shape = ?wide? , ?)
then one can subset it
real_avaliability <-  all_avaliable[all_avaliable$is_avaliable ,]
and resend it through mlogit.data with format long
mlogit.data(real_avaliability , shape = "long" , alt.var = "alt" ,  chid.var = "chid", ?)
please observe that alt and chid will have been created by the first call to mlogit.data
#
To back up Ber's please have a look at
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and/or http://adv-r.had.co.nz/Reproducibility.html

John Kane
Kingston ON Canada
____________________________________________________________
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if5
Capture screenshots, upload images, edit and send them to your friends
through IMs, post on Twitter?, Facebook?, MySpace?, LinkedIn? ? FAST!