Re: [R] regression function for categorical predictor data

2010-09-09 Thread karena
Hi, thank you very much for the help. one more quick question: is that, my predictor variable should be coded as 'factor' when using either 'lm' or 'glm'? sincerely, karena -- View this message in context:

Re: [R] regression function for categorical predictor data

2010-09-09 Thread Joshua Wiley
Hi, If your predictor variable is categorical than it should be converted to a factor. If it is continuous or being treated as such, you do not need to. It is generally quite easy to do: varname - factor(varname) or if it is in a data frame yourdf$varname - factor(yourdf$varname) Cheers,

[R] regression function for categorical predictor data

2010-09-08 Thread karena
Hi, do you guys know what function in R handles the multiple regression on categorical predictor data. i.e, 'lm' is used to handle continuous predictor data. thanks, karena -- View this message in context:

Re: [R] regression function for categorical predictor data

2010-09-08 Thread Ted Harding
On 08-Sep-10 21:11:27, karena wrote: Hi, do you guys know what function in R handles the multiple regression on categorical predictor data. i.e, 'lm' is used to handle continuous predictor data. thanks, karena Karena, lm() also handles categorical data, provided these are presented as

Re: [R] regression function for categorical predictor data

2010-09-08 Thread Peng, C
glm() is another choice. Using glm(), you response variable can be a discrete random bariable, however, you need to specify the distribution in the argument: family = distriubtion name Use Teds simulated data and glm(), you get the same result as that produced in lm(): summary(glm(Y ~ X + F,

Re: [R] regression function for categorical predictor data

2010-09-08 Thread Peng, C
Sorry, result is not the same, since our datasets are different. I also run lm() based on the dataset that used in glm(). THe results are exactly the same: summary(lm(Y ~ X + F)) Call: lm(formula = Y ~ X + F) Residuals: Min 1Q Median 3Q Max -0.53796 -0.16201 -0.08087