Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is it possible to use asclogit with choice sets that vary across individuals?

    To interested Statalist users -

    I am attempting to model a student's choice of university using a conditional logit model with the asclogit package. In my data, I have individuals with different choice sets since each student is choosing from a different subset of schools.

    This is an example with a structure similar to what I have in my data:
    Student_ID University Distance GPA Choice
    1 1 23 3.2 0
    1 2 24 3.2 1
    1 3 45 3.2 0
    2 1 33 3.8 0
    2 3 5 3.8 0
    2 4 10 3.8 1
    2 8 34 3.8 0
    where GPA is individual i's academic quality and distance = distance from individual i to university j

    Different individuals have different choice sets because not every student is considering the same school (i.e. a student may only be looking at schools within a certain distance).

    The book "Microeconometrics Using Stata" says that "The asclogit command allows the choice set to vary across individuals".

    I have 2 questions:

    1) Can the command asclogit be actually used to estimate a conditional logit model with data like the one above (in which we have individuals with different choice sets)?

    2) Do the choice sets of the individuals have to have at least one of the alternatives which is always common across the individuals? If not, how can one set a base alternative?
    For example: asclogit choice distance, casevars(gpa) case(id) alternatives (university) basealternative(1)

    Any comments or suggestions are appreciated (i.e. if this is not possible in asclogit are there any other packages or methods that would work?)

    Thank you.

    Regards,

    Andrew

  • #2
    Andrew,

    An example long data structure for conducting asclogit with both alternative-specific and case-specific variables is shown below, listing only the first two cases. This example data structure includes 8 choice sets per subject with 3 alternatives per choice set. In this example, each subject requires 24 lines of data (8 choice sets times 3 alternatives).

    Each alternative (altno) includes 5 alternative-specific variables (altrvar1-altrvar5). The alternative-specific variables vary within choice sets. (The values of the alternative-specific variables can be created using Optimal Experimental Design techniques such as implement in the user-written dcreate ado program (written by Arne Risa Hole and available to install via ssc).

    There are 2 case-specific variables, jobyears (for experience) and age. The case-specific variables are constant within choice sets and only vary across subjects (id).

    The variable dchoice contains the discrete choice (1, 2, or 3). The variable choice is a binary indicator of the choice within a choice set and was derived from dchoice.

    Code:
    id    choicset altno dchoice choice altrvar1 altrvar2 altrvar3 altrvar4 altrvar5 jobyears age     
    34    1    1    1    1    1    2    0    1    3    1    25     
    34    1    2    1    0    3    1    0    2    2    1    25     
    34    1    3    1    0    2    2   20    3    1    1    25     
    34    2    1    2    0    2    1   -5    2    1    1    25     
    34    2    2    2    1    2    3    0    1    2    1    25     
    34    2    3    2    0    3    3    5    3    3    1    25     
    34    3    1    1    1    3    2   10    1    1    1    25     
    34    3    2    1    0    1    3    5    2    1    1    25     
    34    3    3    1    0    2    1    0    3    3    1    25     
    34    4    1    2    0    1    1   20    1    2    1    25     
    34    4    2    2    1    2    2    5    1    3    1    25     
    34    4    3    2    0    1    3    0    3    1    1    25     
    34    5    1    1    1    3    3   -5    1    3    1    25     
    34    5    2    1    0    2    1   10    2    3    1    25     
    34    5    3    1    0    3    2    5    3    2    1    25     
    34    6    1    1    1    2    3   10    1    1    1    25     
    34    6    2    1    0    1    1   -5    3    3    1    25     
    34    6    3    1    0    1    2   20    2    3    1    25     
    34    7    1    3    0    3    1   20    1    1    1    25     
    34    7    2    3    0    1    2   10    3    2    1    25     
    34    7    3    3    1    2    3   20    2    2    1    25     
    34    8    1    2    0    1    1    5    1    1    1    25     
    34    8    2    2    1    3    2    0    2    1    1    25     
    34    8    3    2    0    2    2   -5    1    2    1    25     
    35    9    1    1    1    1    2    0    1    3    4    31     
    35    9    2    1    0    3    1    0    2    2    4    31     
    35    9    3    1    0    2    2   20    3    1    4    31     
    35    10    1    2    0    2    1   -5    2    1    4    31     
    35    10    2    2    1    2    3    0    1    2    4    31     
    35    10    3    2    0    3    3    5    3    3    4    31     
    35    11    1    1    1    3    2   10    1    1    4    31     
    35    11    2    1    0    1    3    5    2    1    4    31     
    35    11    3    1    0    2    1    0    3    3    4    31     
    35    12    1    2    0    1    1   20    1    2    4    31     
    35    12    2    2    1    2    2    5    1    3    4    31     
    35    12    3    2    0    1    3    0    3    1    4    31     
    35    13    1    1    1    3    3   -5    1    3    4    31     
    35    13    2    1    0    2    1   10    2    3    4    31     
    35    13    3    1    0    3    2    5    3    2    4    31     
    35    14    1    3    0    2    3   10    1    1    4    31     
    35    14    2    3    0    1    1   -5    3    3    4    31     
    35    14    3    3    1    1    2   20    2    3    4    31     
    35    15    1    3    0    3    1   20    1    1    4    31     
    35    15    2    3    0    1    2   10    3    2    4    31     
    35    15    3    3    1    2    3   20    2    2    4    31     
    35    16    1    3    0    1    1    5    1    1    4    31     
    35    16    2    3    0    3    2    0    2    1    4    31     
    35    16    3    3    1    2    2   -5    1    2    4    31 
    


    Following are some basic instructions for running asclogit on a data set with the variables and data structure shown in the example above.

    Code:
    * Create macro (AltVars) for a list of the 5 alternative-specific variables.
    local AltVars altrvar1 altrvar2 altrvar3 altrvar4 altrvar5
    
    * Create macro (CaseVars) for a list of the 2 case-specific variables.
    local CaseVars jobyears age
    
    * Run asclogit with robust clustering on case ID (id) to adjust for within-subject correlation.
    asclogit choice `AltVars', case(choicset) alternatives(altno) casevars(`CaseVars') vce(cluster id)

    You could also run this discrete choice analysis using clogit instead of asclogit, but you would need to create and include variables for the interactions of the alternatives with the case-specific variables.

    Good luck.

    Red Owl
    (Yes, that's my real name.)

    Comment


    • #3
      Thank you for the reply - but it fails to get to the core of the issue which is modeling a situation where each individual is facing a different choice set.

      Comment


      • #4
        Andrew,

        You can have different choice sets for different subjects in the data structure I used as an example above.

        Note that the variable choicset in my example data structure has 8 choice sets repeated for each of two subjects. However, also note that the choice sets are uniquely numbered from 1 to 16.

        The choice sets presented to subject 35 could be different from those presented to subject 34.

        Does that get to the core of the issue?

        Red Owl

        Comment


        • #5
          Originally posted by Red Owl View Post
          Andrew,

          Does that get to the core of the issue?

          Red Owl
          Ahhh... OK thank you a bunch. I understand your example better now and I have it working better than before.

          However, I run into a "dimension of beta incorrect" error when I try to add more than 2 alternative specific variables. Any ideas what might be causing this?

          Comment


          • #6
            I have not seen that error before with asclogit, and I have used more than 2 alternative-specific variables. The most recent DCE study with which I was involved had 6 alternative-specific variables plus 6 case-specific variables. It was run with Stata/IC version 14.1.

            What flavor (Stata's word, not mine) and version of Stata are you using. You may have a matrix size limitation problem, but I don't know why that would happen with the data structure you described.

            If you think that might be the problem, you can read about matsize limits for various flavors of Stata at:
            Code:
            help matsize
            Red Owl

            Comment


            • #7
              In _help asclogit_ I find the following:
              alternatives(varname) specifies the variable that identifies the alternatives for each case. The number of alternatives can vary with each case; the
              maximum number
              of alternatives cannot exceed the limits of tabulate oneway; see [R] tabulate oneway.
              That sounds like it may be the source of your problem.

              Red Owl

              Comment


              • #8
                Originally posted by Red Owl View Post
                In _help asclogit_ I find the following:
                alternatives(varname) specifies the variable that identifies the alternatives for each case. The number of alternatives can vary with each case; the
                maximum number
                of alternatives cannot exceed the limits of tabulate oneway; see [R] tabulate oneway.
                That sounds like it may be the source of your problem.

                Red Owl
                Hello,
                After I read this "In _help asclogit_ I find the following:
                alternatives(varname) specifies the variable that identifies the alternatives for each case. The number of alternatives can vary with each case; the
                maximum number
                of alternatives cannot exceed the limits of tabulate oneway; see [R] tabulate oneway.
                " I still did not understand what do those words mean? Could you please explain a little bit?

                Comment

                Working...
                X