# Interpreting Nominal Variables

data = {{a, 0, 1}, {b, 2, 2}, {a, 2, 1.8}, {b, 0, 2.5}};
nom = LinearModelFit[data, {x, y}, {x, y}, NominalVariables -> x]
Normal[nom]
LinearModelFit[data, {x, y}, {x, y},
NominalVariables -> All] // Normal


output = 2.175 +0.07499999999999996(y) - 0.8500000000000001 DiscreteIndicator[x,a,{a,b}]

Can someone help me interpret the output from this code? Its from the mathematics documentation guide. Does this mean that the effect of "a" has a negative effect of .85 on the total effect?

You might very well get a more complete answer about interpreting "dummy" variables from Cross Validated (http://stats.stackexchange.com) and find existing answers there. However, here is the short version for your model and data.

Because x has two values (a and b), you are essentially fitting two intercepts. Call those $a$ and $b$. (And I'll also use $a$ and $b$ to denote the two different data sources.) Without giving any other options to LinearModelFit, Mathematica gives you $b$ and $a-b$ which are estimated to be 2.175 and -0.8500000000000001, respectively.

So the intercept $a$ is 2.175 + (-0.8500000000000001) = 1.325.

I wouldn't label $a$ as having a negative effect but rather it is simply 0.85 units less than $b$ unless you can justify that $b$ is from a "standard" procedure. It might very well be that the $a$ intercept comes from the standard procedure and procedure $b$ would then have a positive effect. But all this assumes that either $a$ or $b$ can be labeled as a comparative standard. And that is not information that is intrinsic to the numbers.

If you want the separate intercepts, use the following:

nom = LinearModelFit[data, {x, y}, {x, y}, NominalVariables -> x,
IncludeConstantBasis -> False] // Normal


0.075 y + 1.325 DiscreteIndicator[x, a, {a, b}] + 2.175 DiscreteIndicator[x, b, {a, b}]

Hopefully your real data consists of many more than 4 data points.

• DiscreteIndicator[x,a,{a,b}] – user40188 Jun 30 '16 at 22:47
• I assume you're asking a question. DiscreteIndicator[x,a,{a,b}] is 1 when x==a and 0 otherwise. – JimB Jun 30 '16 at 22:55