+ Reply to Thread
Results 1 to 4 of 4

Thread: Indicator Variable

  1. #1
    Points: 3,418, Level: 36
    Level completed: 46%, Points required for next Level: 82

    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Indicator Variable



    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?

  2. #2
    Bhoot
    Points: 1,270, Level: 19
    Level completed: 70%, Points required for next Level: 30

    Posts
    1,758
    Thanks
    40
    Thanked 124 Times in 106 Posts
    Hi
    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

    Regards
    Vinux

  3. #3
    Points: 6,576, Level: 53
    Level completed: 13%, Points required for next Level: 174

    Location
    Atlanta
    Posts
    113
    Thanks
    0
    Thanked 9 Times in 3 Posts
    Try as.factor, for example
    lm(y~x1+as.factor(decile)+x2)

    I think this is what you want.
    Many people would sooner die than think. In fact they do. - B. Russell

  4. #4
    Points: 3,489, Level: 36
    Level completed: 93%, Points required for next Level: 11

    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.
    Last edited by Rounds; 08-14-2008 at 06:36 PM.

+ Reply to Thread

Similar Threads

  1. How to create an indicator variable?
    By non-sleeper in forum Stata
    Replies: 0
    Last Post: 11-11-2010, 01:13 AM
  2. Need help with a problem with Indicator Random Variable
    By StatStudent3 in forum Probability
    Replies: 3
    Last Post: 10-05-2010, 07:24 PM
  3. Missing data: Use of the indicator method
    By Nick5930 in forum Biostatistics
    Replies: 0
    Last Post: 04-27-2010, 10:59 PM
  4. Stata Help: Indicator Variable Problem
    By bowser in forum Stata
    Replies: 1
    Last Post: 02-14-2010, 10:29 AM
  5. indicator variables
    By hanelliot in forum Probability
    Replies: 1
    Last Post: 02-14-2009, 07:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats