I have applied the lm() to a data set. The independent variables are categorical. First, I use lm() with intercept and I got the next results:
> model <- lm(y ~ factor(x))
> summary(model)
Call:
lm(formula = y ~ factor(x))
Residuals:
Min 1Q Median 3Q Max
-5.3085 -1.8132 -0.4136 1.4323 11.2480
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.3085 0.4064 22.907 <2e-16 ***
factor(x)0.75 0.1435 0.6896 0.208 0.836
factor(x)1.5 0.9062 0.6272 1.445 0.151
factor(x)3 0.9040 0.6989 1.293 0.198
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.786 on 126 degrees of freedom
Multiple R-squared: 0.0238, Adjusted R-squared: 0.0005601
F-statistic: 1.024 on 3 and 126 DF, p-value: 0.3844
In the second model I don't use intercept:
> model.1 <- lm(y ~ factor(x) - 1)
> summary(model.1)
Call:
lm(formula = y ~ factor(x) - 1)
Residuals:
Min 1Q Median 3Q Max
-5.3085 -1.8132 -0.4136 1.4323 11.2480
Coefficients:
Estimate Std. Error t value Pr(>|t|)
factor(x)0.25 9.3085 0.4064 22.91 <2e-16 ***
factor(x)0.75 9.4520 0.5572 16.96 <2e-16 ***
factor(x)1.5 10.2147 0.4778 21.38 <2e-16 ***
factor(x)3 10.2125 0.5687 17.96 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.786 on 126 degrees of freedom
Multiple R-squared: 0.9267, Adjusted R-squared: 0.9243
F-statistic: 398 on 4 and 126 DF, p-value: < 2.2e-16
If I don't understand the difference between the R-squared value of them? Could I accept the second one as a fit model?
Would somebody help me to understand this problem?