Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird names for factor in lm

I am using the data from the boys dataset from the package mice. When I run a regression on one of the factor variables (phb), the output shows the factors, but gives them a different name than in the data. I was wondering why this is the case. Is there a way to correct it?

library(mice)
data(boys)
# phb is already an ordered factor
table(boys$phb)

P1 P2 P3 P4 P5 P6 
63 40 19 32 50 41 

>summary(lm(age~factor(phb),data=boys))

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)   14.22660    0.09610 148.033   <2e-16 ***
factor(phb).L  6.24873    0.20493  30.492   <2e-16 ***
factor(phb).Q  0.06451    0.23668   0.273    0.785    
factor(phb).C  0.10205    0.22300   0.458    0.648    
factor(phb)^4 -0.12415    0.23413  -0.530    0.596    
factor(phb)^5 -0.12713    0.27299  -0.466    0.642    

So, the question I have is why is it outputting .L, .Q,.C, ^4,^5? I did a little research and this seems to stand for linear, quadratic, cubic. Why is this the case? I would just like it to be factor(phb).P1 ect.

like image 939
RayVelcoro Avatar asked Oct 19 '22 00:10

RayVelcoro


1 Answers

try factor( x , ordered = FALSE )

like image 54
user12392765 Avatar answered Oct 21 '22 16:10

user12392765