I want to fit a Linear Regression in R to a categorical variable that have 3 levels. In particular, my data is the following:
Y = 1, X= "Type 1", A=0.5
Y = 2, X= "Type 2", A=0.3
Y =0.5,X= "Type 3", A=2
Do I simply do the following:
lm(Y~ X+ A)
?
lm(Y ~ X + A)
will work fine. IfX
isn't already a factor but is a vector of strings,lm
will treat it as a factor, using the first value as the reference category and including a dummy variable for each other level in the model. And ifX
is a factor, fine. – Horrify