1
$\begingroup$

I have a dataset that looks like this:

enter image description here

I would like to use R and find out if being assigned to group "A" rather than "B" (or vice-versa) may depend on "age", "gender" or "school" (or a combination of these):

which kind of analysis should I conduct? Thank you very much!

$\endgroup$
4
  • $\begingroup$ Do you want to know whether the assignment to $A$ or $B$ depends on those features or do you want to find a way to actually predict the assignment? $\endgroup$
    – frank
    Apr 7, 2022 at 11:18
  • $\begingroup$ Hi Frank, I would like to explore whether the assignment to A or B depends on those other features. Thank you! $\endgroup$
    – Fabio
    Apr 7, 2022 at 12:15
  • $\begingroup$ This is similar: stats.stackexchange.com/questions/73646/… $\endgroup$
    – frank
    Apr 7, 2022 at 12:54
  • $\begingroup$ Sorry, I may not have the necessary theoretical background to see the similarity... I thought the variables I have in my dataset are not exactly of the continuous type, am I wrong? Thank you! $\endgroup$
    – Fabio
    Apr 7, 2022 at 13:19

1 Answer 1

1
$\begingroup$

Nearly all algorithms need data in numerical form. If you have binary or categorical data, the usual approach would be to use dummy or one-hot encoding that code different categories as zeroes and ones. In practice, modern software would often do this for you, for example in R if you use the factor datatype (it is likely that R already used it for your data, you check it with the is.factor function) that under the hood produces the dummy encoding representation of the data when needed.

If you want to "find out if being assigned to group "A" rather than "B" (or vice-versa) may depend on "age", "gender" or "school" (or a combination of these)", this sounds like a logistic regression problem. Logistic regression would work out of the box with factor data.

$\endgroup$
2
  • $\begingroup$ Hi Tim, thank you for you reply. Would you mind to suggest an R function which you think would work to run a logistic regression for my dataset, keeping in mind my goal? Thank you very much! $\endgroup$
    – Fabio
    Apr 7, 2022 at 13:15
  • $\begingroup$ @Fabio as said above, most likely you don't need to do anything specific, it'd probably just work. If the variables are strings, use as.factor to transform them. If you're asking about general help with R, the question would be better suited for R users Q&A sites. $\endgroup$
    – Tim
    Apr 7, 2022 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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