Posts mit dem Label statistics werden angezeigt. Alle Posts anzeigen
Posts mit dem Label statistics werden angezeigt. Alle Posts anzeigen

Sonntag, 9. August 2015

Understanding Multiple Regression with Dummy Variables

Recently, I played a bit with a special case of linear regression.

My real-world problem was that I had measured WLAN reception at different distances with 2 devices - a smartphone and a tablet computer. Now, there is a linear relationship between the distance and the log of the received power of the signal. But since the tablet has better antennae than the smartphone the values are shifted by a certain amount. If only I could do something like a combined linear regression over both sets of data which would give me 2 parallel regression lines with the same slope but different intercepts...
Finding a combined slope and different intercepts for
two sets of data == multiple regression with dummy variables

My stats courses were a long time ago and I think we only ever covered simple linear regression anyway. So I searched for "multiple regression" - and found how to do regression when the dependent variable depends on more than one independent variable, iow. when you have a y = f(x1, x2, ...,xn). But I had y1 = f(x) in combination with y2 = f(x)... While I decided to review the definition of simple linear regression to derive something myself I got a tip to take a look at multiple linear regression with dummy variables. Multiple regression with dummy variables is what I wanted - but because the explanations I found when googling around all ended with "and now you just put all that stuff into your stats program" it was not clear how it really works. So, while I did reinvent the wheel it helped me a lot in understanding the matter and I've decided to share my findings. It's actually not complicated at all, so enjoy!

Read more (download PDF) containing a derivation of how it works, showing how that connects to the explanations given in most stats books and tutorials and how to do multiple regression with dummy variables in R (including how to produce the graph shown above).