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,
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:
http://r.789695.n4.nabble.com/regression-function-for-categorical-predictor-data-tp2532
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
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
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
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:
http://r.789695.n4.nabble.com/regression-function-for-categorical-predictor-data-tp25320
6 matches
Mail list logo