# Correct statistics technique for prob below

I am kind-of stuck with a small problem here. I can't find a proper statistics based technique which will solve my problem!

Problem: I have a dependent variable (Categorical 4 Levels), and 6 Independent variables (all Categorical). I am trying to find out rules which will tell me how my dependent variable is getting affected by independent variables.

Eg: Say my dependent is Time which has 4 levels - Morning, Afternoon, Evening and Night. My Independent are, say 3 variables - Gender (Male/Female), SalaryBin (Bin1, Bin2, Bin3, Bin4) and Dept (IT, Marketing, Ops).

I want to just understand and NOT predict what kind of people come to office at a particular time. My results can be in form - Morning :- 75% Female, Bin2&Bin3 ,IT ; Afternoon:- 55% Male, Marketing Bin1 & Bin4.

Now the techinques i have tried include : RF and DT (CHAID using rPart in R). Would be great if someone could just point me toward the right technique for the above problem. I can take care of the rest.

## migrated from stackoverflow.comNov 14 '17 at 10:00

This question came from our site for professional and enthusiast programmers.

Seeing as you haven't really given any code I too am not going to provide any as I feel your question is more for the information & techniques behind it.

When creating models such as random forests it can be hard to actually visualise what is going on under the hood but a good starting point would be to compute a feature importance plot.

You can achieve this by using the function varImp(rfModel).

Another good way of visualising the model is to create some partial dependence plots as seen below.

The y axis is the models response and the x is the value (usually sampled from its minimum to its maximum). These plots are neat when trying to understand how different values impact your models outcome.

I can't speak directly for random forests but I use this a lot when visualising interactions with neural networks. It's quite nice to be able to hold the other inputs at a constant value (which can be adjusted usually by creating a matrix). Being able to change these constant values allows you to create different profiles in your model.

E.g. I wonder how age effects the models outcome for males who smoke.

The above can easily be answered with such plots.

Anyway, I hope this has helped out in some way but please feel free to comment if you feel it necessary.

https://cran.r-project.org/web/packages/datarobot/vignettes/PartialDependence.html

In the case that partial dependence plots are a right fit for your use case, I think this package may be of use: https://cran.r-project.org/web/packages/pdp/pdp.pdf

If you don't want to predict the outcome, you should use a standard contingency table for your issue. After that you could may use some Chi-Squared Tests for independence, or something like that.

As alredy noticed by Nico Shabadoo, what you need is probably just a simple contingency table. If you want to extract meaningful groups from your data, you may use one of the methods for clustering, e.g. hierarchical clustering, or latent class analysis. If you wanted interpretable model that would enable you also to make predictions, you could try using a some kind of decision tree (you would predict time by using other variables).