Announcement

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

  • Mixed logit models

    I'm interested to develop a mixed logit model for crash injury severity. My response variable is "injury severity" that is categorical with 3 levels (i.e. minor injury, serious injury, fatality). There are various explanatory variables but I would list few of them. Land use (urban, rural), lighting (day, evening, night), vehicle type (passenger car, light truck, heavy truck), speed limit, driver age, and vehicle age are the explanatory variables. "Land use", "lighting" and "vehicle type" are also categorical. There are more than 2000 observations.
    I would be really grateful if I may be provided with the code for mixed logit model in STATA and how te create a dataset for a mixed logit severity model
    Thank you.

  • #2
    This is a very big ask for a single post here. It seems that you have conceptualized our project but not yet taken even the first steps towards implementation.

    I'm guessing that you do not yet have a Stata data set to work with; your data is in some other format, perhaps a text file or a spreadsheet. So the first step is to import that. If your data is in Excel, see -help import excel-. If it is a delimited text file, see -help import delimited-. If it is in a fixed-width text file (these are less common nowadays), see -help infix-. Get your data into Stata first.

    You will probably need to do some data cleaning or creation of new variables, or reorganizing your data. I'm sure that people on the Forum will be happy to answer specific questions you have as you proceed. Do your best to make progress on your own. When you get stuck, post back with concrete questions. Be sure, when doing so, to show example data (using the -dataex- command to do so), show the code you tried (in code delimiters, see FAQ #12) and the results Stata gave you (also in code delmiters). And make sure to give a clear explanation of how what you got is not what you wanted.

    Once your data are set, given the nature of your outcome variable, it does not sound suitable for a logit model, because it is not dichotomous. More appropriate would be either ordinal logistic regression (-ologit-) or perhaps multinomial logistic regression (-mlogit-). I don't see anything in your explanation of the context that suggests that a mixed model is needed here: you haven't described any nesting structure among the observations in the data.

    Please do read the entire Forum FAQ for excellent advice on how to post questions in ways that maximize your chance of getting a timely and helpful response.

    If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.



    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X