2
$\begingroup$

I have a data set in the form:

df
  occupation  class
1     lawyer  upper
2     doctor  upper
3 unemployed middle
4    plumber  lower
5 unemployed  upper

The first variable occupation has only 8 values that it can take, and class can only take 3. I am trying to predict the class variable based on the occupation.

I have an idea about predicting continuous independent variables with continuous dependent variables (for example, linear regression). And logistic regressions with categorical dependent variables. But what about both sides of the equation being categorical? Does it even involve regressions or are there a simpler set of method to regress class ~ occupation?

And the opposite situation categorical_data ~ binary_dummy_variable. If X is a binary variable. How can I predict a categorical variable on that dummy variable?

I'm thinking that I would need to turn occupation into a dummy variable and explore the relationship that way. Especially since there is no specific scaling order to the variable. Perhaps turning occupation into a new binary variable "professional" "non-professional". But I still wouldn't know how to compare the new binary output to the class variable.

$\endgroup$
  • $\begingroup$ I would just use Naive Bayes. It is very well implemented in sklearn for example. Alternatively, you can just use logistic regression, since it is applicable for both categorical input and output variables. BTW: Since you seem to use R for data analysis, R internally transforms your factor (!) variables on the fly into dummy variables when optimizing; you can check this out by looking at the model.matrix in R. $\endgroup$ – JimBoy Dec 18 '16 at 9:33
1
$\begingroup$

The easiest way is to break your data down into eight groups. You can do this by writing an occupation vector $x=(v_1,v_2,\cdots,v_7)$ where $v_i=1$ if you're in category $i$ and 0 otherwise. You need to set a reference category correponding to $v=(0,0,0,\cdots,0)$, say "lawyer". Then a simple logistic regression should do the job. Then you have a linear response: $Y=X\beta$ which you map with a logit function to a probability. This way you can see which categories influence more than others.

$\endgroup$
  • $\begingroup$ So it's okay to regress $Y = X\beta$ if $Y$ can take on 5 values and $X$ can take 2 using a normal logistic regression as I would with a continuous $X$? $\endgroup$ – Pierre Lafortune Oct 24 '15 at 1:23
  • $\begingroup$ Also will this turn out to be one long regression or 8 separate? $Y = Xlaywer\beta lawyer + Xdoctor\beta doctor \cdots$ $\endgroup$ – Pierre Lafortune Oct 24 '15 at 1:40
  • $\begingroup$ @PierreLafortune: You could do a double logistic regression: the first tests if the class is lower. If not, you then run a second one for middle and upper. $\endgroup$ – Alex R. Oct 24 '15 at 5:54
1
$\begingroup$

In terms of quantitative methods, in addition to Logit Regression mentioned by Alex there is also Discriminant Analysis and Correspondence Analysis. Both those methods are I think easily doable and well explained in a simple and reasonably priced software program called XLStat. Those methods are most probably doable in R, SAS, Python. You would have to look up the documentation on those within whatever program you use.

$\endgroup$

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.