View Full Version : Indicator Variable
06-28-2008, 08:29 AM
I just using R 2.7 this month and it is fantastic...I have a quick basic question for the board:
I have a column of data that represents decile ranked data. I would like run OLS regression using this and other varibles, but i need to tell R that this column is a "indicator varible". I would like to use the indicator approach rather than lableing it as a discrete variable.. Does someone know the script for R in order to change data indicative?
06-29-2008, 02:11 AM
Are you converting the decile variable to indicator variable? Convert into 9 indicator variable ( I guess there is 10 different values). If you do so .. you will loose the order relationship.
and you can do this by creating 9 new variable
like dec1 = (decile ==1)*1
dec2 = (decile ==2 )*1
Try as.factor, for example
I think this is what you want.
08-14-2008, 05:57 PM
as.factor will do it. As factor will cause all the resulting analysis to treat the variable as nominal. glm will create dummy variables automatically. And you will see it in the summary.
This is etched into my memory cause in the middle of last Mays final I realized having gotten completely to the end of long analysis that I had treated the variable as interval (the default if it isn't a factor). I had to go all the way back, start all the way over, and do it all again... Of course the result was different, the analysis was different, the best method for classification was different etc...
PS I would change the actual variable that you are storing. It is to easy to make a mistake if you dont.
Powered by vBulletin™ Version 4.1.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.