0
$\begingroup$

I have a dataset containing traffic crash information. One variable in the set is the number of fatalities that resulted in the crash, which has the values 0, 1, 2, and 3.

I am working in R and want to create a logistic regression model to predict the probability that fatalities >= 1. In order words, what is the likelihood that a traffic incident will result in at least one fatality? How would I do this? I am thinking I need to create a new binary variable such that fatalities=yes (1) and fatalities=no (0), but I'm wondering if there's a more simple way. Not that creating the binary variable would be difficult, I guess I'm just wondering if the predictor variable has to be binary, or if it is possible to just set a condition on it (i.e. fatalities>=1)?

$\endgroup$
3
  • 3
    $\begingroup$ This seems like mostly a programming question, and should go on Stack Overflow. But in R you can do it in the formula directly by using the I() function. mod <- glm(I(fatalities >= 1) ~ x1 + x2, ...). Or you could create a new variable using >= and refer to that instead, as you describe. Both should be equivalent $\endgroup$ May 10 at 15:04
  • 2
    $\begingroup$ Yould look into ordinal logistic regression, search this site. $\endgroup$ May 10 at 15:42
  • 1
    $\begingroup$ Thank you, David! That worked beautifully. And I appreciate the feedback. This was my first question to this site, but I will be sure to use Stack Overflow for programming questions in the future. $\endgroup$
    – Amyxdomz
    May 11 at 16:14

1 Answer 1

-3
$\begingroup$

You could try that binary transformation, directly or as suggested by @david. However, data transformation could change the odds.

For example, if you have $n_{f_0} = 25$, $n_{f_1} = 25$, $n_{f_2} = 25$, $n_{f_3}=25$, now you'll have $n_{f_0}=25$ and $n_{f_1new}=75$. So, the odds are likely to change too much.

Perhaps, you should try first to run the model with $f_0$ and $f_1$ (the original) and then extend the model the $f_{1new}$. And observe the difference.

If results don't seem reasonable (extreme odds), then the easy way is not feasible. Thus you might need to look to ordinal logit, as suggested by @kjetil, which can give you estimated probabilities such as $P[f>1]$.

$\endgroup$
14
  • 4
    $\begingroup$ This has nothing to do with "territory" or feelings and everything to do with what this site is for and how it works. It's ridiculous to request that others do your editing for you. Please read our help center for more. $\endgroup$
    – whuber
    May 11 at 11:45
  • 4
    $\begingroup$ I am moderating, not harassing. If you object to moderation, this is not the site for you, because everybody (with a sufficient reputation) is a moderator. $\endgroup$
    – whuber
    May 11 at 11:59
  • 4
    $\begingroup$ Whuber is correct. The purpose of comments is to clarify the material in questions and answers. It's very hard to see how this exchange, which asks a clarifying question about the answer, and then explains how this site works, could possibly be harassment, bigotry or abuse. $\endgroup$
    – Sycorax
    May 11 at 12:21
  • 4
    $\begingroup$ I’ve reviewed every reply you’ve received. Nothing seems out of the ordinary: you’ve received feedback about your answers. The purpose of comments is to clarify the content of the answer. If you’re not open to receiving feedback when your answers are unclear or ambiguous, you are not going to enjoy using this website. Please review the help center for more information about how the site works, because it will be hard for your to understand the goals of the site & how to use it without reading it. $\endgroup$
    – Sycorax
    May 11 at 13:04
  • 4
    $\begingroup$ Again, nothing you've experienced rises to the level of "unfriendly or unkind" as described in the code of conduct. Again, the purpose of comments is to clarify the material in questions and answers. You've written a number of short, ambiguous answers; pointing that out is part and parcel of how this site works. Before you spend any time or money finding an attorney to pursue a legal claim, I strongly suggest that you take the time to familiarize yourself with how this site works. If you don't like getting feedback on a website, you really won't like getting laughed out of a courtroom. $\endgroup$
    – Sycorax
    May 11 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.