# Is there a way to measure the effect of categorical factors?

Assume having a dataset composed of 3 source columns and 1 results column. Here I'd like to measure the effect of A, B from source3 based on the results. However, results column is also affected by the other numerical features, like source1, source2. Is there an effective method to measure this effect of categorical features while excluding the effect of numerical features?

>>data
source1 source2 source3 results
1       1       7       A       9
2       2       8       A      11
3       3       9       B      14
4       4      10       B      16
5       5      11       B      18


Running a linear regression including all three source variables will spit out a beta coefficient for source3. It is interpreted as the expected change in results as we change from source3's category A to category B (or vice versa depending on software implementation), while keeping fixed the values of source1 and source2. So if your data (approximately) meet the assumptions of linear regression this is seems like a nice, well-trodden path for you to choose.
• I'm sorry but I don't quite understand your notation in step2. Step 1 is to run a linear regression, Step 2 is extract the regression coefficient from the model and interpret it. In R this would be coef(lm(results~source1+source2+source3, data = data)). It will give you a coefficient for source3 which is interpreted as the effect of source3 on resultswhile holding constant source1 and source2. So you are controlling for the effects of those variables. This sounds like what you wanted in the OP. – klumbard Jun 21 '18 at 13:16
• Furthermore, linear regression is a well-understood modeling technique and is very interpretable. A neural network is a black box and is typically used for a prediction exercise; you're not learning as much about the effect of source3 from a neural network. Rather you're trying to maximize the accuracy of your results predictions, and sacrificing interpretability in doing so – klumbard Jun 21 '18 at 13:19
• step2 here f(B->A) means after having the model, we then substitute all A by B. According to the suggestion, via coef(lm), we get f=1+ 1* source1 + 2*source2 + source3B. However, notice that from this lm model, we still can't exactly comment on the effect of source3B and source3A. are we saying source3A has no effect? – HappyCoding Jun 24 '18 at 9:09